如何使用 Helm 在 Nginx Ingress 中设置服务器片段配置
How to set server snippets Config in Nginx Ingress with Helm
相关 Github 问题:https://github.com/kubernetes/ingress-nginx/issues/6519
apiVersion: v1
data:
server-snippet: |
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
use-forwarded-headers: "true"
kind: ConfigMap
在下面的方法中设置值时,如何使用helm实现上述配置?
helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=<?> \
--debug
您可以定义一个多行环境变量,如下所示,
read -d '' conf << EOF
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
EOF
定义环境变量后,在 helm --set-string controller.config.server-snippet=
arg 中引用它,如下所示,
helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=$conf \
--debug
相关 Github 问题:https://github.com/kubernetes/ingress-nginx/issues/6519
apiVersion: v1
data:
server-snippet: |
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
use-forwarded-headers: "true"
kind: ConfigMap
在下面的方法中设置值时,如何使用helm实现上述配置?
helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=<?> \
--debug
您可以定义一个多行环境变量,如下所示,
read -d '' conf << EOF
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
EOF
定义环境变量后,在 helm --set-string controller.config.server-snippet=
arg 中引用它,如下所示,
helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=$conf \
--debug