kuberneteskubespray

Where are the logs for kubernetes static pods?


I have created a cluster using KubeSpray. When I SSH to the master node to add EventRateLimit to the admission controller list in the static pod manifest yaml of Kubernetes API Server, the API Server pod does not properly restart.

I don't know where to find error logs for a static pod. How can I debug the issue?


Solution

  • To add EventRateLimit admission controller you need to modify the api server static pod yaml from /etc/kubernetes/manifests.

    ...
    spec:
      containers:
      - command:
        - kube-apiserver
        - --advertise-address=10.0.0.115
        - --allow-privileged=true
        - --authorization-mode=Node,RBAC
        - --client-ca-file=/etc/kubernetes/pki/ca.crt
        - --enable-admission-plugins=NodeRestriction,EventRateLimit
    ...
    

    Find the Kubernetes API server pod name

    kubectl get pods -n kube-system
    

    You can get logs of a static pod as you typically get logs of a regular pod

    kubectl logs apiserverpodname -n kube-system
    

    Alternatively directly check logs of the kubernetes API Server container by ssh into master node.

    Find the docker container id for Kubernetes API Server

    docker ps
    

    Check logs of the docker container

    docker logs container