Notice
Recent Posts
Recent Comments
Link
«   2026/06   »
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
Tags more
Archives
Today
Total
관리 메뉴

holssi 님의 블로그

[CKA] ClusterRole, ClusterRoleBinding 문제 (1) 본문

CKA

[CKA] ClusterRole, ClusterRoleBinding 문제 (1)

holssi 2026. 1. 14. 15:00

 작업 클러스터는 k8s이고, 애플리케이션 운영 중 특정 네임스페이스의 파드들을 모니터링할 수 있는 서비스가 요청되었다. api-access 네임스페이스의 모든 파드를 볼 수 있도록 다음 작업을 진행할 것

1. api-access라는 새로운 네임스페이스 pod-viewer라는 이름의 service account를 생성

2. podreader-role이라는 role과 podreader-rolebinding이라는 rolebinding을 만들 것

3. 앞서 생성한 service account를 API resource Pod에 대해 watch, list, get을 허용하도록 매핑해라

 

0. 컨텍스트 전환

kubectl config use-context k8s
ssh k8s-master

 

1. api-access라는 네임스페이스 생성

kubectl create ns api-access

 

2. 네임스페이스 내에 pod-viewer라는 이름의 service account를 생성

kubectl create serviceaccount pod-viewer -n api-resources

 

3. podreader-role이라는 이름의 역할 생성

kubectl create role podreader-role --verb=list --verb=watch --resource=pods -n api-access

 

4. podreader-rolebinding이라는 이름의 rolebinding을 생성한 후, service account와 role 연결

kubectl create rolebinding podreader-rolebinding --role=podreader-role --serviceaccount=api-access:pod-viewer -n api-access

rolebinding을 만들때, role과 serviceaccount를 지정한다

이때, --serviceaccount=[네임스페이스 이름]:[서비스어카운트 이름]