📜 ⬆️ ⬇️

Useful utilities when working with Kubernetes



The article briefly discusses third-party Open Source utilities for Kubernetes that implement various features and are designed to help with daily work. 4 of them are taken from an English-language material and help in: automatic updating of configurations, tracking the load on containers / subnets / nodes, context switching, creating DIND clusters (Docker in Docker). The rest are found on GitHub and presented in a short list.

Kube-applier



The online storage service Box opens the source code of some of the tools used for deployment with Kubernetes. In April , one of these projects was presented - kube-applier.
')
Kube-applier is launched as a service in Kubernetes, takes from the Git-repository a set of configuration files for the Kubernetes cluster and consistently applies them to subsets in the cluster. Whenever these changes appear in the files, they are automatically taken from the repository and applied to the corresponding sub-fields. (Configuration example for kube-applier see 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



Kubetop is a console utility for displaying a list of all running nodes, all hearths on these nodes and all containers in these hearths, as well as the consumption of processor resources and RAM for each of them - similar to the classic Unix top utility. This tool cannot be recommended as a full replacement for detailed logging / reporting, since the information they provide is very limited, but sometimes it is precisely this brevity and a quick look at the status of the Kubernetes cluster can be very useful.

In fact, the kubectl in Kubernetes has a similar function, but Kubetop has a clearer conclusion:

 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 MiB 

Kubectx and K8senv



To refer to clusters with different configurations, Kubernetes uses the concept of context. Switching between them with the native console utility kubectl is not very convenient, resulting in 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, it switches to the previous context. The script also supports the automatic addition of names by pressing the <Tab>.

 $ 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 a bit less functional.

kubeadm-dind-cluster



As you know, for a test run of a local installation of Kubernetes with one node, there is a good ready-made solution from the project itself - Minikube . And for those who want to deploy clusters from many nodes for experimenting or developing Kubernetes itself, there is a product from Mirantis - kubeadm-dind-cluster (KDC).

The KDC uses kubeadm to start a cluster created from Docker containers instead of virtual machines (for this, use DIND, Docker in Docker - approx. Transl. ) . The selected implementation allows you to quickly restart the cluster, 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. Works in GNU / Linux, Mac OS and Windows, does not require Go installation, since uses doberized 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 clean 

Other utilities


The list of other auxiliary utilities for Kubernetes, available on GitHub and not mentioned in the original article:







PS from translator


Read also in our blog:

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


All Articles