【发布时间】:2019-08-23 22:20:27
【问题描述】:
尊敬的 K8S 社区团队,
我在部署应用程序 pod 时从 nginx 收到此错误消息。我的应用程序 angular6 应用程序托管在 nginx 服务器内,该服务器部署为 EKS 内的 docker 容器。
我将我的应用程序配置为“只读容器文件系统”,但我将“emptyDir”类型的“临时挂载”卷与只读文件系统结合使用。
所以我不确定以下错误的原因:
2019/04/02 14:11:29 [emerg] 1#1: mkdir() “/var/cache/nginx/client_temp”失败(30:只读文件系统) nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" 失败 (30: 只读文件系统)
我的deployment.yaml 是:
...
spec:
volumes:
- name: tmp-volume
emptyDir: {}
# Pod Security Context
securityContext:
fsGroup: 2000
containers:
- name: {{ .Chart.Name }}
volumeMounts:
- mountPath: /tmp
name: tmp-volume
image: "{{ .Values.image.name }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
securityContext:
capabilities:
add:
- NET_BIND_SERVICE
drop:
- ALL
securityContext:
readOnlyRootFilesystem: true
ports:
- name: http
containerPort: 80
protocol: TCP
...
nginx.conf 是:
...
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Turn off the bloody buffering to temp files
proxy_buffering off;
sendfile off;
keepalive_timeout 120;
server_names_hash_bucket_size 128;
# These two should be the same or nginx will start writing
# large request bodies to temp files
client_body_buffer_size 10m;
client_max_body_size 10m;
...
【问题讨论】:
-
您好,您将它安装到
/tmp,但在/var/cache/nginx/client_temp创建文件。这是 2 个不同的位置。/tmp来自 emptydir 但其他是容器文件系统的一部分,它是只读的 -
你是对的!现在我正在重定向 nginx 以在我安装的卷中创建文件: nginx.conf
code.. http { client_body_temp_path /tmp 1 2; proxy_temp_path /tmp 1 2; fastcgi_temp_path /tmp 1 2; uwsgi_temp_path /tmp 1 2; scgi_temp_path /tmp 1 2; ... 服务器 { 听 0.0.0.0:80;code但现在出现此错误:2019/04/02 15:22:43 [emerg] 1#1: bind() to 0.0.0.0:80 failed (13: Permission denied) nginx: [emerg] bind()到 0.0.0.0:80 失败(13:权限被拒绝)
标签: nginx deployment kubernetes kubernetes-helm security-context