Cert-Manager๋?
Cert-Manager๋ Kubernetes ํ๊ฒฝ์์ SSL/TLS ์ธ์ฆ์๋ฅผ ์๋์ผ๋ก ๋ฐ๊ธ, ๊ฐฑ์ , ๊ด๋ฆฌํ๋ ์คํ์์ค ๋๊ตฌ์ ๋๋ค. (https://cert-manager.io/docs/)
- ์๋ํ๋ ์ธ์ฆ์ ๊ด๋ฆฌ: ์ธ์ฆ์์ ๋ฐ๊ธ, ๊ฐฑ์ , ์ฌ์ฉ์ ์๋ํํ์ฌ ์๋ ๊ด๋ฆฌ์ ๋ฒ๊ฑฐ๋ก์์ ์ค์ ๋๋ค. (3๊ฐ์๋ง๋ค ๊ฐฑ์ ๋ฉ๋๋ค.)
- ๋ค์ํ ์ธ์ฆ ๊ธฐ๊ด ์ง์: Let's Encrypt, HashiCorp Vault, Venafi ๋ฑ ์ฌ๋ฌ ์ธ์ฆ ๊ธฐ๊ด๊ณผ ํตํฉ๋ฉ๋๋ค.
- Kubernetes ๋ค์ดํฐ๋ธ: Kubernetes์ CustomResourceDefinitions(CRDs)๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์ฆ์ ๊ด๋ฆฌ๋ฅผ ์ฟ ๋ฒ๋คํฐ์ค ๋ฆฌ์์ค๋ก ์ฒ๋ฆฌํฉ๋๋ค.
Cert-Manager ์ค์น (Helm ์ฐจํธ)
์ฟ ๋ฒ๋คํฐ์ค์ Cert-Manager๋ฅผ ์ค์นํ๋ ๋ฐฉ๋ฒ ์ค์์ Helm์ ์ด์ฉํด์ ์ค์นํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. (์ค์น ๋ฒ์ ์ 1.14.4 ์ ๋๋ค.)
- Helm Repo ๋ฑ๋กํ๊ธฐ
$ helm repo add jetstack https://charts.jetstack.io
$ helm repo update
- Helm์ผ๋ก Cert-Manager ์ค์น
$ helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace
- ์ ์์ ์ผ๋ก ์ค์น๋์๋์ง ํ์ธํ๊ธฐ
$ kubectl get po -n cert-manager
NAME READY STATUS RESTARTS AGE
cert-manager-6dc66985d4-msfrf 1/1 Running 0 1d
cert-manager-cainjector-c7d4dbdd9-ds6ll 1/1 Running 0 1d
cert-manager-webhook-847d7676c9-fk5vq 1/1 Running 0 1d
Issuer ๋ฑ๋ก (ACME ๋ฐฉ๋ฒ - https://cert-manager.io/docs/configuration/acme/)
cert-manager์ Issuer๋ ์ธ์ฆ์ ๋ฐ๊ธ์ ๊ด๋ฆฌํ๊ณ ์๋ํํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋ฆฌ์์ค์ ๋๋ค.
Issuer๋ ์ธ์ฆ์๋ฅผ ๋ฐ๊ธํ๊ธฐ ์ํ ์ค์ ์ ์ ์ํ๋ฉฐ, cert-manager๊ฐ Kubernetes ํด๋ฌ์คํฐ ๋ด์์ ์ธ์ฆ์๋ฅผ ์์ฒญํ๊ณ ๊ฐฑ์ ํ๋ ๋ฐ ํ์ํ ์ ๋ณด์ ๊ท์น์ ์ ๊ณตํฉ๋๋ค.
Cert-Manager์์๋ 2๊ฐ์ง Issuer๋ฅผ ์ ๊ณตํฉ๋๋ค.
- ClusterIssuer : ํด๋ฌ์คํฐ ์ ์ญ์ผ๋ก ์ค์ ๋๋ ์ค์
- Issuer : ๋ค์์คํ์ด์ค๋ณ๋ก ์ค์
์๊ณ ์์ ๊ฐ์ธ ํด๋ฌ์คํฐ์์ ๋ค์์คํ์ด์ค๋ณ๋ก ๊ด๋ฆฌํ๋ ๊ฒ์ ๋นํจ์จ์ ์ด๋ผ๊ณ ์๊ฐ์ด ๋ค์ด์ ClusterIssuer๋ก ๋ฑ๋กํ์ต๋๋ค!
- ClusterIssuer ์์ฑ
# clusterissuer.yaml
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod # ์์ฑํ Clusterissuer ์ง์
spec:
acme:
email: # ์ด๋ฉ์ผ ์์ฑ
privateKeySecretRef:
name: letsencrypt-prod # ACME๊ณ์ ์ Private Key๋ฅผ ์ ์ฅํ Secret ์ด๋ฆ ์ง์
server: https://acme-v02.api.letsencrypt.org/directory # ACME์๋ฒ ์ง์ - Let's Encrypt ACME ์๋ฒ๋ฅผ ์ง์
solvers:
- http01:
ingress:
ingressClassName: nginx
- Clusterissuer ๋ฑ๋ก ๋ฐ ํ์ธ
$ kubectl apply -f clusterissuer.yaml
$ kubectl get clusterissuer -A
NAME READY AGE
letsencrypt-prod True 134d
$ kubectl describe clusterissuer letsencrypt-prod
...
Status:
Acme:
Last Private Key Hash: # ๊ฐ์ธ ํค Hash ๊ฐ
Last Registered Email: # ์ค์ ํ ๊ฐ์ธ ์ด๋ฉ์ผ
Uri: https://acme-v02.api.letsencrypt.org/acme/acct/1681070877
Conditions:
Last Transition Time: 2024-07-19T04:50:19Z
Message: The ACME account was registered with the ACME server
Observed Generation: 2
Reason: ACMEAccountRegistered
Status: True
Type: Ready
Events: <none>
Ingress ์ ์ฉ (Harbor Helm Chart)
์๋๋ Harbor Ingress์ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ๊ธฐ์ฌํ์์ต๋๋ค! ์ธ์ฆ์๊ฐ ํ์ํ Ingress์ ๋ค์ ๋ถ๋ถ์ ์ถ๊ฐํ์ฌ ๋ฐฐํฌํฉ๋๋ค.
# harbor-values.yaml
expose:
# Set how to expose the service. Set the type as "ingress", "clusterIP", "nodePort" or "loadBalancer"
# and fill the information in the corresponding section
type: ingress
tls:
# Enable TLS or not.
# Delete the "ssl-redirect" annotations in "expose.ingress.annotations" when TLS is disabled and "expose.type" is "ingress"
# Note: if the "expose.type" is "ingress" and TLS is disabled,
# the port must be included in the command when pulling/pushing images.
# Refer to https://github.com/goharbor/harbor/issues/5291 for details.
enabled: true
# The source of the tls certificate. Set as "auto", "secret"
# or "none" and fill the information in the corresponding section
# 1) auto: generate the tls certificate automatically
# 2) secret: read the tls certificate from the specified secret.
# The tls certificate can be generated manually or by cert manager
# 3) none: configure no tls certificate for the ingress. If the default
# tls certificate is configured in the ingress controller, choose this option
certSource: none
auto:
# The common name used to generate the certificate, it's necessary
# when the type isn't "ingress"
commonName: ""
secret:
secretName: "tls-journalctl-xe-harbor"
ingress:
hosts:
core: harbor.journalctl-xe.com
# set to the type of ingress controller if it has specific requirements.
# leave as `default` for most ingress controllers.
# set to `gce` if using the GCE ingress controller
# set to `ncp` if using the NCP (NSX-T Container Plugin) ingress controller
# set to `alb` if using the ALB ingress controller
# set to `f5-bigip` if using the F5 BIG-IP ingress controller
controller: default
## Allow .Capabilities.KubeVersion.Version to be overridden while creating ingress
kubeVersionOverride: ""
className: "nginx"
annotations:
# note different ingress controllers may require a different ssl-redirect annotation
# for Envoy, use ingress.kubernetes.io/force-ssl-redirect: "true" and remove the nginx lines below
cert-manager.io/cluster-issuer: "letsencrypt-prod"
cert-manager.io/acme-challenge-type: "http01"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
์๋ Harbor Ingress๋ฅผ ํตํด ์ ๋ฆฌํ๋ฉด ์ ์ฉ์ ํ์ํ ๋ถ๋ถ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
$ kubectl get ingress harbor-ingress -n harbor -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/acme-challenge-type: http01 # clusterissuer์ ์ค์ ๋ solvers ์ค ์ ํํ์ฌ ์ฌ์ฉ (http01 ํน์ dns01)
cert-manager.io/cluster-issuer: letsencrypt-prod # ๋ฑ๋ก๋ clusterissuer ๊ธฐ์ฌ
meta.helm.sh/release-name: harbor
meta.helm.sh/release-namespace: harbor
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
...์๋ต...
spec:
ingressClassName: nginx
rules:
- host: harbor.journalctl-xe.com
http:
paths:
- backend:
service:
name: harbor-core
port:
number: 443
path: /api/
pathType: Prefix
...์๋ต...
tls:
- hosts:
- harbor.journalctl-xe.com
secretName: tls-journalctl-xe-harbor
- metadata.annotations : cert-manager.io/acme-challenge-type: http01 , cert-manager.io/cluster-issuer: letsencrypt-prod
- spec.tls : hosts, secretName
์ถ๊ฐ์ ์ผ๋ก spec.tls.secretName์ ๊ธฐ์ฌํ ์ด๋ฆ์ผ๋ก tls secret ํ์ผ์ด ์์ฑ๋ฉ๋๋ค!
$ kubectl get secret -n harbor | grep journalctl-xe
tls-journalctl-xe-harbor kubernetes.io/tls 2 133d
์ ์ฉ ๊ฒฐ๊ณผ
Harbor
harbor.journalctl-xe.com (๊ฐ์ธ Harbor)
gitlab
gitlab.journalctl-xe.com (๊ฐ์ธ Gitlab)
ArgoCD
argocd.journalctl-xe.com
'Kubernetes' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Self Sign ์ธ์ฆ์ ์ ์ฉํ๊ธฐ - ๊ตฌ์ฑ (1) | 2025.03.24 |
---|---|
Self Sign ์ธ์ฆ์ ์ ์ฉํ๊ธฐ - ์ค์น (0) | 2025.03.24 |
VKE - Vultr Kubernetes Engine (0) | 2025.01.12 |
kind(Kubernetes in Docker) (0) | 2025.01.12 |
Kubernetes Workload Resources(Daemonset) (4) | 2023.12.03 |