错误样例
[root@kubemaster ~]# cat cw_test.yaml apiVersion: v1 kind: Pod metadata: name: pod_demo_cw namespace: default labels: app: ngix_test_pod spec: containers: - name: ngix_test_cw image: 10.37.218.29:5000/suning/wildfly_oraclejdk1.7_110:20181220
执行的过程中,提示如下错误:
[root@kubemaster ~]# kubectl create -f ./cw_test.yaml The Pod "pod_demo_cw" is invalid: * metadata.name: Invalid value: "pod_demo_cw": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*') * spec.containers[0].name: Invalid value: "ngix_test_cw": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
修改成中划线
apiVersion: v1 kind: Pod metadata: name: pod-demo-cw namespace: default labels: app: ngix-test-pod spec: containers: - name: ngix-test-cw image: 10.37.218.29:5000/suning/wildfly_oraclejdk1.7_110:20181220
验证
[root@kubemaster ~]# kubectl get pod NAME READY STATUS RESTARTS AGE pod-demo-cw 1/1 Running 0 7s redhat-nginx-59fc448665-9bqmr 1/1 Running 0 21d redhat-nginx-59fc448665-fntgt 1/1 Running 0 28d redhat-nginx-59fc448665-sxt64 1/1 Running 0 21d [root@kubemaster ~]# vim cw_test.yaml +3 [root@kubemaster ~]# kubectl get pod pod-demo-cw NAME READY STATUS RESTARTS AGE pod-demo-cw 1/1 Running 0 3m36s [root@kubemaster ~]#