사용자 정의 nginx.conf 파일 사용
사용자 정의 nginx.conf 파일 사용 (Use a custom nginx.conf file)
ConfigMap이나 Secret을 생성하여 컨테이너에 마운트하면 사용자 정의 nginx.conf 파일을 사용할 수 있어요. values.yaml에서 deployment.userDefinedVolumes와 deployment.userDefinedVolumeMounts 필드를 설정하면 돼요. 이렇게 만든 커스텀 템플릿으로 Kong Gateway의 nginx 설정을 원하는 대로 변경할 수 있어요.
출처: 문서
본문
values.yaml에서 다음 필드를 사용하세요:
deployment.userDefinedVolumes: 이 필드는 객체 배열을 받아서 Kong Gateway 배포 리소스의 기존spec.template.spec.volumes배열에 그대로 추가돼요.deployment.userDefinedVolumeMounts: 이 필드는 기존spec.template.spec.containers[].volumeMounts및spec.template.spec.initContainers[].volumeMounts배열에 그대로 추가돼요.
마운트할 볼륨은 Helm values.yaml 파일의 deployment 키 아래에 제공돼요. 구성 구조는 Kubernetes ConfigMapVolumeSource 또는 SecretVolumeSource 구조와 일치해요.
ConfigMap 생성하기
kubectl create configmap custom-template --from-file=nginx_kong.lua=./nginx_kong.lua -n kong
ConfigMap 마운트하기
gateway:
deployment:
userDefinedVolumes:
- name: custom-template
configMap:
name: custom-template
items:
- key: "nginx_kong.lua"
path: "nginx_kong.lua"
userDefinedVolumeMounts:
- name: custom-template
subPath: "nginx_kong.lua"
mountPath: "/usr/local/share/lua/5.1/kong/templates/nginx_kong.lua"
readOnly: true
구성 확인하기
변경 사항이 제대로 작동하는지 확인하려면 컨테이너 내부에서 nginx 파일을 cat으로 확인할 수 있어요.
kubectl exec -n kong kong-gateway-POD_NAME -c proxy -- cat /usr/local/share/lua/5.1/kong/templates/nginx_kong.lua
출력에는 ConfigMap에 넣은 사용자 정의 구성 파일이 표시돼야 해요.
관련 리소스
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.