2025년 6월 18일 수요일

rbac기반의 namespace 권한부여

 





perplexity에서 생성한 AI이미지

서비스 계정생성

$> kubectl create sa testuser

role설정

$> cat role.yaml
apiVersion: rbac.authozation.k8s.io/v1
kind: Role
metadata
  name: ms-role
  namespace: ms
rules:
- apiGroup: [""]
  resources: ["*"]
  verbs: ["get", "list", "watch"]

rolebinding 설정

$> rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: ms-rolebinding
  namespace: ms
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: ms-role
subjects:
- kind: ServiceAccount
  name: testuser
  namespace: ms

auth 확인

$> kubectl auth can-i get pods --namespace=ms --as=system:serviceaccouint:default:testuser
yes

user credential 생성

$> kubectl describe serviceaccount testuser

$> kubectl describe secret testuser-token-123

$> kubectl config set-credentials testuser --token=testuser-token-123

context생성

$> kubectl config set-context test-context --cluster=testcluster --as=system:serviceaccount:default:testuser
Context "test-context" created.

$> kubectl config get-contexts

$> kubectl config use-context test-context
Switched to context "test-context"

kube-config 반영



Reference

http://igoni.kr/books/3-containerkubernetes/page/rbac-namespace

댓글 없음:

댓글 쓰기

adfit

AI들끼리 대화하기

ChatGPT, perplexity, Gemini... 많은 AI 서비스가 있고 서비스별로 다양한 엔진이 있죠. 문득 AI끼리 대화를 시켜보면 어떤 대화의 흐름을 이어갈까 궁금해졌습니다. 그래서 해보았습니다. 규 칙 나(사람)은 양쪽 AI에서...