Kubernetes configmap 崩溃 pod

约翰

我使用命令行 kubectl 创建 configmap,如下所示:

 kubectl create configmap nginx-config --from-file=./site.conf

在我的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我有正常的吊舱设置:

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

当像这样启动 pod 时:

kubectl create -f nginx-pod.yaml

我的 pod 已创建,但他的状态在CrashLoopBackOff2-3 秒后,但如果我删除此行:

volumeMounts:
        - mountPath: /etc/nginx/conf.d
          name: nginx-config
  volumes:
    - name: nginx-config
      configMap:
        name: nginx-config

我没有问题。

用户9609399

我最近遇到的问题似乎是site.conf。当 nginx 加载她的 conf 您的 nginx 崩溃结束您的 pod 崩溃时,您的 pod 会正确加载您的配置映射。检查您的 site.conf 结束添加默认值,如下所示

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;
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何从kubernetes pod获取configmap

Kubernetes - 封装 DB 的 Pod 崩溃

在Kubernetes中更新configmap时重启Pod吗?

在kubernetes中,如何更新Pod以使用更新的configmap

Kubernetes Pod 上的 CockroachDB 集群崩溃

在kubernetes中查看崩溃的pod的日志文件

为什么我的环境变量没有在 ConfigMap 的 Kubernetes Pod 中设置?

Kubernetes 卷挂载 ConfigMap 到 Pod 内的文件,而不会覆盖所有其他文件

ConfigMap 也用于 kubernetes 配置?

Kubernetes ConfigMap大小限制

Kubernetes集群中的一个Pod崩溃了,但另一个没有崩溃

有没有一种方法可以创建一个包含Kubernetes Pod的多个文件的configMap?

json格式的Kubernetes configmap错误

从Kubernetes中的configmap删除密钥

在 configmap 中使用 kubernetes 机密

从hashicorp vault 填充kubernetes Configmap

Kubernetes JSON configMap 未安装

在Minio作为存储的Kubernetes上部署Spinnaker时,Spin-front50 pod崩溃

Kubernetes ConfigMap YAML到Terraform Kubernetes中

安装之前使用configmap的kubernets pod

Kubernetes:Rails 凭证还是 ConfigMap/Secret 方式?

Kubernetes-使用特定的ConfigMap版本控制

为什么在 kubernetes 中找不到 configmap?

Kubernetes:参考以前定义的ConfigMap键值对

在Kubernetes ConfigMap上托管jar文件

Azure kubernetes-python读取configmap吗?

来自文件的新Kubernetes ConfigMap-加号?

Kubernetes ConfigMap 挂载单个文件而不是目录

Kubernetes-如何编辑CoreDNS corefile configmap?