<p>I have a pod <code>egress-operator-controller-manager</code> created from <a href="https://github.com/monzo/egress-operator/blob/master/Makefile" rel="nofollow noreferrer">makefile</a> by command <code>make deploy IMG=my_azure_repo/egress-operator:v0.1</code>.
<a href="https://i.stack.imgur.com/eT2Sm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eT2Sm.png" alt="enter image description here" /></a></p>
<p>This pod was showing <code>unexpected status: 401 Unauthorized</code> error in description, so I created <code>imagePullSecrets</code> and trying to update this pod with secret by creating pod's deployment.yaml [<code>egress-operator-manager.yaml</code>] file. <br/>But when I am applying this yaml file its giving below error:</p>
<pre><code>root@Ubuntu18-VM:~/egress-operator# kubectl apply -f /home/user/egress-operator-manager.yaml
The Deployment &quot;egress-operator-controller-manager&quot; is invalid: spec.selector: Invalid value:
 v1.LabelSelector{MatchLabels:map[string]string{&quot;moduleId&quot;:&quot;egress-operator&quot;}, 
MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable
</code></pre>
<p><em><strong>egress-operator-manager.yaml</strong></em></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: egress-operator-controller-manager
  namespace: egress-operator-system
  labels:
    moduleId: egress-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      moduleId: egress-operator
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        moduleId: egress-operator
    spec:
      containers:
        - image: my_azure_repo/egress-operator:v0.1
          name: egress-operator
      imagePullSecrets:
        - name: mysecret
</code></pre>
<p>Can somene let me know that how can I update this pod's deployment.yaml ?</p>

solveit
<p>Delete the deployment once and try applying the YAML agian.</p>
<p>it could be due to K8s service won't allow the <strong>rolling update</strong> once deployed the <strong>label selectors</strong> of <strong>K8s service</strong> can not be updated until you decide to delete the existing <strong>deployment</strong></p>
<pre><code>Changing selectors leads to undefined behaviors - users are not expected to change the selectors
</code></pre>
<p><a href="https://github.com/kubernetes/kubernetes/issues/50808" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/50808</a></p>
