亲爱的K8S社区团队,
当我部署应用程序窗格时,我从nginx收到此错误消息。我的应用程序angular6应用程序托管在nginx服务器中,该服务器在EKS中部署为docker容器。
我将我的应用程序配置为“只读容器文件系统”,但我使用“shortDir”类型的“临时安装”卷与只读文件系统结合使用。
所以我不确定以下错误的原因:
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;
...
好像你的nginx
没有以root用户身份运行。
自发布1.12.1-r2
以来,nginx守护程序正在以用户1001
身份运行。
1.12.1-R2
nginx容器已迁移到非root容器方法。以前,容器以root用户身份运行,nginx守护程序以nginx用户身份启动。从现在开始,容器和nginx守护程序都以用户1001运行。因此,配置文件可由运行nginx进程的用户写入。
这就是为什么你无法绑定端口80
,必须使用端口> 1000。
你应该使用:
ports:
- '80:8080'
- '443:8443'
并编辑nginx.conf,使其侦听端口8080:
server {
listen 0.0.0.0:8080;
...
或者以root身份运行nginx:command: [ "/bin/bash", "-c", "sudo nginx -g 'daemon off;'" ]