[AEWS] #6์ฃผ์ฐจ EKS ์ธ์ฆ/์ธ๊ฐ€ (3)

25๋…„๋„ AWS EKS Hands-on Study ์Šคํ„ฐ๋”” ์ •๋ฆฌ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค.

 

RBAC ๊ถŒํ•œ ํ™•์ธ

kubectl krew install access-matrix rbac-tool rbac-view rolesum whoami

 

์‹ค์Šต์„ ์œ„ํ•œ ๋„๊ตฌ๋ฅผ ์„ค์น˜ํ•œ๋‹ค.

  • access-matrix: ์‚ฌ์šฉ์ž์˜ RBAC ๊ถŒํ•œ์„ ๋งคํŠธ๋ฆญ์Šค๋กœ ํ™•์ธ
  • rbac-tool: RBAC ์—ญํ• (Role)๊ณผ ๋ฐ”์ธ๋”ฉ ์ •๋ณด๋ฅผ ์กฐํšŒ
  • rbac-view: ์›น UI์—์„œ RBAC ์—ญํ• ์„ ์‹œ๊ฐ์ ์œผ๋กœ ๋ถ„์„
  • rolesum: RBAC ์š”์•ฝ ์ •๋ณด๋ฅผ ์ œ๊ณต
  • whoami: ํ˜„์žฌ ์ปจํ…์ŠคํŠธ์—์„œ์˜ ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž ํ™•์ธ
kubectl rolesum aws-node -n kube-system
ServiceAccount: kube-system/aws-node
Secrets:
Policies:
โ€ข [CRB] */aws-node โŸถ [CR] */aws-node
Resource Name Exclude Verbs G L W C U P D DC
cninodes.vpcresources.k8s.aws [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ” โœ– โœ–
eniconfigs.crd.k8s.amazonaws.com [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
events.[,events.k8s.io] [*] [-] [-] โœ– โœ” โœ– โœ” โœ– โœ” โœ– โœ–
namespaces [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
nodes [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
pods [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
policyendpoints.networking.k8s.aws [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
policyendpoints.networking.k8s.aws/status [*] [-] [-] โœ” โœ– โœ– โœ– โœ– โœ– โœ– โœ–

 

aws-node SA๋Š” AWS VPC CNI ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ๋„คํŠธ์›Œํฌ ๊ด€๋ จ ๋ฆฌ์†Œ์Šค๋ฅผ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•„์š”ํ•œ ๊ถŒํ•œ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

  • cninodes.vpcresources.k8s.aws VPC CNI ๊ด€๋ จ ๋…ธ๋“œ ๊ด€๋ฆฌ
  • eniconfigs.crd.k8s.amazonaws.com AWS ENI(Elastic Network Interface) ์„ค์ • ๊ด€๋ฆฌ
  • nodes ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ๋…ธ๋“œ ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • pods Pod ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • policyendpoints.networking.k8s.aws ๋„คํŠธ์›Œํฌ ์ •์ฑ… ์ ์šฉ
kubectl rolesum -k User system:kube-proxy
User: system:kube-proxy
Policies:
โ€ข [CRB] */system:node-proxier โŸถ [CR] */system:node-proxier
Resource Name Exclude Verbs G L W C U P D DC
endpoints [*] [-] [-] โœ– โœ” โœ” โœ– โœ– โœ– โœ– โœ–
endpointslices.discovery.k8s.io [*] [-] [-] โœ– โœ” โœ” โœ– โœ– โœ– โœ– โœ–
events.[,events.k8s.io] [*] [-] [-] โœ– โœ– โœ– โœ” โœ” โœ” โœ– โœ–
nodes [*] [-] [-] โœ” โœ” โœ” โœ– โœ– โœ– โœ– โœ–
services [*] [-] [-] โœ– โœ” โœ” โœ– โœ– โœ– โœ– โœ–

 

Kube-Proxy๋Š” ํด๋Ÿฌ์Šคํ„ฐ ๋„คํŠธ์›Œํ‚น์„ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ์„œ๋น„์Šค ๋ฐ ์—”๋“œํฌ์ธํŠธ ์ •๋ณด๋ฅผ ๊ฐ€์ง„๋‹ค.

  • endpoints ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ์„œ๋น„์Šค์˜ ์—”๋“œํฌ์ธํŠธ ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • endpointslices.discovery.k8s.io ์„œ๋น„์Šค์˜ ์—”๋“œํฌ์ธํŠธ ์Šฌ๋ผ์ด์Šค ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • events.[,events.k8s.io] ์ด๋ฒคํŠธ ๊ด€๋ จ ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • nodes ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ๋…ธ๋“œ ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
  • services ์„œ๋น„์Šค ์ •๋ณด ์กฐํšŒ ๊ฐ€๋Šฅ
kubectl rolesum -k Group system:masters
Group: system:masters
Policies:
โ€ข [CRB] */cluster-admin โŸถ [CR] */cluster-admin
Resource Name Exclude Verbs G L W C U P D DC
*.* [*] [-] [-] โœ” โœ” โœ” โœ” โœ” โœ” โœ” โœ”

 

ํด๋Ÿฌ์Šคํ„ฐ ๊ด€๋ฆฌ์ž ๊ทธ๋ฃน์œผ๋กœ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์ตœ๊ณ  ๊ถŒํ•œ์ธ cluster-admin ์—ญํ• ์„ ๋ถ€์—ฌ๋ฐ›์•„ ๋ชจ๋“  ๋ฆฌ์†Œ์Šค๋ฅผ ์ˆ˜์ • ๊ฐ€๋Šฅํ•˜๋‹ค.

 

kubectl rolesum -k Group system:nodes
Group: system:nodes
Policies:
โ€ข [CRB] */eks:node-bootstrapper โŸถ [CR] */eks:node-bootstrapper
Resource Name Exclude Verbs G L W C U P D DC
certificatesigningrequests.certificates.k8s.io/selfnodeserver [*] [-] [-] โœ– โœ– โœ– โœ” โœ– โœ– โœ– โœ–

 

EKS(๋˜๋Š” Kubernetes ํด๋Ÿฌ์Šคํ„ฐ)์—์„œ ์ƒˆ๋กœ์šด ๋…ธ๋“œ๊ฐ€ ํด๋Ÿฌ์Šคํ„ฐ์— ์ถ”๊ฐ€๋  ๋•Œ ํ•„์š”ํ•œ ๊ถŒํ•œ์€ eks:node-bootstrapper๋กœ ๋ถ€ํ„ฐ ์ฃผ์–ด์ง€๋Š”๋ฐ,

๋…ธ๋“œ(Kubelet)๋Š” ์ž์‹ ์˜ ์ธ์ฆ์„œ๋ฅผ ์š”์ฒญ(Certificate Signing Request, CSR)ํ•˜๊ณ  ๊ด€๋ฆฌ์ž๋กœ๋ถ€ํ„ฐ ์Šน์ธ๋ฐ›์•„์•ผ API ์„œ๋ฒ„์™€ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ๋œ๋‹ค.

๋…ธ๋“œ๋Š” API ์„œ๋ฒ„์™€ ์•ˆ์ „ํ•˜๊ฒŒ ํ†ต์‹ ํ•˜๊ธฐ ์œ„ํ•ด ์ž์ฒด ์ธ์ฆ์„œ ์š”์ฒญ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

 

kubectl rolesum -k Group system:authenticated
Group: system:authenticated
Policies:
โ€ข [CRB] */system:basic-user โŸถ [CR] */system:basic-user
Resource Name Exclude Verbs G L W C U P D DC
selfsubjectaccessreviews.authorization.k8s.io [*] [-] [-] โœ– โœ– โœ– โœ” โœ– โœ– โœ– โœ–
selfsubjectreviews.authentication.k8s.io [*] [-] [-] โœ– โœ– โœ– โœ” โœ– โœ– โœ– โœ–
selfsubjectrulesreviews.authorization.k8s.io [*] [-] [-] โœ– โœ– โœ– โœ” โœ– โœ– โœ– โœ–
โ€ข [CRB] */system:discovery โŸถ [CR] */system:discovery
โ€ข [CRB] */system:public-info-viewer โŸถ [CR] */system:public-info-viewer

 

API ์„œ๋ฒ„์— ์ธ์ฆ๋œ ๋ชจ๋“  ์‚ฌ์šฉ์ž๊ฐ€ ์ž๋™์œผ๋กœ ํฌํ•จ๋˜๋Š” ๊ทธ๋ฃน์œผ๋กœ RBAC ์ •์ฑ…์„ ํ†ตํ•ด ํŠน์ • ๋ฆฌ์†Œ์Šค์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.

 

EKS ์ธ์ฆ

EKS์—์„œ ์•ก์„ธ์Šค ์ œ์–ด๋Š” AWS Identity and Access Management(IAM)๊ณผ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ์—ญํ•  ๊ธฐ๋ฐ˜ ์•ก์„ธ์Šค ์ œ์–ด(RBAC)๋ฅผ ๊ฒฐํ•ฉํ•˜์—ฌ ์ด๋ฃจ์–ด์ง„๋‹ค. IAM์€ ํด๋Ÿฌ์Šคํ„ฐ์— ๋Œ€ํ•œ ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  Kubernetes RBAC๋Š” ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ๊ด€๋ฆฌํ•œ๋‹ค.

 

  • IAM ์‚ฌ์šฉ์ž ๋ฐ ์—ญํ• ์˜ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค API ์•ก์„ธ์Šค ๋ถ€์—ฌ: IAM ์‚ฌ์šฉ์ž ๋˜๋Š” ์—ญํ• ์ด Kubernetes API์— ์ ‘๊ทผํ•˜๋ ค๋ฉด ์•ก์„ธ์Šค ํ•ญ๋ชฉ์„ ์‚ฌ์šฉํ•˜์—ฌ Kubernetes RBAC ๊ถŒํ•œ์„ ํ•ด๋‹น IAM ์—”ํ„ฐํ‹ฐ์™€ ์—ฐ๊ฒฐํ•˜์—ฌ ๊ฐœ๋ฐœ์ž๋‚˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ํด๋Ÿฌ์Šคํ„ฐ์™€ ์ƒํ˜ธ ์ž‘์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.
  • AWS Management Console์—์„œ Kubernetes ๋ฆฌ์†Œ์Šค ๋ณด๊ธฐ: AWS Management Console์„ ํ†ตํ•ด ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋„ค์ž„์ŠคํŽ˜์ด์Šค, ๋…ธ๋“œ, ํŒŒ๋“œ์™€ ๊ฐ™์€ Kubernetes ๋ฆฌ์†Œ์Šค๋ฅผ ์‹œ๊ฐํ™”ํ•˜๊ธฐ ์œ„ํ•ด ์ฝ˜์†”์ด Amazon EKS ํด๋Ÿฌ์Šคํ„ฐ์™€ ํ†ต์‹ ํ•˜๋„๋ก ๊ตฌ์„ฑํ•ด์•ผ ํ•œ๋‹ค.
  • kubectl์„ EKS ํด๋Ÿฌ์Šคํ„ฐ์— ์—ฐ๊ฒฐ: AWS CLI๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ kubeconfig ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ์—…๋ฐ์ดํŠธํ•จ์œผ๋กœ์จ kubectl cli ๋„๊ตฌ๊ฐ€ Amazon EKS ํด๋Ÿฌ์Šคํ„ฐ์˜ API ์„œ๋ฒ„์™€ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•œ๋‹ค.
  • Kubernetes ์„œ๋น„์Šค ์–ด์นด์šดํŠธ๋ฅผ ํ†ตํ•œ AWS API ์•ก์„ธ์Šค: Kubernetes ์›Œํฌ๋กœ๋“œ๊ฐ€ AWS API๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋ ค๋ฉด ์„œ๋น„์Šค ์–ด์นด์šดํŠธ์™€ IAM ์—ญํ• ์„ ์„ค์ •ํ•˜์—ฌ ํŒŒ๋“œ๊ฐ€ AWS ๋ฆฌ์†Œ์Šค์— ์•ˆ์ „ํ•˜๊ฒŒ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋กค ํ™•์ธ

kubectl describe clusterrolebindings.rbac.authorization.k8s.io cluster-admin
Name: cluster-admin
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
Role:
Kind: ClusterRole
Name: cluster-admin
Subjects:
Kind Name Namespace
---- ---- ---------
Group system:masters
kubectl describe clusterrole cluster-admin
Name: cluster-admin
Labels: kubernetes.io/bootstrapping=rbac-defaults
Annotations: rbac.authorization.kubernetes.io/autoupdate: true
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
*.* [] [] [*]
[*] [] [*]

 

cluster-admin์€ Kubernetes ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ๋ชจ๋“  ๋ฆฌ์†Œ์Šค๋ฅผ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์ตœ๊ณ  ๊ถŒํ•œ์„ ๊ฐ€์ง„ ์—ญํ• ์ด๋‹ค.

system:masters ๊ทธ๋ฃน์— cluster-admin ์—ญํ• ์„ ๋ถ€์—ฌํ•˜๋Š”๋ฐ system:masters ๊ทธ๋ฃน์— ์†ํ•œ ์‚ฌ์šฉ์ž๋Š” ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋ชจ๋“  ๋ฆฌ์†Œ์Šค๋ฅผ ๊ด€๋ฆฌ ๊ฐ€๋Šฅํ•˜๋‹ค.

cluster-admin ์—ญํ• ์„ ๊ฐ€์ง„ ์‚ฌ์šฉ์ž๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด ๋ชจ๋“  ๋ฆฌ์†Œ์Šค์™€ API ์—”๋“œํฌ์ธํŠธ์— ๋Œ€ํ•ด ์ œํ•œ ์—†์ด ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

aws auth config map

aws iam create-user --user-name testuser
aws iam create-access-key --user-name testuser
aws iam attach-user-policy --policy-arn arn:aws:iam::aws:policy/AdministratorAccess --user-name testuser

 

์‹ค์Šต์„ ์œ„ํ•œ ํ…Œ์ŠคํŠธ ์œ ์ €๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์–ด๋“œ๋ฏผ ์•ก์„ธ์Šค ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•œ๋‹ค.

kubectl get node -v6
I0316 05:40:16.553046 2768 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s in 0 milliseconds
E0316 05:40:16.553210 2768 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
I0316 05:40:16.554763 2768 cached_discovery.go:120] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.555075 2768 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s in 0 milliseconds
E0316 05:40:16.555135 2768 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
I0316 05:40:16.558345 2768 cached_discovery.go:120] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.559675 2768 shortcut.go:103] Error loading discovery information: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.560892 2768 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s in 0 milliseconds
E0316 05:40:16.560975 2768 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
I0316 05:40:16.562193 2768 cached_discovery.go:120] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.562483 2768 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s in 0 milliseconds
E0316 05:40:16.562535 2768 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
I0316 05:40:16.563622 2768 cached_discovery.go:120] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.563803 2768 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s in 0 milliseconds
E0316 05:40:16.563844 2768 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
I0316 05:40:16.564946 2768 cached_discovery.go:120] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I0316 05:40:16.565005 2768 helpers.go:264] Connection error: Get http://localhost:8080/api?timeout=32s: dial tcp 127.0.0.1:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

AWS ์ž๊ฒฉ ์ฆ๋ช…์€ ๋ฌธ์ œ ์—†์ง€๋งŒ Kubernetes RBAC ๋ฐ ์ธ์ฆ ์„ค์ •์„ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค.

 

iam ๋งคํ•‘

 

# 1๋ฒˆ ๋ฐฐ์Šค์ฒœ ์„œ๋ฒ„
eksctl get iamidentitymapping --cluster $CLUSTER_NAME
eksctl create iamidentitymapping --cluster $CLUSTER_NAME --username testuser --group system:masters --arn arn:aws:iam::$ACCOUNT_ID:user/testuser
eksctl get iamidentitymapping --cluster $CLUSTER_NAME
ARN USERNAME GROUPS ACCOUNT
...
arn:aws:iam::390844768149:user/testuser testuser system:masters

 

# 2๋ฒˆ ๋ฐฐ์Šค์ฒœ ์„œ๋ฒ„
aws eks update-kubeconfig --name $CLUSTER_NAME --user-alias testuser
Updated context testuser in /root/.kube/config
cat ~/.kube/config
...
- name: testuser
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- --region
- ap-northeast-2
- eks
- get-token
- --cluster-name
- myeks
- --output
- json
command: aws
kubectl ns default
Context "testuser" modified.
Active namespace is "default".
(testuser:default) [root@operator-host-2 ~]# kubectl get node -v6
I0316 06:04:22.045436 3159 loader.go:395] Config loaded from file: /root/.kube/config
I0316 06:04:23.069865 3159 round_trippers.go:553] GET https://~~~.yl4.ap-northeast-2.eks.amazonaws.com/api/v1/nodes?limit=500 200 OK in 1015 milliseconds
NAME STATUS ROLES AGE VERSION
ip-192-168-1-31.ap-northeast-2.compute.internal Ready <none> 5h53m v1.31.5-eks-5d632ec
ip-192-168-2-143.ap-northeast-2.compute.internal Ready <none> 5h53m v1.31.5-eks-5d632ec
ip-192-168-3-145.ap-northeast-2.compute.internal Ready <none> 5h53m v1.31.5-eks-5d632ec

 

testuser์˜ ๊ทธ๋ฃน ๊ถŒํ•œ์„ ๋ณ€๊ฒฝํ•˜๋ฉด?

kubectl edit cm -n kube-system aws-auth
...
- groups:
- system:authenticated
userarn: arn:aws:iam::390844768149:user/testuser
username: testuser
eksctl get iamidentitymapping --cluster $CLUSTER_NAME
arn:aws:iam::390844768149:user/testuser testuser system:authenticated
kubectl get node -v6
I0316 06:07:56.767482 3307 loader.go:395] Config loaded from file: /root/.kube/config
I0316 06:07:57.923161 3307 round_trippers.go:553] GET https://~~.yl4.ap-northeast-2.eks.amazonaws.com/api/v1/nodes?limit=500 403 Forbidden in 1147 milliseconds
I0316 06:07:57.923812 3307 helpers.go:246] server response object: [{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "nodes is forbidden: User \"testuser\" cannot list resource \"nodes\" in API group \"\" at the cluster scope",
"reason": "Forbidden",
"details": {
"kind": "nodes"
},
"code": 403
}]
Error from server (Forbidden): nodes is forbidden: User "testuser" cannot list resource "nodes" in API group "" at the cluster scope

 

testuser๊ฐ€ system:authenticated ๊ทธ๋ฃน์— ์†ํ•ด ์žˆ๊ณ , nodes ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ RBAC ๊ถŒํ•œ์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ์ •์ƒ์ ์œผ๋กœ ์ ‘๊ทผ์ด ์ฐจ๋‹จ๋œ๋‹ค.

 

testuser IAM ๋งคํ•‘ ์‚ญ์ œ

eksctl delete iamidentitymapping --cluster $CLUSTER_NAME --arn arn:aws:iam::$ACCOUNT_ID:user/testuser
2025-03-16 06:09:54 [โ„น] removing identity "arn:aws:iam::390844768149:user/testuser" from auth ConfigMap (username = "testuser", groups = ["system:authenticated"])
eksctl get iamidentitymapping --cluster $CLUSTER_NAME
kubectl get cm -n kube-system aws-auth -o yaml
# 2๋ฒˆ ๋ฐฐ์Šค์ฒœ ์„œ๋ฒ„
kubectl get node -v6
I0316 06:10:54.403658 3413 loader.go:395] Config loaded from file: /root/.kube/config
I0316 06:10:56.447285 3413 round_trippers.go:553] GET https://~~~.yl4.ap-northeast-2.eks.amazonaws.com/api/v1/nodes?limit=500 401 Unauthorized in 2035 milliseconds
I0316 06:10:56.447752 3413 helpers.go:246] server response object: [{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Unauthorized",
"reason": "Unauthorized",
"code": 401
}]
error: You must be logged in to the server (Unauthorized)

 

๊ธฐ์กด์— testuser๋Š” aws-auth ConfigMap์— ๋“ฑ๋ก๋˜์–ด ์žˆ์—ˆ๋Š”๋ฐ IAM ๋งคํ•‘์„ ์ œ๊ฑฐํ•œ ํ›„, kubectl get nodes๋ฅผ ์‹คํ–‰ํ•˜๋ฉด 401 Unauthorized ์˜ค๋ฅ˜ ๋ฐœ์ƒํ•˜๊ฒŒ ๋œ๋‹ค.
์ด๋Š” testuser๊ฐ€ ์ด์ œ Kubernetes API ์„œ๋ฒ„์— ์ธ์ฆ๋˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.