k8s报错: * spec.template.spec.volumes[0].name: Invalid value: "nfs_pvc001": must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])? (e.g. 'my-name' or '123-abc')
报错i原文:
[root@k8s-master ~]# vim nginx-deploy.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 4 template: ▽ metadata: labels: app: nginx spec: containers: - name: nginx image: 10.0.0.10:5000/nginx:1.15 ports: - containerPort: 80 volumeMounts: - name: nfs_pvc001 mountPath: /etc/nginx volumes: - name: nfs_pvc001 persistentVolumeClaim: claimName: pvc0001 [root@k8s-master ~]# kubectl apply -f nginx-deploy.yaml The Deployment "nginx-deployment" is invalid: * spec.template.spec.volumes[0].name: Invalid value: "nfs_pvc001": must match the regex [a-z0-9]([-a-z0-9]*[a-z0-9])? (e.g. 'my-name' or '123-abc') * spec.template.spec.containers[0].volumeMounts[0].name: Not found: "nfs_pvc001" [root@k8s-master ~]# vim nginx-deploy.yaml apiVersion: extensions/v1beta1
将下划线改成- 不符合正则的规则
[root@k8s-master ~]# vim nginx-deploy.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 4 template: metadata: labels: app: nginx spec: containers: - name: nginx image: 10.0.0.10:5000/nginx:1.15 ports: - containerPort: 80 volumeMounts: - name: nfs-pvc001 mountPath: /etc/nginx volumes: - name: nfs-pvc001 persistentVolumeClaim: claimName: pvc0001