Kubernetes tips and tricks: how to increase productivity

Kubernetes tips and tricks: how to increase productivity

Kubectl is an efficient Kubernetes command line tool for Kubernetes and we use it daily. It has many features and can be used to deploy a Kubernetes system or its core features.

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

kubectl autocomplete

You'll use Kubectl all the time, so with autocomplete, you won't have to hit the keys again.

First install the bash-completion package (it is not installed by default).

  • Linux

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

  • MacOS

## Install
brew install bash-completion@2

As you can see in the brew install output (Caveats section), you need to add the following lines to the file ~/.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

kubectl aliases

When you start using kubectl, the best part is that there are tons of aliases, starting with this:

alias k='kubectl'

We 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

Kubernetes tips and tricks: how to increase productivity

Just don't set up a kubectl alias for a newbie, otherwise he won't understand all the commands in his life. Let him practice for a week or two first.

Kubernetes + Helm Charts

«Helmet is the best way to discover, distribute and use software built for Kubernetes."

When you have a bunch of Kubernetes applications up and running, deploying and updating them becomes a chore, especially if you need to update the docker image tag before deploying. Helm charts create packages with which applications and configuration can be defined, installed, and updated when they are run on the cluster by the release system.

Kubernetes tips and tricks: how to increase productivity

The Kubernetes package in Helm is called a chart and contains a lot of information on how to create a Kubernetes instance.

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

Unlike apt or yum, Helm charts (that is, packages) build on top of Kubernetes and take full advantage of its cluster architecture, the coolest of which is the ability to consider scalability from the start. The charts for 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 no time and add them to their projects.

Helm can be installed in other ways:

  • Snap/Linux:

sudo snap install helm --classic

  • homebrew/macOS:

brew install kubernetes-helm

  • Script:

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

  • File:

https://github.com/helm/helm/releases

  • Initialize Helm and install Tiller on the cluster:

helm init --history-max 200

  • Install chart example:

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

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

  • Finally, the release can be removed:

helm delete --purge releasemysql

Follow these tips and you'll be up and running with Kubernetes. Devote the freed time to the main goal of your Kubernetes applications in the cluster. For questions about Kubernetes or Helm, write to us.

Source: habr.com

Add a comment