直接使用范例中的web-frontend的yaml进行kubectl apply -f的时候会遇到报错:
```
error: error when retrieving current configuration of:
Resource: "/v1, Resource=pods", GroupVersionKind: "/v1, Kind=Pod"
Name: "", Namespace: "default"
Object: &{map["apiVersion":"v1" "kind":"Pod" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":""] "labels":map["role":"web-frontend"] "namespace":"default"] "spec":map["containers":[map["image":"nginx" "name":"web" "ports":[map["containerPort":'P' "name":"web"]] "volumeMounts":[map["mountPath":"/usr/share/nginx/html" "name":"nfs"]]]] "volumes":[map["name":"nfs" "persistentVolumeClaim":map["claimName":"nfs"]]]]]}
from server for: "test-pod-pvc.yaml": resource name may not be empty
```
需要给metadata加一个name,例如:
```
apiVersion: v1
kind: Pod
metadata:
labels:
role: web-frontend
name: web-frontend
```
不知道是不是kubernetes版本的差异。
展开