How do I find and call the kube-apiserver in k3s / k3d (with Calico and without it)?

2k views Asked by At

I want to use the kube-apiserver to enable/disable admission controllers (e.g. kube-apiserver --enable-admission-plugins=NamespaceLifecycle), but I cannot find it anywhere.

When I run the following, I don't see it anywhere:

# Running this:
kubectl get pods -n kube-system

# Shows only this:
# NAME                                       READY   STATUS      RESTARTS   AGE
# helm-install-traefik-fvs4z                 0/1     Completed   0          10d
# local-path-provisioner-5ff76fc89d-rrntw    1/1     Running     4          10d
# coredns-854c77959c-vz4s2                   1/1     Running     4          10d
# metrics-server-86cbb8457f-6kl5n            1/1     Running     4          10d
# svclb-traefik-cc7zx                        2/2     Running     8          10d
# calico-kube-controllers-5dc5c9f744-6bwdj   1/1     Running     4          10d
# calico-node-xcjz8                          1/1     Running     4          10d
# traefik-6f9cbd9bd4-b6nk7                   1/1     Running     4          10d

I thought it might be due to using Calico, but even creating a cluster without Calico still shows no kube-apiserver:

# Running this:
kubectl get pods -n kube-system

# Shows only this:
# NAME                                      READY   STATUS      RESTARTS   AGE
# local-path-provisioner-5ff76fc89d-d28gc   1/1     Running     0          2m31s
# coredns-854c77959c-lh78n                  1/1     Running     0          2m31s
# metrics-server-86cbb8457f-xlzl2           1/1     Running     0          2m31s
# helm-install-traefik-nhxp4                0/1     Completed   0          2m31s
# svclb-traefik-hqndx                       2/2     Running     0          2m21s
# traefik-6f9cbd9bd4-m42jg                  1/1     Running     0          2m21s

Where is the kube-apiserver? How do I enable and disable controllers in k3d?

2

There are 2 answers

0
ilyesAj On

For people coming by and searching for answer:

K3s runs all control-plane components in a single systemd process. If you need to add extra arguments to one of them, you need to pass through the k3s.service.

For your example, in order to enable/disable admission controllers :

  1. add the following line to this file /etc/systemd/system/k3s.service
    --server-arg=--kube-apiserver-arg=enable-admission-plugins=NamespaceLifecycle
  1. restart control-plane

you may have disruption if you're not on HA mode.

systemctl daemon-reload && systemctl restart k3
  1. check logs to verify if everything is okey systemctl logs k3s.service

Hope it helps.

references:

7
coderanger On

It's not running via static pod, so it doesn't show up as a pod. With k3s you would usually install it as a systemd service unit. With k3d you can see it via docker ps.