mide
mide

Reputation: 23

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

Upvotes: 1

Views: 684

Answers (2)

coderanger
coderanger

Reputation: 54211

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.

Upvotes: 2

Dan Harper
Dan Harper

Reputation: 1130

The go client and similar libraries would be following the REST API structure. I believe the kubectl client also uses the API, so it should be possible.

Checkout the code for pod functions in the go library (possibly "Apply" is what you're looking for): https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod.go and the API reference: https://kubernetes.io/docs/reference/kubernetes-api/

Upvotes: 1

Related Questions