Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

전공공부

[K8S - CKA] CA KubeConfig 본문

Study/K8S

[K8S - CKA] CA KubeConfig

monitor 2024. 1. 7. 18:46

CA 설정이 모두 끝났다면 kube - apiserver에 요청 할 때마다 원래는 -- ca.crt 등의 요청을 기입하는 것을 알고 있을 것이다.

그러나, 우리는 절대 이런식으로 쓰지 않는다. kubectl get pod를 쓰지 kubectl get pod --ca.crt=/kube/... 이런식으로 다 기입 하지 않지 않는가? 그래서, 이를 간단히 해결 해 줄 방법책을 공유한다.

 

 

apiVersion: v1
kind: Config
current-context: my-cluster-context #별도 설정이 없다면 해당 context 셋팅을 기본으로 쓴다는 것이다.
clusters:
- name: my-cluster
  cluster:
    server: https://cluster-api-server-url
    certificate-authority: ca.crt

users:
- name: my-user
  user:
    client-certificate: admin.crt
    client-key: admin.key

contexts:
- name: my-cluster-context
  context:
    cluster: my-cluster
    user: my-user

 

만일, context가 여러개 일 때 context와 유저를 변경하려면 어떻게 해야 할까요?

kubectl config use-context prod-user@production

 

이렇게 하면 현재 유저와 클러스터가 변경이 됩니다.

 

그리고, 위 설정들은 namespace에 대해서도 적용이 가능합니다.

 

+) /root/.kube/config 위치의 config 값이 static pod 같이 현재 cluster와 유저 정보를 셋팅한 정보입니다.

'Study > K8S' 카테고리의 다른 글

[K8S - CKA] Authorization  (0) 2024.01.09
[K8S - CKA] API Groups  (1) 2024.01.08
[K8S - CKA] Certification API  (1) 2024.01.07
[K8S - CKA] TLS in K8S  (1) 2023.12.17
[K8S - CKA] TLS - Basic  (1) 2023.12.10