「-」の付け忘れ
apiVersion: v1
kind: Pod
metadata:
...
spec:
containers:
- envFrom: # <- editコマンドとかで先頭に追加したとき「-」付け忘れガチ
- secretRef:
name: db-secret
image: kodekloud/simple-webapp-mysql
imagePullPolicy: Always
name: webapp
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-7h9vc
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: controlplane
preemptionPolicy: PreemptLowerPriority
このとき表示されるエラー
controlplane ~ k apply -f /tmp/kubectl-edit-1562776459.yaml
Error from server (BadRequest): error when creating "/tmp/kubectl-edit-1562776459.yaml": Pod in version "v1" cannot be handled as a Pod: json: cannot unmarshal object into Go struct field PodSpec.spec.containers of type []v1.Container
controlplane ~
こっちはarrayじゃなくてもいいとこをarrayにした時
controlplane ~ ➜ k apply -f pv-log.yaml
Error from server (BadRequest): error when creating "pv-log.yaml": PersistentVolume in version "v1" cannot be handled as a PersistentVolume: json: cannot unmarshal array into Go struct field PersistentVolumeSpec.spec.hostPath of type v1.HostPathVolumeSource