简体   繁体   English

将应用程序部署到 Kubernetes 集群时未找到 ConfigMap

[英]ConfigMaps Not Found while Deploying an Application to Kubernetes Cluster

I am trying to deploy an app to a Kubernetes cluster.我正在尝试将应用程序部署到 Kubernetes 集群。 My deployment uses three configMaps as volumeMounts.我的部署使用三个 configMaps 作为volumeMounts。

However when I apply the deployment it can't seem to find the configMaps.但是,当我应用部署时,它似乎找不到 configMaps。

My deployment.yml looks like this:我的 deployment.yml 看起来像这样:

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: dev-space
  name: my-app-dev
spec:
  replicas: 1
  revisionHistoryLimit: 1
  selector:
    matchLabels:
      name: my-app-dev
  strategy:
    rollingUpdate:
      maxSurge: 100%
      maxUnavailable: 30%
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: my-app-dev
        version: v1
      annotations:
        sla: high
        tier: application
        role: frontend-api
        quality: dev
    spec:
      containers:
      - name: my-app
        env:
        - name: ENVIRONMENT
          value: dev
        - name: SAMPLE_FILE
          value: sample.yml
        - name: SAMPLE_FILE2
          value: sample2.yml
        image: my-app:1.0
        ports:
        - containerPort: 8000
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /health
            port: 9000
          initialDelaySeconds: 11
          timeoutSeconds: 3
        readinessProbe:
          httpGet:
            path: /health
            port: 9000
          initialDelaySeconds: 11
          timeoutSeconds: 3
        volumeMounts:
          - name: sample-volume
            mountPath: /path
            readOnly: true
          - name: sample-volume1
            mountPath: /path1
            readOnly: true
          - name: sample-volume2
            mountPath: /path2
            readOnly: true
      nodeSelector:
        tier: app
      imagePullSecrets:
      - name: img-secret
      volumes:
        - name: "sample-volume"
          configMap:
            name: "sample-volume-dev-my-app"
        - name: "sample-volume1"
          configMap:
            name: "sample-volume1-dev-my-app"
        - name: "sample-volume2"
          configMap:
            name: "sample-volume2-dev-my-app"

When I apply the deployment I get the following errors:当我应用部署时,我收到以下错误:

Warning  FailedMount   4m (x6 over 5m)  kubelet, server.org.local  MountVolume.SetUp failed for volume "sample-volume" : configmaps "sample-volume-dev-my-app" not found
Warning  FailedMount   4m (x6 over 5m)  kubelet, server.org.local  MountVolume.SetUp failed for volume "sample-volume1" : configmaps "sample-volume1-dev-my-app" not found
Warning  FailedMount   4m (x6 over 5m)  kubelet, server.org.local  MountVolume.SetUp failed for volume "sample-volume2" : configmaps "sample-volume2-dev-my-app" not found

Is there something wrong with my configuration?我的配置有问题吗? What could be the issue?可能是什么问题?

You either have not created the config maps or you have created them in a different namespace than where you are deploying the application.您要么没有创建配置映射,要么在与部署应用程序不同的命名空间中创建了它们。

kubectl get cm -A

Above command will list all config maps in all namespaces.上面的命令将列出所有命名空间中的所有配置映射。 Check if a config map with name sample-volume-dev-my-app exists and in which namespace.检查名称为sample-volume-dev-my-app的配置 map 是否存在以及在哪个命名空间中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 部署到 Kubernetes 集群后启动 angular 应用程序时出现 502 bad gateway 错误 - 502 bad gateway error while launching the angular application after deploying to Kubernetes cluster 使用Kubernetes ConfigMaps的应用程序配置文件 - Application Config file using Kubernetes ConfigMaps 使用 spring 微服务从 kubernetes 集群中的服务中提取配置映射 - Extracting configmaps from services in kubernetes cluster using a spring microservice kubernetes-部署集群时“ govc:未找到网络'vm网络'” - kubernetes - “govc: network 'vm network' not found” when deploying cluster 在 kubernetes 集群上部署 Cassandra - Deploying Cassandra on kubernetes cluster 使用无服务器框架将kubeless功能部署到kubernetes集群时出错 - Error while deploying kubeless function to kubernetes cluster by using serverless framework 使用PostgreSQL将Django应用程序部署到Kubernetes Google Cloud集群 - Deploying Django Application with PostgreSQL to Kubernetes Google Cloud cluster 部署 nginx 入口 controller 时错误创建资源“configmaps” - error create resource “configmaps” while deploying nginx ingress controller 更新配置映射时如何在 kubernetes 中的应用程序内获取通知 - How to get notification inside an application in kubernetes when configmaps get updated 在kubernetes集群上部署zuul代理 - Deploying zuul proxy on kubernetes cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM