Restart pods when configmap updates in Kubernetes?

The current best solution to this problem (referenced deep in https://github.com/kubernetes/kubernetes/issues/22368 linked in the sibling answer) is to use Deployments, and consider your ConfigMaps to be immutable. When you want to change your config, create a new ConfigMap with the changes you want to make, and point your deployment at the new ConfigMap. If the … Read more

Mount local directory into pod in minikube

You can’t mount your local directory into your Pod directly. First, you need to mount your directory $HOME/go/src/github.com/nginx into your minikube. $ minikube start –mount-string=”$HOME/go/src/github.com/nginx:/data” –mount Then If you mount /data into your Pod using hostPath, you will get you local directory data into Pod. There is another way Host’s $HOME directory gets mounted into … Read more

Helm install in certain order

Helm collects all of the resources in a given Chart and it’s dependencies, groups them by resource type, and then installs them in the following order (see here – Helm 2.10): Namespace ResourceQuota LimitRange PodSecurityPolicy Secret ConfigMap StorageClass PersistentVolume PersistentVolumeClaim ServiceAccount CustomResourceDefinition ClusterRole ClusterRoleBinding Role RoleBinding Service DaemonSet Pod ReplicationController ReplicaSet Deployment StatefulSet Job CronJob … Read more

What’s the best way to share/mount one file into a pod?

For example you have a configmap which contain 2 config files: kubectl create configmap config –from-file <file1> –from-file <file2> You could use subPath like this to mount single file into existing directory: — volumeMounts: – name: “config” mountPath: “/<existing folder>/<file1>” subPath: “<file1>” – name: “config” mountPath: “/<existing folder>/<file2>” subPath: “<file2>” restartPolicy: Always volumes: – name: … Read more

kubectl apply vs kubectl create?

Those are two different approaches: Imperative Management kubectl create is what we call Imperative Management. On this approach you tell the Kubernetes API what you want to create, replace or delete, not how you want your K8s cluster world to look like. Declarative Management kubectl apply is part of the Declarative Management approach, where changes … Read more

Why container memory usage is doubled in cAdvisor metrics?

That’s because cAdvisor takes these values from cgroups. The structure of cgroups looks like a tree, where there are branches for each pod, and every pod has child cgroups for each container in it. This is how it looks (systemd-cgls): ├─kubepods │ ├─podb0c98680-4c6d-4788-95ef-0ea8b43121d4 │ │ ├─799e2d3f0afe0e43d8657a245fe1e97edfdcdd00a10f8a57277d310a7ecf4364 │ │ │ └─5479 /bin/node_exporter –path.rootfs=/host –web.listen-address=0.0.0.0:9100 │ │ … Read more