[英]Kubernetes Persistent Volume Mount not found
我正在尝试创建和安装一个卷但卡住了。
这部分创建存储:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvclaim2
spec:
accessModes:
- ReadWriteOnce
storageClassName: managed-premium
resources:
requests:
storage: 5Gi
以下是我的部署部分的延续:
volumeMounts:
- name: config
mountPath: /config
readOnly: true
args:
- --configfile=/config/traefik.toml
volumes:
- name: config
persistentVolumeClaim:
claimName: pvclaim2
configMap:
name: traefik-config
我不断收到以下错误消息:
部署“traefik-ingress-controller”无效:spec.template.spec.containers[0].volumeMounts[0].name:未找到:“config”
任何帮助表示赞赏。
更新:
Output from describe pv:
Conditions:
Type Status
PodScheduled False
Volumes:
certs:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: pvclaim101
ReadOnly: false
config:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: traefik-conf
Optional: false
traefik-ingress-controller-token-6npxp:
Type: Secret (a volume populated by a Secret)
SecretName: traefik-ingress-controller-token-6npxp
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 1m (x25 over 2m) default-scheduler persistentvolumeclaim "pvclaim101" not found
看起来你有缩进它找到VolumeMount而不是Volume。 这样的事情应该有效:
containers:
- image: your-image
name: your-containers
volumeMounts:
- name: config
mountPath: /config
readOnly: true
args:
- --configfile=/config/traefik.toml
volumes:
- name: config
persistentVolumeClaim:
claimName: pvclaim2
configMap:
name: traefik-config
我们调试一下:
1)你的PersistentVolumeClaim的名字是pvclaim2
,一切看起来都不错
2) VolumeMounts
部分看起来不错。 config
处于只读模式,配置正确。
3) volumes
部分描述config
卷的类型是persistentVolumeClaim
并且它链接到PVC pvclaim2
- 好吧!
4)接下来我们可以看到config
卷的类型同时是configMap
以及PersistentVolumeClaim
......这将是未来出错的原因。 假设你想使用config
卷作为configfile traefik.toml
的挂载,你不需要PVC(特别是在只读模式下为5千兆字节)
您需要做的就是创建configMap
。 命令语法:
kubectl create configmap <map-name> <data-source>
在你的情况下,它可以这样做:
kubectl create configmap traefik-config --from-file=<your-local-path-to-file>/traefik.toml
然后,您需要更新部署:
containers:
- image: your-image
name: your-containers
volumeMounts:
- name: config
mountPath: /config
readOnly: true # as far as i know configmaps are read-only since 1.9.5
- name: some-persistent-storage-name
mountPath: /<some-mount-point-for-storage>
...
volumes:
- name: config
configMap:
name: traefik-config
- name: some-persistent-storage-name
persistentVolumeClaim:
claimName: pvclaim2
我想在这里做一个疯狂的猜测,你的traefik入口控制器是否在与你的pvc相同的命名空间中运行? Pvc是名称空间作用域,在您的示例中,它位于默认名称空间中。 通常我们将入口部署到自己的命名空间,如“ingress”及其他相关的pod。
这是因为没有PersistentVolume(PV)绑定到该PersistentVolumeClaim(PVC)。 这可能是由于几个原因造成的。
有一点是你没有为索赔创建PV。 PVC需要要求PV。 如果是这样,首先需要创建kubernets支持的任何类型的多种类型的持久卷。 可以在此处找到使用nfs的PV的示例。
第二个原因可能是任何现有和未绑定PV的任何参数都与PVC不匹配。 因此,请检查PV和PVC的存储容量,访问模式,存储类别和标签是否匹配。 例如,如果您想要storageClassName: managed-premium
的PVC storageClassName: managed-premium
,请确保您的PV也具有存储类类型。
最后一件事可能是您认为存在的PV,并将所有参数与PVC绑定到其他PVC相匹配。 PV是一种原子抽象,您不能将一个PV用于多个PVC。
您可以使用kubectl get pv
来检查是否存在可用STATUS且符合PVC要求的卷。
我也遇到过这个错误。 确保 PVC 指向正确的命名空间,因为 PVC 是命名空间的。 光伏不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.