CKS · Question #54
Use admin kubeconfig (because old kubectl config may break).
This instruction appears in CKA/CKAD/CKS exam simulations to remind candidates to explicitly use the admin kubeconfig file when executing kubectl commands, ensuring they have full cluster-admin privileges and avoid conflicts with a potentially misconfigured or context-switched ku
Question
Explanation
This instruction appears in CKA/CKAD/CKS exam simulations to remind candidates to explicitly use the admin kubeconfig file when executing kubectl commands, ensuring they have full cluster-admin privileges and avoid conflicts with a potentially misconfigured or context-switched kubeconfig.
Approach. The correct approach is to pass --kubeconfig=/etc/kubernetes/admin.conf explicitly to kubectl commands (e.g., kubectl get nodes --kubeconfig=/etc/kubernetes/admin.conf), or to set the KUBECONFIG environment variable: export KUBECONFIG=/etc/kubernetes/admin.conf. This is critical because exam tasks sometimes involve modifying or troubleshooting kubeconfig files, which can corrupt the current context and lock you out of the cluster. The admin.conf file at /etc/kubernetes/admin.conf is generated by kubeadm and always contains a valid cluster-admin credential bound directly to the API server certificate, so it remains reliable even if ~/.kube/config is broken.
Concept tested. Kubernetes kubeconfig management - understanding that kubectl resolves credentials via the KUBECONFIG env var or --kubeconfig flag, that /etc/kubernetes/admin.conf is the authoritative admin credential created by kubeadm, and that exam tasks requiring kubeconfig manipulation should be performed with a stable fallback kubeconfig to prevent self-lockout.
Reference. https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
Topics
Community Discussion
No community discussion yet for this question.