Posted on 3 July 2019, updated on 28 July 2023.
As we know, kubectl is a powerful command line tool from and for Kubernetes that we are using every day. It has broad functionalities and helps us deploying Kubernetes system or some basic Kubernetes features.
Here’s are Kubernetes tips and tricks to code and deploy faster.
You are going to use the command kubectl a lot. Using autocompletion will save you a lot of typing
First, install bash-completion package (which is not installed by default)
- Mac Os
As stated in the output of brew install (“Caveats” section), add the following lines to your ~/.bashrc or ~/.bash_profile file:
One of the most useful weapons, when you start using kubectl, must be the tons of alias you can set up starting by this one
After adding this one, you can run into kubectl-aliases on Github. Ahmet Alp Balkan did it pretty well, you can find more about his aliases on his github
Be careful, do not install kubectl alias for a newbie right away otherwise they will never understand the meaning of the commands, do it after one or two weeks of practice.
Kubernetes + Helm Charts
“Helm is the best way to find, share, and use software built for Kubernetes.”
When you start running a lot of Kubernetes applications, deployments and update can be really painful, especially when you need to update the docker image’s tag before deploying. Helm Charts is a packager which helps define, install and upgrade your applications and configuration while running on your cluster by a system of release.
A Kubernetes package is called Charts in Helm, it contains a lot of information needed to create a Kubernetes instance.
Config is the useful point there, it contains dynamic information about setting up a Chart. A Release is an existing instance on the cluster, combined with a specific Config.
Unlike apt or yum, Helms charts (package) are built atop Kubernetes and benefit from its cluster architecture. One of his main benefits is the ability to consider scalability from the start. The carts of all the images used by Helm are stored in a registry called Helm Workspace. So once deployed, your DevOps teams can easily search charts and add to their projects with ease.
You can install Helm through different methods :
- Snap / Linux :
sudo snap install helm --classic
- Homebrew / macOs :
brew install kubernetes-helm
- Through script :
curl -L https://git.io/get_helm.sh | bash
- Binary Releases :
- Initialize Helm and install Tiller on your cluster :
helm init --history-max 200
- Then install an example chart
The commands above release stable/mysql chart and the name of this release is releasemysql.
You can verify your helm release with `helm list`
- You can finally uninstall a release
helm delete --purge releasemysql
These tips and tricks will have a significant impact on your productivity while using Kubernetes. Using less times on these will allow you to focus more on the main goal of your kubernetes applications on your cluster. After productivity comes security, learn how to create Kubernetes Secrets in this article.