Is there a way to update the Services selector label?

2,080 views
Skip to first unread message

Norman Khine

unread,
Oct 20, 2016, 9:30:59 AM10/20/16
to Kubernetes user discussion and Q&A
Hello, I have the following pod, which has 3 containers:

apiVersion: extensions/v1beta1
kind
: Deployment
metadata
:
  name
: app-feature
  labels
:
    pod
: app
    track
: feature
spec
:
  replicas
: 3
 
template:
    metadata
:
      labels
:
        pod
: app
        track
: feature
    spec
:
      containers
:
       
- name: app-api
          image
: quay.io/.../api:feature_swagger
          imagePullPolicy
: Always
          ports
:
           
- containerPort: 3000
       
- name: app-media
          image
: quay.io/.../media:feature_kube
          imagePullPolicy
: Always
          ports
:
           
- containerPort: 4000
       
- name: phantom
          image
: docker.io/wernight/phantomjs:2.1.1
          command
: ["phantomjs", "--webdriver=8910", "--web-security=no", "--load-images=false", "--local-to-remote-url-access=yes"]
          ports
:
           
- containerPort: 8910
          resources
:
            requests
:
              memory
: 1000
      restartPolicy
: Always
      imagePullSecrets
:
       
# we download these from quay.io account
       
- name: pull-secret



This is the service file i have:

apiVersion: v1
kind: Service
metadata:
  name: media-dev
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:XXX:certificate/XXX
spec:
  type: LoadBalancer
  selector:
    pod: app
    track: develop
  ports:
  - name: http
    port: 80
    targetPort: 4000
  - name: https
    port: 443
    targetPort: 4000

How do I change the selector for this loadBalancer to track `feature` instead of `develop` - is it possible to modify for an existing Service without having to create a new service?

Any advise is much appreciated

Rodrigo Campos

unread,
Oct 20, 2016, 9:54:10 AM10/20/16
to kubernet...@googlegroups.com
Yes, modify the file and do kubectl apply -f <file>
--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Tim Hockin

unread,
Oct 20, 2016, 10:35:28 AM10/20/16
to kubernet...@googlegroups.com
Kubectl replace requires you to read-modify-write to avoid immutable fields, but apply is "gentler" and generates a patch.

Norman Khine

unread,
Oct 20, 2016, 10:48:54 AM10/20/16
to kubernet...@googlegroups.com
i am trying to update a service not a pod

➜  k8s git:(master) ✗ kubectl replace -f templates/services/dev/service-media-feature.yaml       (git)-[master] 
The Service "media-feature" is invalid.
spec.clusterIP: Invalid value: "": field is immutable

whereas apply works and updates the Service

thanks for your help


You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/tqtPsS7t3hw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.

To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.



--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

Tim Hockin

unread,
Oct 20, 2016, 11:34:37 AM10/20/16
to kubernet...@googlegroups.com
That's what I mean - replace really requires a read-modify-write, so
you can read back the immutable field.
>>>> an email to kubernetes-use...@googlegroups.com.
>>>> To post to this group, send email to kubernet...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Kubernetes user discussion and Q&A" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to kubernetes-use...@googlegroups.com.
>>> To post to this group, send email to kubernet...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Kubernetes user discussion and Q&A" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/kubernetes-users/tqtPsS7t3hw/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> kubernetes-use...@googlegroups.com.
>> To post to this group, send email to kubernet...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/kubernetes-users.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for
> c in ",adym,*)&uzq^zqf" ] )
>
> --
> You received this message because you are subscribed to the Google Groups
> "Kubernetes user discussion and Q&A" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kubernetes-use...@googlegroups.com.
> To post to this group, send email to kubernet...@googlegroups.com.

Norman Khine

unread,
Oct 20, 2016, 11:55:55 AM10/20/16
to kubernet...@googlegroups.com
oh i see, thank you

On 20 October 2016 at 16:34, 'Tim Hockin' via Kubernetes user discussion and Q&A <kubernet...@googlegroups.com> wrote:
That's what I mean - replace really requires a read-modify-write, so
you can read back the immutable field.

On Thu, Oct 20, 2016 at 7:48 AM, Norman Khine <nor...@khine.net> wrote:
> i am trying to update a service not a pod
>
> ➜  k8s git:(master) ✗ kubectl replace -f
> templates/services/dev/service-media-feature.yaml       (git)-[master]
> The Service "media-feature" is invalid.
> spec.clusterIP: Invalid value: "": field is immutable
>
> whereas apply works and updates the Service
>
> thanks for your help
>
>
> On 20 October 2016 at 15:35, 'Tim Hockin' via Kubernetes user discussion and
>>>> an email to kubernetes-users+unsubscribe@googlegroups.com.
>>>> To post to this group, send email to kubernetes-users@googlegroups.com.

>>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Kubernetes user discussion and Q&A" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to kubernetes-users+unsubscribe@googlegroups.com.
>>> To post to this group, send email to kubernetes-users@googlegroups.com.

>>> Visit this group at https://groups.google.com/group/kubernetes-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Kubernetes user discussion and Q&A" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/kubernetes-users/tqtPsS7t3hw/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>> Visit this group at https://groups.google.com/group/kubernetes-users.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26) for
> c in ",adym,*)&uzq^zqf" ] )
>
> --
> You received this message because you are subscribed to the Google Groups
> "Kubernetes user discussion and Q&A" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kubernetes-users+unsubscribe@googlegroups.com.
> To post to this group, send email to kubernetes-users@googlegroups.com.

> Visit this group at https://groups.google.com/group/kubernetes-users.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/tqtPsS7t3hw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages