Re: Changing Pod labels with Kubernetes Go client

227 views
Skip to first unread message

Brian Grant

unread,
Jul 23, 2018, 11:57:41 AM7/23/18
to igor.s...@gmail.com, Kubernetes user discussion and Q&A
Moved to kubernetes-users
kubernetes-dev to bcc

Thanks for also posting to stackoverflow:

Though I'll answer here so that I can link to other sources, and point out some places/ways to search for info in the future.

Looking at documentation on kubernetes.io, it looks like selector immutability was noted in the Deployment documentation:
If you'd like to help by adding a note similar to the one for Deployment, the documentation is in https://github.com/kubernetes/website/tree/master/content/en/docs/concepts/workloads/controllers

However, it sounds like you want to do a blue/green deployment. If you search for "how to do a blue green deployment kubernetes", you should get many relevant hits, such as:
and several others

which change the service selector instead of controller selectors.

A number of deployment tools, such as Spinnaker, can also do this for you.



On Sun, Jul 22, 2018 at 5:17 AM Igor Shmukler <igor.s...@gmail.com> wrote:

Hello,

I am trying to understand something about v1beta2 Go client API. Sorry, but I am new to Kubernetes. Please help me out. It says:

// Label selector for pods. Existing ReplicaSets whose pods are
// selected by this will be the ones affected by this deployment.
// It must match the pod template's labels.
Selector *metav1.LabelSelector `json:"selector" protobuf:"bytes,2,opt,name=selector"`

I have a "custom" label, say color that I want to change from blue or green to solve my CD/CI task. From CLI, I can pass --overwrite and kubectl changes the label's value just fine.

When I am trying to use the API to change just the labels, it returns: the "selector does not match template labels" error. What do I need to do for the label change to succeed? How to I make it "match the template?"

I also see https://github.com/kubernetes/kubernetes/pull/50719 and the selector is now immutable. If selector has to match the labels and selector is immutable, how do I change the labels, now?

Right now, it is either the error: `failed to update deployment: Deployment.apps ...  field is immutable` when I try to change both `MatchLabels` and `Labels` or ``selector` does not match template `labels``.

What do I need to do for the label to get changed/patched?

Thank you

--
You received this message because you are subscribed to the Google Groups "Kubernetes developer/contributor discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.
To post to this group, send email to kuberne...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/8dba56a5-d04f-4a6f-aad5-2e5c216a1e1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages