簡體   English   中英

將應用程序部署到 Kubernetes 集群時未找到 ConfigMap

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

我正在嘗試將應用程序部署到 Kubernetes 集群。 我的部署使用三個 configMaps 作為volumeMounts。

但是,當我應用部署時,它似乎找不到 configMaps。

我的 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"

當我應用部署時,我收到以下錯誤:

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

我的配置有問題嗎? 可能是什么問題?

您要么沒有創建配置映射,要么在與部署應用程序不同的命名空間中創建了它們。

kubectl get cm -A

上面的命令將列出所有命名空間中的所有配置映射。 檢查名稱為sample-volume-dev-my-app的配置 map 是否存在以及在哪個命名空間中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM