Kubernetes配置地图坠毁吊舱
我使用命令行kubectl创建configmap,如下所示:Kubernetes配置地图坠毁吊舱,kubernetes,kubectl,minikube,Kubernetes,Kubectl,Minikube,我使用命令行kubectl创建configmap,如下所示: kubectl create configmap nginx-config --from-file=./site.conf kubectl create -f nginx-pod.yaml 在my site.conf中,我有一个简单的nginx conf: server { listen 80; index index.php index.html; location / {
kubectl create configmap nginx-config --from-file=./site.conf
kubectl create -f nginx-pod.yaml
在my site.conf中,我有一个简单的nginx conf:
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 configmap nginx-config --from-file=./site.conf
kubectl create -f nginx-pod.yaml
我的pod已创建,但他的状态在2-3秒后崩溃,但如果我删除此行:
volumeMounts:
- mountPath: /etc/nginx/conf.d
name: nginx-config
volumes:
- name: nginx-config
configMap:
name: nginx-config
我没有问题。有别的事情把你搞糊涂了。我只是复制了您的conf和yaml文件,除了使用-n test名称空间进行分离外,它工作得非常完美 运行ok,跳转到pod,site.conf按照预期安装在/etc/nginx/conf.d文件夹中。我使用的裸金属k8s版本是1.9.2,从配置角度看这是正确的 编辑:刚刚在Mac上的minikube以及客户端1.9.3服务器1.9.0上试用过,而且它甚至不在名称空间中工作,这正是您描述的步骤
您能看到处于失败状态的调度器/api或pod的日志吗?也许它能让我们更清楚是什么阻止了它的发生?您没有错误配置RBAC或跨名称空间的某些内容,从而阻止读取配置映射?我最近遇到的问题是site.conf。当nginx加载她的配置时,正确加载您的pod配置映射nginx崩溃结束pod崩溃。检查您的site.conf end添加默认值,如下所示
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;
}
}
嗨,你能把kubectl的输出放到cm nginx config-o yaml吗?