์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[Kubernetes] ServiceAccount, Role, RoleBinding ๊ด€๊ณ„

๐Ÿ˜Ž ์ง€์‹ in Action/โ˜๏ธ ๐Ÿ–ฅ๏ธ

by :ํ•ดํ”ผ๋ž˜๋น—๐Ÿพ 2026. 5. 24. 20:06

๋ณธ๋ฌธ

728x90

๋ˆ„๊ฐ€ ๋ฌด์—‡์„ ์—ฐ๊ฒฐ(๋ˆ„๊ฐ€ ๋ฌด์—‡์„ ํ•œ๋‹ค)

 

- ServiceAccount : ๊ถŒํ•œ์„ ์‚ฌ์šฉํ•  ์ฃผ์ฒด 

- Role : ์–ด๋–ค ๋ฆฌ์†Œ์Šค์— ์–ด๋–ค ํ–‰๋™์„ ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์ •์˜ 

- RoleBinding: ServiceAccount์™€ Role์„ ์—ฐ๊ฒฐ

 

 

apiVersion: v1
kind: ServiceAccount
metadata:
  name: app-sa
  namespace: dev
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: dev
  name: pod-reader

rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "list", "watch"]
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: dev

subjects:
- kind: ServiceAccount
  name: app-sa
  namespace: dev

roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

Role vs ClusterRole

Role : ํŠน์ • namespace ๋ฒ”์œ„, ํŠน์ • namespace ์•ˆ์—์„œ๋งŒ ๋™์ž‘ 

ClusterRole: Node ์กฐํšŒ, ๋ชจ๋“  namespace pod ์กฐํšŒ 

 

 

RoleBinding vs ClusterRoleBinding

RoleBinding namespace
ClusterRoleBinding cluster ์ „์ฒด

 

728x90

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ