KUBENETES Kubernetes Authentication Kubernetes Authentication, Authorization
๋ณด์๊ด๋ฆฌ ๋ณดํต 2๊ฐ์ง๊ฐ ์๋ค. ํด๋ผ์ด์ธํธ ์ ์ ํ๊ฐ ๊ด๋ฆฌํ๋ ์ธ์ฆ๊ด๋ฆฌ ์ ์ ์์ด ํ๊ฐ๋ ํด๋ผ์ด์ธํธ์ ๋ํ ๋ฆฌ์์ค ์ ๊ทผ ๊ถํ์ ๊ด๋ฆฌํ๋ ๊ถํ ๊ด๋ฆฌ ๊ฐ ์๋ค.
์ฟ ๋ฒ๋คํฐ์ค์์ ์ธ์ฆ๋ฐฉ๋ฒ์ผ๋ก
kubeconfig ํ์ผ๋ก ์ธ์ฆ,
ServiceAccount Token ์ ์ด์ฉํ ์ธ์ฆ,
์ปจํ
์ด๋์ ๊ฐ์ง๊ณ ์๋ Token ์ ์ด์ฉํ ์ธ์ฆ,
idP ๋ฅผ ํตํ ์ธ์ฆ์ด ์๋ค.
kubeconfig ํ์ผ๋ก ์ธ์ฆ
kubectl๋ก API๋ฅผ ํธ์ถํ ๋, kubeconfig ํ์ผ๋ก ์ธ์ฆํ๊ณ ํด๋ฌ์คํฐ์ ์ ๊ทผํ ์ ์๋ค.
Copy from kubernetes import client , config
config . load_kube_config ()
v1 = client . CoreV1Api ()
print ( " Listing pods with their IPs: " )
ret = v1 . list_pod_for_all_namespaces ( watch = False ) ServiceAccount ํ ๊ทผ์ ์ด์ฉํ์ฌ ์ธ์ฆ
ํ๋๊ฐ API๋ฅผ ํธ์ถํ ๋ ServiceAccount ํ ํฐ์ ์ด์ฉํ์ฌ ์ธ์ฆํ๋ค.
์ปจํ
์ด๋์ ์์นํ ํ ํฐ์ ์ด์ฉํ์ฌ ์ธ์ฆ
์ฟ ๋ฒ๋คํฐ์ค ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ ๋, ํ๋ ๋ด ์ปจํ
์ด๋์ ์์นํ ํ ํฐ์ ์ด์ฉํ์ฌ ์ธ์ฆํ๋ค.
idP๋ฅผ ํตํ ์ธ์ฆ
์ฟ ๋ฒ๋คํฐ์ค๋ ์ฌ์ฉ์๋ฅผ API๋ก ์ง์ ๊ด๋ฆฌํ์ง ์๊ณ Dex์ ์ฐ๊ณํ์ฌ ๊ธฐ์กด ์์คํ
(LDAP ๋ฑ)์ ํ์ฉํ์ฌ ์ธ์ฆํ ์ ์๋ค. Dex๋ ์๋ํํฐ๋ก ๋ถํฐ OAuth ์ธ์ฆ์ ๊ด๋ฆฌํ๋ ๋๊ตฌ์ด๋ค. Dex๋ OAuth ์๋ํํฐ์์ ์ค๊ฐ ๋งค๊ฐ์ฒด ์ญํ ์ ํด์ฃผ๊ธฐ ๋๋ฌธ์ OAuth์ ์ธ์ฆ ํ ํฐ ๋ฐ๊ธ, ์ ์ฅ ๋ฐ ๊ด๋ฆฌ๋ฅผ ์ข๋ ์ฝ๊ฒ ํ ์ ์๋ค.
์ฟ ๋ฒ๋คํฐ์ค๋ RBAC์ ์ฌ์ฉํ์ฌ ๋ฆฌ์์ค ๊ถํ์ ๊ด๋ฆฌํ๋ค.
์ด์นด์ดํธ๋ ์ ์ ์ด์นด์ดํธ์ ์์คํ
์ด์นด์ดํธ๋ก ๊ตฌ๋ถ๋๋๋ฐ, ์ ์ ์ด์นด์ดํธ๋ User์ User๋ฅผ ๋ฌถ์ Group์ผ๋ก ์ ์ํ๊ณ , ์์คํ
์ด์นด์ดํธ๋ ServiceAccount ๋ก ์ ์ํ๋ค. ์ด์นด์ดํธ์ ๋ฆฌ์์ค ๊ถํ(์, Pod - create/list/delete)์ Role์ ์ ์ํ๋ฉฐ, Role์ ์ด์นด์ดํธ์ ๋ถ์ฌํ ๋ RoleBinding์ ์ค์ ํ๋ค.
ClusterRole๊ณผ Role
Role์ ์ ์ฉ ๋ฒ์์ ๋ฐ๋ผ ClusterRole๊ณผ Role๋ก ๊ตฌ๋ถํ๋ค. ClusterRole์ ํด๋ฌ์คํฐ ์ ์ฒด ๋ฆฌ์์ค ๊ถํ์ ์ ์ ํ๊ณ , Role์ ํน์ ๋ค์์คํ์ด์ค ๋ด์ ๋ฆฌ์์ค ๊ถํ์ ์ ์ ํ๋ค.
์ฟ ๋ฒ๋คํฐ์ค๋ namespace๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ์์ค๋ฅผ ๊ฒฉ๋ฆฌํ๊ณ , ํด๋ฌ์คํฐ ๋ด์์ ์ฌ๋ฌ ์ฌ์ฉ์๋ค ์์์ ๊ตฌ๋ถํด์ ๋๋ ์ธ ์ ์๋ค. ๋์ผํ namespace ๋ด์์ ๋ฆฌ์์ค๋ ๋ ์ด๋ธ์ ์ฌ์ฉํ์ฌ ๊ตฌ๋ถํ๋ค.
https://lcc3108.github.io/articles/2020-12/Istio+Dex-์ธ์ฆarrow-up-right
Istio Usage in Kubeflow, https://www.kubeflow.org/docs/other-guides/istio-in-kubeflow/arrow-up-right
https://speakerdeck.com/chanyilin/authz?slide=15arrow-up-right
https://speakerdeck.com/chanyilin/authz?slide=12arrow-up-right
https://medium.com/kubeflow/enabling-kubeflow-with-enterprise-grade-auth-for-on-premise-deployments-ae7dd13a69e5arrow-up-right
https://waspro.tistory.com/608arrow-up-right
https://bcho.tistory.com/1272arrow-up-right