Istio Gateway에 인증서 적용하는 방법

1–2분

Istio Gateway에 인증서 적용하는 방법

이 블로그 포스트에서는 Kubernetes 환경에서 Istio Gateway에 SSL/TLS 인증서를 생성하고 적용하는 과정을 설명합니다. 이를 통해 Istio 인그레스 게이트웨이를 통해 노출되는 서비스의 안전한 통신을 보장할 수 있습니다.

사전 준비

  • Istio가 설치된 Kubernetes 클러스터
  • 클러스터와 상호 작용할 수 있도록 구성된 kubectl 명령줄 도구
  • 로컬 컴퓨터에 설치된 OpenSSL

1단계: SSL/TLS 인증서 생성

우리는 *.example.com 도메인에 대한 와일드카드 인증서를 생성할 것입니다. 도메인 이름은 필요에 따라 조정하십시오.

1.1 자체 서명된 인증서 생성

먼저, 자체 서명된 인증서와 키를 생성합니다:

export DOMAIN_NAME="*.example.com"
openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:2048 -subj "/O=$DOMAIN_NAME Inc./CN=$DOMAIN_NAME" -keyout main.key -out main.crt

1.2 인증서 서명 요청(CSR) 생성

다음으로, CSR을 생성합니다:

openssl req -out main.csr -newkey rsa:2048 -nodes -key main.key -subj "/CN=$DOMAIN_NAME/O=hello world from $DOMAIN_NAME"

1.3 CSR 서명

CSR을 자체 서명된 인증서로 서명합니다:

openssl x509 -req -days 3650 -CA main.crt -CAkey main.key -set_serial 0 -in main.csr -out main.crt

2단계: 주체 대체 이름(SAN) 추가

우리는 *.example.com 도메인에 대한 주체 대체 이름(SAN)이 포함된 인증서를 생성할 것입니다.

openssl req -addext "subjectAltName=DNS:*.example.com" -subj "/C=KR/ST=Seoul/L=Seoul/O=YourCompany/OU=Support/CN=*.example.com/emailAddress=you@example.com" -newkey rsa:4096 -nodes -sha256 -keyout domain.key -x509 -days 3650 -out domain.crt

3단계: Kubernetes 비밀 생성

이제 인증서와 키를 저장할 Kubernetes 비밀을 생성합니다. 이 비밀은 Istio Gateway에서 사용됩니다.

kubectl create secret tls example-certs -n istio-system --key domain.key --cert domain.crt

4단계: Istio Gateway 구성

생성된 인증서를 사용하도록 Istio Gateway를 정의합니다.

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: example-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*.example.com'
    port:
      name: http
      number: 80
      protocol: HTTP
  - hosts:
    - '*.example.com'
    port:
      name: https
      number: 443
      protocol: HTTPS
    tls:
      credentialName: example-certs
      mode: SIMPLE

이 Gateway 구성을 적용합니다:

kubectl apply -f gateway.yaml

결론

이 가이드에서는 OpenSSL을 사용하여 SSL/TLS 인증서를 생성하고 이를 Kubernetes 환경의 Istio Gateway에 적용하는 방법을 설명했습니다. 이러한 단계를 따라 Istio를 통해 노출되는 서비스의 안전한 통신을 보장할 수 있습니다. 궁금한 사항이나 문제가 발생하면 아래에 댓글을 남겨주세요.