2021. 5. 9. 11:52ใ๐ฏ OpenSource/K8S
7.5 ์ํฌ๋ฆฟ์ผ๋ก ๋ฏผ๊ฐํ ๋ฐ์ดํฐ ์ ๋ฌํ๊ธฐ
๋ณด์์ด ์ ์ง๋์ด์ผ ํ๋ ๋ฐ์ดํฐ(์๊ฒฉ์ฆ๋ช , ๊ฐ์ธ ์ํธํํค ๋ฑ)์ Secret์ด๋ผ๋ ์ค๋ธ์ ํธ๋ฅผ ํตํด ๊ด๋ฆฌํ๋ค.
7.5.1 Secret ์๊ฐ
- ConfigMap๊ณผ ์ ์ฌํ key-value ์์ผ๋ก ConfigMap๊ณผ ๋์ผํ ๋ฐฉ์์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅ.
- ๋ค์๊ณผ ๊ฐ์ ์ํฉ์์ ์ฌ์ฉํ๋ค.
- ํ๊ฒฝ๋ณ์๋ก Secret ํญ๋ชฉ์ ์ปจํ ์ด๋์ ์ ๋ฌ
- Secret ํญ๋ชฉ์ ๋ณผ๋ฅจ ํ์ผ๋ก ๋ ธ์ถ
- Secret์ ์ฌ์ฉํด์ผ ํ๋ ํ๋๊ฐ ์๋ ๋ ธ๋์๋ง ๊ฐ๋ณ์ ์ผ๋ก ์ํฌ๋ฆฟ์ ๋ฐฐํฌํ ์ ์๋ค.
- ๋ ธ๋ ์์ฒด์ ์ผ๋ก ์ํฌ๋ฆฟ์ ๋ฉ๋ชจ๋ฆฌ์๋ง ์ ์ฅํ๊ณ , ๋ฌผ๋ฆฌ ์ ์ฅ์์๋ ์ ์ฅํ์ง ์๋๋ค. (wiping ๋ฐฉ์ง)
ConfigMap๊ณผ Secret์ ์ ์ฌ์ ์์ ์ฌ์ฉํ๋ ๊ฒ์ด ํ์ํ๋ค.
- ๋ฏผ๊ฐํ์ง ์์ ์ผ๋ฐ ์ค์ ๋ฐ์ดํฐ : ์ปจํผ๊ทธ๋งต
- ๋ฏผ๊ฐํ ๋ฐ์ดํฐ : ์ํฌ๋ฆฟ
- ๋ง์ฝ ์ค์ ํ์ผ์ด ๋ฏผ๊ฐํ ๋ฐ์ดํฐ + ์ผ๋ฐ ๋ฐ์ดํฐ : ํด๋น ํ์ผ์ ์ํฌ๋ฆฟ ์์ ์ ์ฅ
7.5.2 ๊ธฐ๋ณธ ํ ํฐ ์๊ฐ
๋ชจ๋ ํ๋์๋ secret ๋ณผ๋ฅจ์ด /var/run/secrets/kubernetes.io/serviceaccout ๋๋ ํฐ๋ฆฌ์ ๋ง์ดํธ๋์ด ์๋ค.
root@master001:~/Chapter07# kubectl describe pod fortune-configmap-volume | grep secret
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xgl85 (ro)
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xgl85 (ro)
์กฐํ๋ ์ํฌ๋ฆฟ default-token-xgl85๋ฅผ ์ดํด๋ณธ๋ค. ์ด๋ฌํ default-token ์ํฌ๋ฆฟ์ ๋ชจ๋ ์ปจํ ์ด๋์ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ง์ดํธ๋๋ ๊ฒ์ด๋ค.
root@master001:~/Chapter07# kubectl get secrets default-token-xgl85
NAME TYPE DATA AGE
default-token-xgl85 kubernetes.io/service-account-token 3 69d
root@master001:~/Chapter07# kubectl describe secrets default-token-xgl85
Name: default-token-xgl85
Namespace: default
Labels: <none>
Annotations: kubernetes.io/service-account.name: default
kubernetes.io/service-account.uid: 10eba40f-2402-45c8-9355-0bbaa753a4ee
Type: kubernetes.io/service-account-token
Data
====
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IjdRWUpZYjlncElyclZfY3FsSnZiMDZVTG1zdGNRTHg1WkZQZE5UN3N3ZEUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRlZmF1bHQtdG9rZW4teGdsODUiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVmYXVsdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjEwZWJhNDBmLTI0MDItNDVjOC05MzU1LTBiYmFhNzUzYTRlZSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmRlZmF1bHQifQ.Ew2zNJJHWq7sfA7h5An2Ke0wASQ_ASCNHiIB4AR6KHwSRsvm9JQx0IoEZqeinvcnSbJ5MEgwSxsuj7kLRoPG6wsOp3CjG2MfM7946MsSM78PmJY1XkRsEqJLIYQ-umV4NNNyFQ0IEcgnqov28bY8KXfRel6iXNgzMMmMpOjomliSDjdd6t7BD4sq2p3TJa_aAQmOAGEQY0NKrt9kU64O2gBgbq-dS5W31c53me0FUEGAzHMIQJUolfKyNwD15ze9S-_98NMDh-GDqpvljBBX86arW1tAsr959PuYcrVhPewXbVSKQaeVkcE4n3C03qJz9dedCzF8x28fMgCTSDEKGA
ca.crt: 1066 bytes
namespace: 7 bytes
์ํฌ๋ฆฟ์ด ๊ฐ์ง๋ ์ธ๊ฐ์ง ํญ๋ชฉ(ca.crt, namespace, token)์ pod ์์์ ์ฟ ๋ฒ๋คํฐ์ค API ์๋ฒ์ ํต์ ํ ๋ ํ์ํ ๋ฐ์ดํฐ์ด๋ค.
์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ์ฟ ๋ฒ๋คํฐ์ค๋ฅผ ๋ถ๋ฆฌํ๋๊ฒ์ด ์ด์์ ์ด์ง๋ง, ์ง์ ํต์ ์ด ๊ผญ ํ์ํ ๊ฒฝ์ฐ๋ secret ๋ณผ๋ฅจ์ ์ด์ฉํ๋ค.
์ปจํ ์ด๋์ ํด๋น ๊ฒฝ๋ก์ default secret ๋ณผ๋ฅจ์ ๋ง์ดํธ ๋จ์ผ๋ก์จ ์ ๊ทผํ๋ ํ์ผ์ด ์๋๊ฑธ ๋ณผ ์ ์๋ค.
root@master001:~/Chapter07# kubectl exec fortune-configmap-volume ls /var/run/secrets/kubernetes.io/serviceaccount
ca.crt
namespace
token
7.5.3 ์ํฌ๋ฆฟ ์์ฑ
์ํฌ๋ฆฟ์ ์์ฑํ์ฌ fortune-serving Nginx ์ปจํ ์ด๋๊ฐ HTTPS ํธ๋ํฝ์ ์ ๊ณตํ ์ ์๋๋ก ๊ฐ์ ํ๋ค.
1) ์ธ์ฆ์์ ๊ฐ์ธ ํค ํ์ผ ์์ฑ
root@master001:~/Chapter07# openssl genrsa -out https.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
....................+++++
...........................................................................+++++
e is 65537 (0x010001)
root@master001:~/Chapter07# openssl req -new -x509 -key https.key -out https.cert -days 3650 -subj /CN=www.kubia-example.com
2) ๋๋ฏธ ํ์ผ ์์ฑ
root@master001:~/Chapter07# echo bar > foo
3) ์ํฌ๋ฆฟ ์์ฑ
root@master001:~/Chapter07# kubectl create secret generic fortune-https2 --from-file=https.key --from-file=https.cert --from-file=foo
secret/fortune-https2 created
root@master001:~/Chapter07# kubectl describe secrets fortune-https2
Name: fortune-https2
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
foo: 4 bytes
https.cert: 1147 bytes
https.key: 1675 bytes
์ํฌ๋ฆฟ์ ๋ฐ์ดํฐ๋ Base64 ํํ๋ก ์ธ์ฝ๋ฉ๋์ด ์ ์ฅ๋๋ฉฐ, ์ปจํ ์ด๋์ ์ ๋ฌ๋ ๋๋ ๋์ฝ๋ฉ๋์ด ์ ๋ฌ๋๋ค.
7.5.4 ConfigMap๊ณผ Secret ๋น๊ต
์ํฌ๋ฆฟ ํญ๋ชฉ์ ๋ด์ฉ์ Base64๋ก ์ธ์ฝ๋ฉ๋์ด ์์ผ๋ฉฐ, ์ปจํผํฌ๋งต์ ๋ด์ฉ์ ์ผ๋ฐ ํ ์คํธ์ด๋ค.
Base64 ์ธ์ฝ๋ฉ์ ์ฌ์ฉํด ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ๋ฅผ ์ผ๋ฐ ํ ์คํธ ํ์์ธ yaml์ด๋ json์ ๋ฃ์ ์ ์๋ค.
root@master001:~/Chapter07# kubectl describe secrets fortune-https2
Name: fortune-https2
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
foo: 4 bytes
https.cert: 1147 bytes
https.key: 1675 bytes
root@master001:~/Chapter07# kubectl get secret fortune-https2 -o yaml
apiVersion: v1
data:
foo: YmFyCg==
https.cert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lVTnJHdHdhalo3Z21QaXBSVzAvTFBYa1ZENGc0d0RRWUpLb1pJaHZjTkFRRUwKQlFBd0lERWVNQndHQTFVRUF3d1ZkM2QzTG10MVltbGhMV1Y0WVcxd2JHVXVZMjl0TUI0WERUSXhNRFV3T1RBMgpNakl6T0ZvWERUTXhNRFV3TnpBMk1qSXpPRm93SURFZU1Cd0dBMVVFQXd3VmQzZDNMbXQxWW1saExXVjRZVzF3CmJHVXVZMjl0TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF0Q0dpM1JmN21KL00KUjJQUWFkblBWRnJ3SHQxTTZRWVdUTGV1akxLTWM0dHN0RUdGY29HMkNISUczRUROanY0V1RBSjhpVWtzaEFQNgpWT05qUlFxZmh3bzQvS21CTFB0NzU1VHd6Z3daQmtUOFdpai94dmRBSmM5allaaWZOM3R5TUEvb3FJeEM4dXRoCkk4STNuWmhVSUdiN0k5VjdYVG5zV2dEbVdUWlVzWmJOOEtlY09sRlBBdUl1VVNTN3h6MFVlZ3ErTnR5ZGF2YTIKZ2lZbEVKNXRMSWVMZDV2TEFtUGh1dDRHYUJ3MjZBN2tUYVF4OEZNNi9oM2FIL29tTWJqYks3TFRI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UU2ZiNDhxWGRtdXUxZjJMSjdzejVRbFV5bHRLMzdoUHFKV2tERmhOUgpFYjVsZlduR0lRellOZ1pwM0czckVFWlhRZTFhc1ZhTCtjRWdENG11aGdFeHFaQTVqOWlUdkFHVUxKdTlOQVhUClExcHI1Wm4yODUwc0lxTzZKZ0FldlkrUGJnZ09ucnh5c1JsbUx0TUNnWUFWWlZ0MFh0cXlJYkpiaW5iYS9PMVoKTXl6WkNuMkhKMWNHVnhLVXRZMHpDQk95eTF5RkwvMWsrUWJTa2pUcGVBYUNsSTU5aXQ1bTJ5OEFjTjJNUHZ2aAorRnBKTEhOMXdSZkhFems2bmhtSVJPR0ZVeVZENmRuSlUrNUhVYkdCU0srM1c3cXloa1ZHUVRaT1UwWWVTMCtQCjlGOXBtUHQ5ekd4dktCVnpZbHN3a1FLQmdFTFN1d25jeWZuVEVjV3luT2d6OFhwRUFiYWNXMFhOeXVmQW5wMXUKckh4OWwvb3g0aHk5RUhTWlkzQmRpZmx1Um1NdzZ5SXBYUmtSWVFhSDg4dmZ3QWJydnEwSUNjeFlGN0ljbzNHWgpRd2lra3czcngvRkRGWndnVG9yYXludWg2OWVLaHkvaXdMa0M2UnY4Y3l2T0VJbXJEc2NBeWc3c1kvTmlPMktjCks5R0xBb0dBU3JyVjhwdlNjRkUwRnpmMHM4NDlicXRkaERyY0xPMnJRYlFlWWFIa1RhbHpyQ3RJYTE1cTE2a20KYlR2NUEwVUZWdzEwY1NZSFJuQ2wwQ0p5YUlISFgzcnFSMUc4UGFOc0VaOTFpWDZ0SnN1akE0c2NubklrT0I3ZwpWZzlEbDd0MWJLU0c5Mms1VHpLZFM1YVBoc0R5aGUwYXZiTmFqMmJsYXZNOFNtdEN4VXc9Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
kind: Secret
root@master001:~/Chapter07# kubectl get configmap fortune-config -o yaml
apiVersion: v1
data:
my-nginx-config.conf: |
server {
listen 80;
server_name www.kubia-example.com;
gzip off;
gzip_types text/plain application/xml;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
sleep-interval: |
25
StringData ํ๋ ์๊ฐ
์ํฌ๋ฆฟ ๊ฐ์ string data ํ๋๋ก ์ค์ ํ ์๋ ์๋ค.
StringData ํ๋๋ ์ฐ๊ธฐ ์ ์ฉ์ผ๋ก, ๊ฐ์ ์ค์ ํ ๋๋ง ์ฌ์ฉํ ์ ์๋ค.
7.5.5 ํ๋์์ ์ํฌ๋ฆฟ ์ฌ์ฉํ๊ธฐ
์ธ์ฆ์์ ํค ํ์ผ์ ๋ชจ๋ ํฌํจํ๋ fortune-https ์ํฌ๋ฆฟ์ Nginx์์ ์ฌ์ฉํ ์ ์๋๋ก ์ค์ ํ๋ค.
my-nginx-config.conf: |
server {
listen 80;
listen 443;
server_name www.kubia-example.com;
# ๊ฐ ๊ฒฝ๋ก๋ /etc/nginx ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ง์ ํ์ฌ ์น์๋ฒ๊ฐ ์ธ์ฆ์ ๋ฐ ํคํ์ผ์ /etc/nginx/certs ์์ ์ฝ๋๋ก ํ๋ค.
ssl_certificate certs/https.cert;
ssl_certificate_key certs/https.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
Secret ๋ณผ๋ฅจ์ /etc/nginx/cers ๊ฒฝ๋ก์ ๋ง์ดํธํ๋ค.
apiVersion: v1
kind: Pod
metadata:
name: fortune-https
spec:
containers:
...
- image: nginx:alpine
name: web-server
volumeMounts:
- name: config
mountPath: /etc/nginx/conf.d
readOnly: true
# ์ธ์ฆ์ ๋ฐ ํค ํ์ผ์ ์ฝ๋ ๊ฒฝ๋ก์ ์ํฌ๋ฆฟ ๋ณผ๋ฅจ์ ๋ง์ดํธ
- name: certs
mountPath: /etc/nginx/certs/
readOnly: true
...
volumes:
- name: config
configMap:
name: fortune-config
items:
- key: my-nginx-config.conf
path: https.conf
# fortune-https ์ํฌ๋ฆฟ์ ์ฐธ์กฐํ๋๋ก ์ํฌ๋ฆฟ ๋ณผ๋ฅจ์ ์ ์
- name: certs
secret:
secretName: fortune-https
์ ์ํฌ๋ฆฟ ๋ณผ๋ฅจ์ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ฅ๋๋๊ฐ?
secret ๋ณผ๋ฅจ์ ์ธ๋ฉ๋ชจ๋ฆฌ ํ์ผ์์คํ tempfs๋ฅผ ์ฌ์ฉํด ์ ์ฅ๋๋ค.
tmpfs๋ฅผ ์ฌ์ฉํ๋ ์ด์ ๋ ๋ฏผ๊ฐํ ๋ฐ์ดํฐ๋ฅผ ๋์คํฌ์ ์ ์ฅํ๊ธฐ ์์ ์ธ๋ถ๋ก์ ๋ ธ์ถ์ ์ต์ํํ๊ธฐ ์ํด์์ด๋ค.
root@master001:~/Chapter07# kubectl exec fortune-https -c web-server -- mount | grep certs
tmpfs on /etc/nginx/certs type tmpfs (ro,relatime)
7.5.6 ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ ธ์ฌ ๋ ์ฌ์ฉํ๋ ์ํฌ๋ฆฟ
์ปจํ ์ด๋ ์ด๋ฏธ์ง๊ฐ ํ๋ผ์ด๋น ๋ ์ง์คํธ๋ฆฌ์ ์์ผ๋ฉด ์ฟ ๋ฒ๋คํฐ์ค๋ ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ ธ์ค๋๋ฐ ํ์ํ ์๊ฒฉ์ฆ๋ช ์ ์์์ผ ํ๋ค.
ํ๋ผ์ด๋น ์ ์ฅ์๋ฅผ ์ฌ์ฉํ๋ pod๋ฅผ ์คํํ๋ ค๋ฉด ๋ ๊ฐ์ง ์์ ์ด ํ์ํ๋ค.
- ๋์ปค ๋ ์ง์คํธ๋ฆฌ ์๊ฒฉ์ฆ๋ช ๊ฐ์ง ์ํฌ๋ฆฟ ์์ฑ
- ํ๋ ๋งค๋ํ์คํธ ์์ imagePullSecrets ํ๋์ ํด๋น ์ํฌ๋ฆฟ ์ฐธ์กฐ
๋์ปค ๋ ์ง์คํธ๋ฆฌ ํ์์ ์ํฌ๋ฆฟ ์์ฑ
root@master001:~/Chapter07# kubectl create secret docker-registry mydockerhubsecret \
> --docker-username=myusername --docker-password=mypassword \
> --docker-email=my.email@provider.com
secret/mydockerhubsecret created
root@master001:~/Chapter07# kubectl describe secrets mydockerhubsecret
Name: mydockerhubsecret
Namespace: default
Labels: <none>
Annotations: <none>
Type: kubernetes.io/dockerconfigjson
pod ์ yaml ํ์ผ์ ํด๋น ์ํฌ๋ฆฟ์ ์ด๋ฆ์ ์ง์ ํ๋ค.
apiVersion: v1
kind: Pod
metadata:
name: private-pod
spec:
# ํ๋ผ์ด๋น ์ด๋ฏธ์ง ๋ ์ง์คํธ๋ฆฌ์์ ์ด๋ฏธ์ง ๊ฐ์ ธ์ค๋๋ก ์ค์
imagePullSecrets:
- name: mydockerhubsecret
containers:
- image: username/private:tag
name: main
์ด๋ก์จ private registry์ ์๋ ์ด๋ฏธ์ง๋ฅผ pull ํด ์ฌ ์ ์๊ฒ ๋๋ค.
'๐ฏ OpenSource > K8S' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[K8S] Service (NodePort / ClusterIP / LoadBalancer) (0) | 2022.11.14 |
---|---|
12. Accessing to Pod metadata from application (2) | 2021.05.09 |
10. ConfigMap (0) | 2021.05.08 |
09. Job์ผ๋ก ์๋ฃ ๊ฐ๋ฅํ ๋จ์ผ task ๊ตฌํํ๊ธฐ (0) | 2021.04.05 |
08. DaemonSet (0) | 2021.04.05 |