Search code examples
linuxgokuberneteskubectlmicrok8s

Pod redeploy trigger in golang k8s client


How can I trigger the update (redeploy) of the hearth through the k8s golang client.

At the moment, I use these libraries to get information about pods and namespaces:

v1 "k8s.io/api/core/v1
k8s.io/apimachinery/pkg/apis/meta/v1
k8s.io/client-go/kubernetes
k8s.io/client-go/rest

Maybe there is another library or it can be done through linux signals


Solution

  • The standard way to trigger a rolling restart is set/update an annotation in the pod spec with the current timestamp. The change itself does nothing but that changes the pod template hash which triggers the Deployment controller to do its thang. You can use client-go to do this, though maybe work in a language you're more comfortable with if that's not Go.