Certificate Signing Request
K8s์ CertificateSigningRequest ๋ฆฌ์์ค๋ .csr
ํ์ผ๊ณผ ๋์ผํ ๋
์์ด๋ค!
CertificateSigningRequest ๋ฆฌ์์ค๋ฅผ ์์ฑํ ๋ spec.request
ํญ๋ชฉ์ .csr
ํ์ผ์ ๋ด์ฉ์ base64๋ก ์ธ์ฝ๋ฉํ ๊ฐ์ด ํ์ํ๋ค.
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
name: akshay
spec:
request: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS # base64 ์ธ์ฝ๋ฉ๋ .csr ํ์ผ
์์ ๋ด์ฉ๋๋ก CSR ๋ฆฌ์์ค๋ฅผ ๋ง๋ค๊ณ , Approve๋ฅผ ํด์ฃผ๋ฉด K8s์ certificate๊ฐ ๋ง๋ค์ด์ง๋ค! ํด๋น ๋ด์ฉ์ k get csr -o yaml
์ ํตํด ํ์ธํ ์ ์๋ค.
$ k get csr akshay -o yaml
apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest
metadata:
spec:
groups:
- system:masters
- system:authenticated
request: xxxx
signerName: kubernetes.io/kube-apiserver-client
usages:
- client auth
status:
certificate: this-is-your-cert! # ์๊ธฐ!
๋ง์ฝ K8s์ Certificate API๋ฅผ ์ฌ์ฉํ์ง ์์๋ค๋ฉด, openssl
๋ก .crt
ํ์ผ๊น์ง ๋ง๋ค์ด์ผ ํ์ ๊ฒ์ด๋ค. ๊ทธ๋ฐ ๊ท์ฐฎ์์ CSR ๋ฆฌ์์ค๊ฐ ํด๊ฒฐํด์ค ๊ฒ!
User ๋ฆฌ์์ค์ ์ด๋ฆ์ ์ด๋์ ์ ์?
RBAC์์ RoleBinding ๋ฆฌ์์ค๋ฅผ ์ ์ํ๋ค๋ณด๋ฉด, ์ด๋ฐ User ๋ฆฌ์์ค๋ฅผ ๋ณด๊ฒ ๋๋ค.
apiVersion: rbac.authorization.k8s.io/v1
# This role binding allows "jane" to read pods in the "default" namespace.
# You need to already have a Role named "pod-reader" in that namespace.
kind: RoleBinding
metadata:
name: read-pods
namespace: default
subjects:
# You can specify more than one "subject"
- kind: User
name: jane # "name" is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
# "roleRef" specifies the binding to a Role / ClusterRole
kind: Role #this must be Role or ClusterRole
name: pod-reader # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
๊ทธ๋ฐ๋ฐ K8s๋ User ๋ฆฌ์์ค๋ฅผ ๋ฐ๋ก ์ ์ํ์ง ์๋๋ฐ, User ์ด๋ฆ์ ์ด๋์ ์ ์ ์๋ ๊ฑธ๊น? ์ด๊ฒ๋ CSR ๋ฆฌ์์ค๋ฅผ ํตํด ์ ์ ์๋ค!!
k describe csr
์ ํด๋ณด๋ฉด ์๋์ ๊ฐ์ด CN
(Common Name)์ ๋ํ ํญ๋ชฉ์ด ์๋๋ฐ, ์ด๊ฒ User ๋ฆฌ์์ค์ ์ด๋ฆ์ด๋ค!
$ k describe csr akshay
Name: akshay
Requesting User: kubernetes-admin
Signer: kubernetes.io/kube-apiserver-client
Subject:
Common Name: akshay # ์๊ธฐ์์ ํ์ธ!
์ด CN
์ .csr
ํ์ผ์ ๋ง๋ค๋ ์ ์ํ๋ ๊ฒ์ด๋ค. ์ฐธ๊ณ ๋ก CN
๊ณผ CSR ๋ฆฌ์์ค์ ์ด๋ฆ์ด ๋ค๋ฅผ ์๋ ์๋ค!