gpt4 book ai didi

kubernetes - 将应用程序部署到 Kubernetes 集群时找不到 ConfigMaps

转载 作者:行者123 更新时间:2023-12-05 01:35:12 26 4
gpt4 key购买 nike

我正在尝试将应用程序部署到 Kubernetes 集群。我的部署使用三个 configMap 作为 volumeMounts。

但是,当我应用部署时,它似乎无法找到 configMap。

我的 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 的配置映射是否存在以及在哪个命名空间中。

关于kubernetes - 将应用程序部署到 Kubernetes 集群时找不到 ConfigMaps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63175389/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com