laitimes

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

author:Seal software

If you're familiar with DevOps and the use of Kubernetes, you know how important the command-line interface (CLI) is for administrative tasks. Fortunately, there are tools on the market that can make terminals easier to use in these environments. In this article, we'll explore great tools that can streamline your workflow and help you navigate the terminal with ease in DevOps and Kubernetes.

Zsh

Zsh (Z Shell) is a powerful, highly customizable command-line shell and terminal emulator that is more powerful and efficient than traditional shells like Bash. Zsh is popular with developers and DevOps engineers because of its options for the following options.

ohmyzsh

Oh My Zsh is an open source, community-driven framework for managing Zsh configurations. You can install it using curl as follows:

sh -c "$(curl -fsSL <https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh>)"
           

zsh-syntax-highlighting

zsh-syntx-highlighting is a plugin for the Zsh shell that provides real-time syntax highlighting for commands and their parameters as they are entered. It helps to visually distinguish between different types of commands, options, paths, and variables, making it easier to spot errors and understand the structure of commands in the terminal.

Follow the installation guide:

https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md

Here's what my terminal looks like before and after installing the tool:

Before installation

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

After installation

zsh-autosuggestions

zsh-autosuggestions is a useful plugin for the Zsh shell that provides intelligent command suggestions as the user types a command. It analyzes your command history and provides predictive recommendations for completing commands.

Please refer to the installation guide:

https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md

Here's what my terminal looks like before and after installing the tool:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

Before installation

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

After installation

Terraform

If you use Terraform and Terragrunt as infrastructure code tools, you may find the following related tools useful when using Terraform and Terragrunt.

tfswitch and tgswitch

Tfswitch and tgswitch are command-line tools that simplify switching between different versions of Terraform and Terragrunt infrastructure-as-code tools. They allow developers and operators to easily manage and switch between different versions of Terraform and Terragrunt for different projects or environments.

On your Mac, you can install these tools as follows:

brew install warrensbox/tap/tfswitch
brew install warrensbox/tap/tgswitch
           

Note: When installing Terraform and Terragrunt using Zsh on a Mac, you may need to add the following line to the .zshrc file to use tfswitch and tgswitch.

export PATH=$HOME/bin:/usr/local/bin:$PATH
           

Infracost

Infracost is a powerful tool that helps you estimate and track the cost of infrastructure as code (IaC) in platforms like Terraform. By analyzing infrastructure profiles, Infracost provides real-time cost estimates, allowing you to make informed decisions and optimize cloud spend by identifying potential cost-saving opportunities.

The tool also has a Visual Studio Code (VSCode) extension.

This is the result of my run in a project:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

TfSec

TFSec is a security scanning tool designed for Terraform code. It helps identify potential security vulnerabilities and violations of best practices in your code infrastructure, allowing you to proactively address security issues and ensure compliance with industry standards and organizational policies.

You can install it on your Mac as follows:

brew install tfsec
           

This is the result of running it in my project:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

Git

If you use Git, here are some tools that can make your job easier and more convenient.

Git aliases

There are many benefits to using aliases for Git, including increased productivity and efficiency by reducing the need to repeatedly enter lengthy Git commands. If you use Git frequently, it is recommended to define aliases for common Git commands in a .zshrc file. Here's an example to help you get started with Git:

# Git aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gpl='git pull'
alias gb='git branch'
           

By defining these aliases in a shell configuration file such as .bashrc or .zshrc, you can perform common actions by typing the alias instead of the full Git command, saving time and effort in your daily Git workflow.

GitLens

GitLens is a useful extension to VSCode that provides valuable insights and additional functionality when working with Git repositories. It enables users to easily track changes, view commit details, and learn about code authorship directly in the code editor, enhancing collaboration and making it easier to navigate and explore project history.

After you enable the GitLens extension in Visual Studio Code, you'll see a clear indication of code authorship:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

Git Graph

Git Graph is a user-friendly extension to Visual Studio Code that visualizes the commit history of a Git repository. It makes it easy to visualize branches, merges, and commits, has a useful overview of your project's development timeline, and makes it easier to navigate and understand the structure of your Git repository.

Kubernetes

Due to the complexity of Kubernetes, many additional tools have been created to help DevOps teams leverage it effectively. These tools are designed to streamline processes, enable DevOps professionals to use Kubernetes seamlessly and optimize their deployment and management tasks.

Kubernetes aliases

Just like using aliases for Git commands, there are benefits to using aliases for Kubernetes commands. Aliases make it easier and more efficient to use Kubernetes commands, saving time and effort when interacting with Kubernetes clusters and resources.

alias k='kubectl'
           
# For switching context between different clusters
alias kswitch-maryam='kubectl config use-context maryam'
alias kswitch-mary='kubectl config use-context mary'
alias kpod='kubectl get pods -A'
alias knode='kubectl get nodes'
alias kdesp='kubectl describe pod'
alias kdp='kubectl delete pod'
alias kgd='kubectl get deployments'
           

These are just a few examples, and you can customize aliases based on common Kubernetes commands. Adding these aliases to a shell configuration file such as .bashrc or .zshrc allows you to use these shortcuts to quickly and easily execute Kubernetes commands.

Kube-PS1

Kube-ps1 provides your command prompt with relevant information about the current Kubernetes context. Useful when working with multiple Kubernetes clusters and managing different cluster contexts. The tool visually highlights the details of the active cluster context, helping users avoid potential errors and provide greater clarity when navigating and interacting with the Kubernetes environment.

You can install it on your Mac as follows:

brew install kube-ps1
           

If you use Zsh, make sure to add the following to your .zshrc file:

plugins=(
  kube-ps1
)
           
PROMPT='$(kube_ps1)'$PROMPT # or RPROMPT='$(kube_ps1)'
           

This is how the tool visualizes the current active context and namespace:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

kubecolor

Kubecolor is a handy tool that enhances the output of Kubernetes commands with color and formatting, making it easier to read and understand. Kubecolor improves visibility and helps quickly identify important information when using Kubernetes. (It's also a lifesaver when using Kubernetes on a daily basis!) )

Install the following on your Mac, and make sure to add a second line to .zshrc to work with kubectl autocomplete:

brew install hidetatz/tap/kubecolor
# get zsh complete kubectl
source <(kubectl completion zsh)
alias kubectl=kubecolor
# make completion work with kubecolor
compdef kubecolor=kubectl
           

Here is an example of how the tool colors the output of a Kubernetes command:

kubectx + kubens

Kubectx + kubens is an excellent tool for managing Kubernetes contexts and namespaces. Kubectx allows users to switch between different Kubernetes contexts, while Kubens simplifies switching between namespaces within specific contexts, making it easier to work with multiple clusters and organize resources efficiently.

K9s

K9s is a user-friendly command-line tool that provides a visual dashboard for managing Kubernetes clusters. It provides a simple and intuitive interface for viewing and interacting with resources, pods, logs, and events, making it easier for DevOps professionals to monitor and troubleshoot Kubernetes deployments.

k8s Lens

K8s Lens is a user-friendly desktop application that provides a graphical interface for managing and monitoring Kubernetes clusters. It provides a visual representation of resources, pods, and nodes, allowing users to easily navigate and interact with the Kubernetes environment, making it easy for developers and administrators to consume Kubernetes.

popeye

Popeye is a great command-line tool that analyzes Kubernetes clusters and provides valuable suggestions for potential problems or misconfigurations. It scans cluster configurations, namespaces, deployments, and pods for best practice violations, resource inefficiencies, and security issues, helping users ensure that Kubernetes deployments are optimized and well maintained.

The following is sample information that Popeye provides when scanning a cluster:

Recommended tool! Make the terminal easy to use for DevOps and Kubernetes

Install the tool on your Mac as follows:

brew install derailed/popeye/popeye
           

Kube-shell

Kube-shell is an integrated shell for the Kubernetes CLI. It provides a user-friendly interface that visualizes cluster resources, allowing users to easily navigate, monitor, and manage their Kubernetes deployments without relying on a command-line interface.

Kube-Capacity

Kube-Capacity is a tool that gives you insight into the resource usage and capacity of your Kubernetes cluster. It helps you understand how cluster resources are allocated and utilized, allowing you to optimize resource allocation, plan for scaling, and ensure efficient resource management in your Kubernetes environment.

Reference Links:

https://awstip.com/tools-to-make-your-terminal-devops-and-kubernetes-friendly-64d27a35bd3f