Below is the code:
apiVersion: v1
kind: Pod
metadata:
name: test-probe
labels:
app: probe
rel: stable
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat:
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
that gives error:
Error from server (BadRequest): error when creating "file.pod.yml": Pod in version "v1" cannot be handled as a Pod: json: cannot unmarshal object into Go struct field ExecAction.spec.containers.livenessProbe.exec.command of type string
on running kubectl create -f file.pod.yml --save-config
How to resolve this error?
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", GitCommit:"fa3d7990104d7c1f16943a67f11b154b71f6a132", GitTreeState:"clean", BuildDate:"2023-07-19T12:20:54Z", GoVersion:"go1.20.6", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.3", GitCommit:"25b4e43193bcda6c7328a6d147b1fb73a33f1598", GitTreeState:"clean", BuildDate:"2023-06-14T09:47:40Z", GoVersion:"go1.20.5", Compiler:"gc", Platform:"linux/amd64"}