TLS 인증서와 개인 키 생성하기

TLS 인증서와 개인 키 생성하기 (Create TLS Certificate and Private Key)

데모 목적으로 만들어낸 self-signed CA(인증 기관)가 서명한 TLS 인증서를 사용해볼게요. mkcert를 사용하면 쉽게 만들 수 있어요.

출처: Create TLS Certificate and Private Key

본문

데모 목적으로 만들어낸 self-signed CA(인증 기관)가 서명한 TLS 인증서를 사용해볼게요. 손쉬운 방법 중 하나는 mkcert를 사용하는 거예요. 이 예제에서 사용하는 호스트 이름인 bookinfo.cilium.rocks와 hipstershop.cilium.rocks를 검증할 인증서가 필요해요.

$ mkcert bookinfo.cilium.rocks hipstershop.cilium.rocks
Note: the local CA is not installed in the system trust store.
Run "mkcert -install" for certificates to be trusted automatically ⚠️

Created a new certificate valid for the following names 📜
 - "bookinfo.cilium.rocks"
 - "hipstershop.cilium.rocks"

The certificate is at "./bookinfo.cilium.rocks+1.pem" and the key at "./bookinfo.cilium.rocks+1-key.pem" ✅

It will expire on 29 November 2026 🗓

이 데모 키와 인증서로 Kubernetes 시크릿을 만들어볼게요:

$ kubectl create secret tls demo-cert --key=bookinfo.cilium.rocks+1-key.pem --cert=bookinfo.cilium.rocks+1.pem

(대안) cert-manager를 설치해볼게요:

$ helm repo add jetstack https://charts.jetstack.io
$ helm install cert-manager jetstack/cert-manager --version v1.16.2 \
    --namespace cert-manager \
    --set crds.enabled=true \
    --create-namespace \
    --set config.apiVersion="controller.config.cert-manager.io/v1alpha1" \
    --set config.kind="ControllerConfiguration" \
    --set config.enableGatewayAPI=true

이제 CA Issuer를 만들어볼게요:

$ kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/1.20.2/examples/kubernetes/servicemesh/ca-issuer.yaml

더 알아보기 (Learn more)