我使用命令行kubectl创建configmap,如下所示:
kubectl create configmap nginx-config --from-file=./site.conf在我的site.conf中,我有一个简单的nginx:
server {
listen 80;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
access_log off;
expires max;
}
}在我的nginx-pod.yaml中,我有正常的pod设置:
apiVersion: v1
kind: Pod
metadata:
name: www
labels:
app: nginx
spec:
containers:
- name: proxy
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /etc/nginx/conf.d
name: nginx-config
volumes:
- name: nginx-config
configMap:
name: nginx-config当像这样启动吊舱时:
kubectl create -f nginx-pod.yaml我的吊舱是创建的,但是他的状态CrashLoopBackOff在2-3秒后,但是如果我移除这一行:
volumeMounts:
- mountPath: /etc/nginx/conf.d
name: nginx-config
volumes:
- name: nginx-config
configMap:
name: nginx-config我没什么问题。
发布于 2018-05-01 14:31:58
我最近遇到了一个问题,那就是site.conf。当nginx加载nginx时,您的吊舱加载您的configmap正确地倒出,您的nginx崩溃结束您的吊舱崩溃。检查site.conf end添加de默认值,如下所示
server {
listen 80;
listen [::]:80;
root /var/www/html/quickstart/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}发布于 2018-04-30 22:08:37
还有别的事把你搞砸了。我刚刚从字面上复制了您的conf和yaml文件(除了使用-n测试名称空间运行它以实现分离),它运行得完美无缺。
运行正常,跳到荚中,site.conf按预期愉快地安装在/etc/nginx/conf.d .d文件夹中。我使用的k8s版本是1.9.2,从配置上看,这是正确的。
编辑:刚在Mac (Client1.9.3,服务器1.9.0)上试用了minikube (客户端1.9.3服务器1.9.0),它也只是起作用(甚至连名称空间都没有,完全是您所描述的步骤)。
您能看到调度器/api或pod在失败状态下的日志吗?也许它能让更多的人明白是什么阻止了它的开始?您是否有错误配置的RBAC或跨名称空间来阻止读取配置映射?
https://stackoverflow.com/questions/50106425
复制相似问题