So at work we are having a bit of a mare with Helm and Kubernetes.
Long-term we have a fix, but short-term we have some patches that I'm currently manually applying using kubectl edit deployment -n {namespace} {podBaseName}
, then editing in vim...
It feels a bit cowboy.
I found https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/ which suggests I can issue a kubectl patch deployment -n {namespace} {podBaseName} --patch 'some: patch: definition'
I'm looking to add to a livenessProbe
but I'm not 100% sure of the Syntax to ensure I only add the property I want, which is initialDelaySeconds: 60
Is it also possible to upsert
using a patch if I wanted to add startupProbe
or readinessProbe
?
So this is as far as I have got.
It does solve some problems (mostly not going via vim as the kubectl edit deployment
leads to, with possible user-error etc).
Our Helm is still broken, and I've no definitive ETA on the fix.
So The current kubectl
fix/hack is limited (or seems to be) limited to single container pod type.
kubectl patch deployment \
-n ${KUBE_NAMESPACE} \
${KUBE_POD_PREFIX} \
--patch '{"spec":{"containers":[{"livenessProbe":{"exec":{"command":["your", "health", "check", "command"]},"failureThreshold":5,"initialDelaySeconds":60,"periodSeconds:5,"successThreshold":1,"timeoutSeconds":1},"name":"sqs-worker"}]}}}}'
This is to patch an sqs-worker type container in a pod, which only has that container. We also have web-containers which have an nginx ingress as well as an instance of an app.
KUBE_NAMESPACE
is how we are separating internal environments. This might be a branch name or prod
or dev
. kubectl get namespaces
should be your guide to picking a value for you.
KUBE_POD_PREFIX
is the pod name, without the odd suffix that is appended. This might be helm or our helm related. All I know is I might have service-a-specific-task-worker-sdhhdg3jh
pod and I supply service-a-specific-task-worker
. I use kubectl get pods -n ${KUBE_NAMESPACE}
as my source of truth here.