Kubernetes tips and tricks: how to increase productivity

Kubectl is an effective Kubernetes command-line tool and for Kubernetes, we use it daily. It has many features, and with it you can deploy the Kubernetes system or its basic features.

Here are some useful tips on how to code and deploy faster in Kubernetes.

Kubectl autocomplete

You will use Kubectl all the time, so with autocompletion you won’t have to knock keys again.

Install the bash-completion package first (it is not installed by default).

## Install apt-get install bash-completion ## Bash echo 'source <(kubectl completion bash)' >>~/.bashrc ## Zsh source <(kubectl completion zsh) 

 ## Install brew install bash-completion@2 

As you can see in the output of brew install (Caveats section), you need to add the following lines to the ~/.bashrc ~/.bash_profile :

 export BASH_COMPLETION_COMPAT_DIR=/usr/local/etc/bash_completion.d [[ -r /usr/local/etc/profile.d/bash_completion.sh ]] && . /usr/local/etc/profile.d/bash_completion.sh 

Aliases kubectl

When you start using kubectl, the best part is a ton of aliases, starting from this:

 alias k='kubectl' 

Added it - then take on kubectl-aliases on Github. Ahmet Alp Balkan ( https://twitter.com/ahmetb ) understands them, learn more about his aliases on github

Just do not install the alias kubectl for a beginner, otherwise he will not understand all the commands in life. Let him practice a week or two first.

Kubernetes + Helm Charts

Helm is the best way to find, distribute, and use software built for Kubernetes.”

When you get a bunch of Kubernetes applications up and running, deploying them and updating them will turn into flour, especially if you need to update the docker image tag before deployment. Helm charts create packages with which you can define, install and update applications and configuration when they are launched on a cluster by a release system.

Helm's Kubernetes package is called a chart and contains a lot of information from which an instance of Kubernetes is created.

The configuration is very useful: it contains dynamic information about setting up the chart. A release is an existing instance in a cluster combined with a specific configuration.

Unlike apt or yum, Helm charts (i.e. packages) are collected on top of Kubernetes and take full advantage of its cluster architecture, and the coolest of them is the ability to take into account scalability from the very beginning. The charts of all the images that Helm uses are stored in a registry called Helm Workspace. Once deployed, your DevOps teams will be able to find charts in two accounts and add them to their projects.

Helm can be installed in other ways:

 sudo snap install helm --classic 

 brew install kubernetes-helm 

 curl -L https://git.io/get_helm.sh | bash 


 helm init --history-max 200 

 helm repo update helm install --name releasemysql stable/mysql 

These commands will release the stable / mysql chart, and the release is called releasemysql.
Check out the helm release using the helm list.

 helm delete --purge releasemysql 

Follow these tips and work with Kubernetes more lively. Free time by devoting yourself to the main goal of your Kubernetes applications in the cluster. If you have questions about Kubernetes or Helm, write to us .

Source: https://habr.com/ru/post/463299/

All Articles