This is a follow-up from my last question - How to programmatically modify a running k8s pod status conditions? after which I realized, you can only patch the container spec from the deployment manifest to seamlessly let the controller apply the patch changes to the pods through the ReplicaSet it created.
Now my question is how to apply patch to make the Pod phase to go to Succeeded
or Failed
. I know for e.g. for pod phase to go to Succeeded
, all the containers need to terminate successfully and shouldn't be restarted. My intention is to not modify the original command and arguments from the container image, but apply a patch to introduce a custom command which will override the one from the container image.
So I attempted to do below to run exit 0
as below
kubectl -n foo-ns patch deployment foo-manager -p '
{
"spec": {
"template": {
"spec": {
"containers": [
{
"name": "container1",
"command": [
"exit",
"0"
]
},
{
"name": "container2",
"command": [
"exit",
"0"
]
}
]
}
}
}
}'
But since my container file system layers are built from FROM scratch
, there aren't any native commands available other than the original executable supposed to run i.e. exit
as a built-in is not even available.
What's the best way to do this? by patching the pod to make it transition to either of those Pod phases.