我有一个使用 nginx 网络服务器提供静态内容的应用程序,这是实际nginx.conf
文件的样子
upstream app_api {
server web:8000;
}
server {
listen 80;
client_max_body_size 100M;
location / {
proxy_pass http://chp_api;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_read_timeout 3600;
}
location /staticfiles/ {
alias /home/chp_api/web/staticfiles/;
}
}
为了将其转换为 helm chart 并将 nginx 作为应用程序 namsespace 中的单独 pod 运行。我遵循了这段代码。这是我的nginx-config.yaml
文件
{{- if .Values.nginx.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "app.fullname" . }}-nginxconfig
labels:
app.kubernetes.io/name: {{ include "app.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
nginx.conf: |-
{{- if .Values.nginx.config.default }}
upstream app_api {
server web:8000;
}
server {
listen 80;
# set max upload size
client_max_body_size 100M;
location / {
proxy_pass http://app_api;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_read_timeout 3600;
}
location /staticfiles/ {
alias /home/app_api/web/staticfiles/;
}
}
{{- else }}
{{ .Values.nginx.config.custom | indent 4 }}
{{- end }}
{{- end }}
nginx 的 values.yaml 文件看起来像
nginx:
enabled: false
image:
repository: nginx
tag: alpine
pullPolicy: IfNotPresent
config:
default: true
resources: {}
但是我没有看到为 nginx web 服务器创建了单独的 pod,除了应用程序的一个。请问我做错了什么,我是kubernetes和helm chart的新手。