Photo by Towfiqu barbhuiya on Unsplash

[K8S] Support TLSv1, TLSv1.1 at Nginx Ingress Controller


๐Ÿ–Œ Note: ์ด ํฌ์ŠคํŒ…์€ Kubernetes community ์—์„œ ๊ฐœ๋ฐœํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” โ€œofficialโ€ NGINX ingress controller ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. NGINX ์—์„œ ์ œ๊ณตํ•˜๋Š” ingress controller ์™€๋Š” ์ฐจ์ด๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“Œ TLS/HTTPS in NGINX Ingress Controller

NGINX ingress controller ์˜ ๊ธฐ๋ณธ ์ง€์› TLS ๋ฒ„์ „์€ TLSv1.2 / TLSv1.3 ์ด๋‹ค. ํ•˜์œ„ ๋ฒ„์ „์˜ ์ทจ์•ฝ์  ๋•Œ๋ฌธ์— ๊ธฐ๋ณธ ์„ค์ •์—๋Š” ๋น ์ ธ ์žˆ์ง€๋งŒ, ์˜ค๋ž˜๋œ ๋ฒ„์ „์˜ ๊ธฐ๊ธฐ์—์„œ๋„ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋ ค๋ฉด ์ตœ์†Œํ•œ TLSv1.1 ์˜ ์ง€์›์€ ํ•„์ˆ˜์ ์ด๋‹ค.

๐Ÿ“ ConfigMap

ConfigMap ์„ค์ •์„ ํ†ตํ•ด ๊ฐ„๋‹จํžˆ ingress controller ์˜ NGINX ์„œ๋ฒ„ ์„ค์ •์„ ๋ณ€๊ฒฝํ•ด ์ค„ ์ˆ˜ ์žˆ๋‹ค.

๋จผ์ €, ingress controller pod ๋ฅผ ํ™•์ธํ•˜์ž (namespace: โ€˜ingress-nginxโ€™)

> kubectl get -n ingress-nginx pods
NAME                                        READY   STATUS    RESTARTS   AGE
ingress-nginx-controller-54d8b558d4-798w5   1/1     Running   0          102d

๋‹ค์Œ์œผ๋กœ, ingress controller ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” configmap ์„ ํ™•์ธํ•œ๋‹ค.

> kubectl describe -n ingress-nginx pod/ingress-nginx-controller-54d8b558d4-798w5 | grep configmap
      --configmap=$(POD_NAMESPACE)/ingress-nginx-controller

Configmap ์˜ ์ด๋ฆ„์ด ingress-nginx-controller ์ธ ๊ฒƒ์„ ํ™•์ธํ–ˆ์œผ๋ฏ€๋กœ, ์•„๋ž˜์™€ ๊ฐ™์ด configmap ์ƒ์„ฑ์šฉ yaml ํŒŒ์ผ์„ ์ž‘์„ฑํ•œ๋‹ค.

apiVersion: v1
kind: ConfigMap
metadata:
  name: ingress-nginx-controller
  namespace: ingress-nginx
data:
  allow-snippet-annotations: 'true'
  ssl-protocols: TLSv1 TLSv1.1 TLSv1.2 TLSv1.3
  ssl-ciphers: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA
configmap.yaml

allow-snippet-annotations ๋Š” ๊ธฐ์กด configmap ์˜ ๋‚ด์šฉ์„ ๋ฐ˜์˜ํ•œ ๊ฒƒ์ด๋‹ค. ๊ธฐ์กด configmap ์— ๋‹ค๋ฅธ ๋‚ด์šฉ์ด ์žˆ๋‹ค๋ฉด ์ „๋ถ€ ์ถ”๊ฐ€ํ•ด ์ค€๋‹ค. (kubectl describe -n ingress-ningx configmap/ingress-nginx-controller ๋ช…๋ น์œผ๋กœ ํ™•์ธ)

> kubectl apply -f configmap.yaml

ํด๋Ÿฌ์Šคํ„ฐ์— ์ ์šฉํ•˜๊ณ  ๋‚˜๋ฉด, ์ˆ˜ ์ดˆ ๋‚ด์ง€ ์ˆ˜ ๋ถ„ ์ด๋‚ด์— NGINX ingress controller ๊ฐ€ configmap ์˜ ๋ณ€๊ฒฝ์„ ๊ฐ์ง€ํ•˜๊ณ  ์ž๋™์œผ๋กœ ๋ณ€๊ฒฝ๋œ ์„ค์ •์„ ์ ์šฉํ•œ๋‹ค. ์„ค์ • ๋ณ€๊ฒฝ์ด ์ ์šฉ๋˜์—ˆ๋Š”์ง€๋Š” kubectl get events -n ingress-nginx ๋ช…๋ น์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ณ€๊ฒฝ๋œ ์„ค์ •์œผ๋กœ RELOAD ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ  ๋‚˜๋ฉด nginx ์„ค์ •์ด ๋ณ€๊ฒฝ๋˜์—ˆ์Œ์„ ํ™•์ธํ•˜์ž.

> kubectl -n ingress-nginx exec -it ingress-nginx-controller-54d8b558d4-798w5 -- cat /etc/nginx/nginx.conf | grep ssl_protocols
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

์ด๋ฏธ ์„œ๋น„์Šค ์ค‘์ธ domain ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๋ฉด, https://www.cdn77.com/tls-test ์™€ ๊ฐ™์ด ์„œ๋ฒ„์˜ SSL/TLS ์ง€์› ์—ฌ๋ถ€๋ฅผ ๊ฒ€์ฆํ•ด ์ฃผ๋Š” ์‚ฌ์ดํŠธ์—์„œ๋„ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.

๐Ÿ“Œ References

  1. NGINX Ingress Controller - Default TLS Version and Ciphers
  2. There are two Nginx Ingress Controllers for k8s. What?