Make Your Terminal DevOps and Kubernetes Friendly
Last updated
Last updated
If you work with DevOps and Kubernetes, you know how important the command line interface (CLI) is for managing tasks. Fortunately, there are tools available that make the terminal easier to use in these environments. In this article, we’ll explore some top tools that simplify your workflow and help you navigate the terminal with confidence in DevOps and Kubernetes.
Zsh (Z Shell) is a powerful and highly customizable command-line shell and terminal emulator that offers enhanced features and productivity improvements over traditional shells like Bash. Providing the following options makes it a popular choice among developers and DevOps engineers.
Oh My Zsh is an open-source, community-driven framework for managing your Zsh configuration. You can install it with curl as below:
zsh-syntx-highlighting is a plugin for the Zsh shell that provides real-time syntax highlighting for commands and their arguments as you type. It helps visually distinguish between different types of commands, options, paths, and variables, making it easier to spot errors and understand the structure of your commands in the terminal.
Follow the installation guide HERE.
This is what my terminal looks like before and after installing the tool:
zsh-autosuggestions is a helpful plugin for the Zsh shell that offers intelligent command suggestions as you type. It analyzes your command history and provides predictive suggestions for completing commands.
Follow the installation guide HERE.
This is what my terminal looks like before and after installing the tool:
If you work with Terraform and Terragrunt as Infrastructure as Code tools, then you might find the below relevant tools useful while working with Terraform and Terragrunt.
Tfswitch and tgswitch are command line tools that simplify switching between different versions of the 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 Mac, you can install these tools as below:
NOTE: For Terraform and Terragrunt installations to work with tfswitch and tgswitch on Mac with Zsh, you might need to add the below line to your .zshrc file.
Infracost is a powerful tool that helps you estimate and track the cost of your infrastructure as code (IaC) in platforms like Terraform. By analyzing your infrastructure configuration files, Infracost provides real-time cost estimates, allowing you to make informed decisions and optimize your cloud spending by identifying potential cost-saving opportunities.
This tool also has a Visual Studio Code (VSCode) extension.
This is what I got running it for a project:
TFSec is a security scanning tool specifically designed for Terraform code. It helps identify potential security vulnerabilities and best practice violations in your infrastructure as code, allowing you to proactively address security concerns and ensure compliance with industry standards and organizational policies.
You can install it on Mac as below:
This is what I got running it for my project:
There are also some tools that make your life easier if you work with Git!
Using aliases for Git offers numerous benefits, including enhanced productivity and efficiency by minimizing the need to repeatedly type lengthy Git commands. If you frequently work with Git, it is recommended to define aliases for commonly used Git commands in your .zshrc file. Here’s an example section to help you get started:
By defining these aliases in your shell configuration file (e.g., .bashrc or .zshrc), you can simply type the alias instead of the full Git command to execute common operations, saving you time and effort in your daily Git workflow.
GitLens is a helpful extension for VSCode that provides valuable insights and additional functionality when working with Git repositories. It enables users to easily track changes, view commit details, and understand code authorship directly within the code editor, enhancing collaboration and making it easier to navigate and explore the history of a project.
Once you enable the GitLens extension in Visual Studio Code, you will see clear indications of code authorship:
Git Graph is a user-friendly extension for Visual Studio Code that displays a visual representation of your Git repository’s commit history. It allows you to easily visualize branches, merges, and commits, providing a helpful overview of the project’s development timeline and making it simpler to navigate and understand the structure of your Git repository.
Due to the complexity of Kubernetes, many additional tools have been created to assist DevOps teams in effectively utilizing it. These tools are designed to simplify the process, allowing DevOps professionals to seamlessly work with Kubernetes and optimize their deployment and management tasks.
Just like using aliases for Git commands, utilizing aliases for Kubernetes commands is also beneficial. Aliases can make working with Kubernetes commands easier and more efficient, saving time and effort when interacting with Kubernetes clusters and resources.
These are just a few examples, and you can customize aliases based on your frequently used Kubernetes commands. By adding these aliases to your shell configuration file (e.g., .bashrc or .zshrc), you can use these shortcuts to execute Kubernetes commands quickly and easily.
Kube-ps1 enhances your command prompt with relevant information about your current Kubernetes context. It has been incredibly helpful for me while working with multiple Kubernetes clusters and managing different cluster contexts. Visually highlighting the details of the active cluster context, it has saved me from potential mistakes and provided clarity in navigating and interacting with Kubernetes environments.
You can install it on Mac as follow:
If you work with Zsh, make sure to add the below to your .zshrc file:
This is how this tool visualizes your current active context and namespace:
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 working with Kubernetes. (Its again one lifesaver tool while daily working with Kubernetes!)
Install it as below on Mac and make sure to add the second line to your .zshrc for it to work with kubectl auto-complete:
This is an example of how this tool colorizes the output of Kubernetes commands:
Kubectx and kubens are helpful tools for managing Kubernetes contexts and namespaces. Kubectx allows users to switch between different Kubernetes contexts, while Kubens simplifies switching between namespaces within a specific context, making it easier to work with multiple clusters and organize resources efficiently.
K9s is a user-friendly command-line tool that provides a visual dashboard for managing Kubernetes clusters. It offers a simple and intuitive interface to view and interact with resources, pods, logs, and events, making it easier for DevOps professionals to monitor and troubleshoot their Kubernetes deployments.
K8s Lens is a user-friendly desktop application that provides a graphical interface for managing and monitoring Kubernetes clusters. It offers a visual representation of resources, pods, and nodes, allowing users to easily navigate and interact with their Kubernetes environments, making it convenient for developers and administrators to work with Kubernetes.
Popeye is a helpful command-line tool that analyzes Kubernetes clusters and provides valuable insights regarding potential issues or misconfigurations. It scans the cluster configuration, namespaces, deployments, and pods to identify best practices violations, resource inefficiencies, and security concerns, helping users ensure their Kubernetes deployments are optimized and well-maintained.
This is the example information that scanning a cluster, Popeye will give you:
Install the tool on Mac as below:
Kube-shell is an integrated shell for Kubernetes CLI. It offers a user-friendly interface with visual representations of cluster resources, allowing users to easily navigate, monitor, and manage their Kubernetes deployments without needing to rely on command-line interfaces.
Kube-Capacity is a handy tool that provides insights into the resource usage and capacity of your Kubernetes cluster. It helps you understand how your cluster’s resources are allocated and utilized, allowing you to optimize resource allocation, plan for scaling, and ensure efficient resource management within your Kubernetes environment.