1. 개념
- 쿠버네티스 클러스터에 접속하기 위한 설정·인증서 정보를 저장하고 있는 파일
- kubeconfig가 없을 경우 매번 아래와 같이 긴 명령어를 사용해야 함
kubectl get pod --server my-k8s:6443 --client-key admin.key --client-certificate admin.crt --certificate-authority ca.crt
- kubeconfig 파일은
$HOME/.kube/config
에 존재
- kubeconfig 구조
clusters
: 접속할 클러스터의 주소 정보
contexts
: 어떤 유저가 어떤 클러스터에 접속할지 정의한 정보
users
: 클러스터에 접속할 유저 정보
2. kubeconfig 확인
cat ~/.kube/config

3. config 핸들링
- kubeconfig 내용 확인 :
kubectl config view

- 기본 경로에 위치한 config가 아닌 경우 :
kubectl config view --kubeconfig=[경로]

- 클러스터 목록 확인 :
kubectl config get-clusters

- 컨택스트 목록 확인 :
kubectl config get-contexts

- 현재 컨텍스트 확인 :
kubectl config current-context

- 컨텍스트 변경 :
kubectl config use-context [컨텍스트]

참고
- https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/
- https://nayoungs.tistory.com/entry/Kubernetes-Kubeconfig