Useful utilities when working with Kubernetes
- Transfer

The article briefly discusses third-party Open Source utilities for Kubernetes that implement various features and are designed to help in everyday work. 4 of them are taken from English-language material and help in: automatic updating of configurations, tracking load on containers / pods / nodes, switching contexts, creating DIND clusters (Docker in Docker). The rest are found on GitHub and are presented with a short list.
Kube-applier
- GitHub .
- License: Apache License 2.0.
- Requirements: Go 1.7+, Docker 1.10+, Kubernetes 1.2.x — 1.4.x (with support for 1.5 and 1.6 there is a temporary problem ).
Box online storage service opens the source code for some of the tools used for deploying with Kubernetes. In April , one of such projects was presented - kube-applier.
Kube-applier runs as a service in Kubernetes, takes from the Git repository a set of configuration files for the Kubernetes cluster and sequentially applies them to the pods in the cluster. Whenever these changes appear in files, they are automatically taken from the repository and applied to the corresponding submissions. (See the configuration example for kube-applier here .)
Changes can also be applied on schedule or on request. Kube-applier logs its actions every time it starts and offers metrics for monitoring with Prometheus.

Kubetop
- GitHub .
- License: MIT License.
- Requirements: Python, Pip / Pipsi.
Kubetop is a console utility for listing all running nodes, all pods on these nodes and all containers in these pods, as well as the consumption of processor and RAM resources for each of them - similar to the classic Unix top utility. This tool cannot be recommended as a complete substitute for detailed logging / reporting, as the information they provide is very limited, but sometimes it’s such a brevity and a quick look at the status of the Kubernetes cluster can be very useful.
In fact,
kubectlKubernetes has a similar function, but Kubetop has a more visual output:kubetop - 13:02:57
Node 0 CPU% 9.80 MEM% 57.97 ( 2 GiB/ 4 GiB) POD% 7.27 ( 8/110) Ready
Node 1 CPU% 21.20 MEM% 59.36 ( 2 GiB/ 4 GiB) POD% 3.64 ( 4/110) Ready
Node 2 CPU% 99.90 MEM% 58.11 ( 2 GiB/ 4 GiB) POD% 7.27 ( 8/110) Ready
Pods: 20 total 0 running 0 terminating 0 pending
POD (CONTAINER) %CPU MEM %MEM
s4-infrastructure-3073578190-2k2vw 75.5 782.05 MiB 20.76
(subscription-converger) 72.7 459.11 MiB
(grid-router) 2.7 98.07 MiB
(web) 0.1 67.61 MiB
(subscription-manager) 0.0 91.62 MiB
(foolscap-log-gatherer) 0.0 21.98 MiB
(flapp) 0.0 21.46 MiB
(wormhole-relay) 0.0 22.19 MiBKubectx and K8senv
- Kubectx: announcement in a blog ; GitHub ; License: Apache License v2.
- K8senv: GitHub ; License: MIT License; requires Python (put via Pip).
Kubernetes uses the concept of context to access clusters with different configurations. Switching between them with the native console utility
kubectlis not very convenient, as a result of which there are third-party methods for solving this problem. Kubectx - Bash script that allows you to assign short names to Kubernetes contexts and switch between them. And if you pass a hyphen as an argument, then you switch to the previous context. The script also supports automatic addition of names by clicking on
$ kubectx minikube
Switched to context "minikube".
$ kubectx -
Switched to context "oregon".
$ kubectx -
Switched to context "minikube".
$ kubectx dublin=gke_ahmetb_europe-west1-b_dublin
Context "dublin" set.
Aliased "gke_ahmetb_europe-west1-b_dublin" as "dublin".Another context switching utility, k8senv, is slightly less functional.
kubeadm-dind-cluster
- GitHub .
- License: Apache License 2.0.
- Requirements: Docker 1.12+, Kubernetes 1.4.x, 1.5.x, 1.6.x.
As you know, for a test run of a local Kubernetes installation with a single node, there is a good turnkey solution from the project itself - Minikube . And for those who want to deploy clusters of many nodes for experimenting or developing Kubernetes itself, there is a product from Mirantis - kubeadm-dind-cluster (KDC).
KDC uses
kubeadmto run a cluster generated from Docker-containers instead of virtual machines (this applies DIND, Docker in Docker - approx Trans.. ). The chosen implementation allows you to restart the cluster faster, which is especially valuable if you need to quickly see the result of changes in the code when developing Kubernetes itself. You can also use KDC in continuous integration environments. It works in GNU / Linux, Mac OS and Windows, does not require the installation of Go, because uses dockerized builds of Kubernetes. An example of working with KDC based on Kubernetes 1.6:
$ wget https://cdn.rawgit.com/Mirantis/kubeadm-dind-cluster/master/fixed/dind-cluster-v1.6.sh
$ chmod +x dind-cluster-v1.6.sh
$ # запуск кластера
$ ./dind-cluster-v1.6.sh up
$ # добавление директории с kubectl в PATH
$ export PATH="$HOME/.kubeadm-dind-cluster:$PATH"
$ kubectl get nodes
NAME STATUS AGE
kube-master Ready,master 1m
kube-node-1 Ready 34s
kube-node-2 Ready 34s
$ # Kubernetes dashboard доступен на http://localhost:8080/ui
$ # перезапуск кластера, который произойдет намного быстрее первого старта
$ ./dind-cluster-v1.6.sh up
$ # остановка кластера
$ ./dind-cluster-v1.6.sh down
$ # удаление контейнеров и томов DIND
$ ./dind-cluster-v1.6.sh cleanOther utilities
List of other utilities for Kubernetes available on GitHub and not mentioned in the original article:
- kube-monkey - kills pods randomly by analogy with Netflix's Chaos Monkey (there is an alternative to chaoskube );
- Kubediff - shows the difference between Kubernetes configurations: currently running and described in the config (it can work as a service that periodically downloads the latest configuration from Git and compares it with the current one, supports sending notifications to Slack chat, has a web interface);
- ktmpl - Handles parameterized Kubernetes manifest templates
- kube-lint - Validates Kubernetes configurations and resources for compliance with the rules defined by you;
- kenv - inserts environment variables into the resource description;
- konfd - manages application configurations using Kubernetes secrets, configmaps and Go templates;
- kubernetes-secret-manager - manages secrets using Vash from Hashicorp;
- k8sec - also helps to manage Kubernetes secrets in the console;
- kube-ops-view - visually shows the current status of all the pods and nodes of the cluster using a dashboard written in JavaScript;

- kubewatch - monitors all events in the Kubernetes cluster and reports them in Slack chat;
- kube-slack - informs Slack about errors in hearth operation;
- k8stail - implements log output
tail -ffor all cluster headers.

PS from the translator
Read also in our blog:
- “ Kubebox and other console shells for Kubernetes ”;
- “ Useful commands and tips when working with Kubernetes through the kubectl console utility ”;
- “ Acquaintance with kube-spawn - a utility for creating local Kubernetes clusters ”;
- “ Package Manager for Kubernetes - Helm: Past, Present, Future ”;
- “ Introducing loghouse, the Open Source Logging System for Kubernetes .”