How can I customize the arguments to a kubernetes system pod such as kube-apiserver in Kind?

3/26/2020

I want to customize the arguments to kube-apiserver so that I can inspect the requests being made, so that I can debug a failing request. However, I'm not sure what I need to modify. I know that kube-apiserver can't be being deployed with helm, because helm requires an API server in order to do its job. So it must be being deployed via some other bootstrapping method, but looking at the kind source code I can't figure out what that method is.

-- Robin Green
kind
kubernetes

1 Answer

3/26/2020

The kube-apiserver is configured with a static manifest file, which is stored in /etc/kubernetes/manifests/kube-apiserver.yaml.

So find out the ID of the container that is the Kubernetes control plane node in kind:

docker ps|grep cluster-control-plane

Get a shell in it:

docker exec -it 4aeedccce928 bash

Install an editor (e.g. emacs) and edit the aforementioned file to add/remove/replace the desired arguments:

apt-get update
apt-get install emacs-nox
emacs /etc/kubernetes/manifests/kube-apiserver.yaml

Kubernetes will detect the file change and automatically restart the server, which can be validated with:

ps -Afl|grep kube-apiserver

If it crashes on startup, you can find the logs using

apt-get install less
less /var/log/pods/kube-system_kube-apiserver-cluster-control-plane_*/*/*.log

If the container fails to start at all, there will not be any log file there - check the manifest file for syntax errors by referring to the Kubernetes documentation.

-- Robin Green
Source: StackOverflow