<p>I am trying to create a kubernetes deployment. Here is the manifest:</p>
<p><code>server-deployment.yaml</code></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      tier: server
  template:
    metadata:
      labels:
        tier: server
    spec:
      containers:
        - image: rocketblast2481/chatto-server
          name: server-container
          imagePullPolicy: Always
</code></pre>
<p>Then I run the following command:</p>
<pre><code>kubectl apply -f=server-deployment.yaml
</code></pre>
<p>But then I get the following error:</p>
<pre><code>The Deployment &quot;server-deployment&quot; is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{&quot;tier&quot;:&quot;server&quot;}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutabl
</code></pre>

chai
<p>It looks like you are trying to update deployment selector. Which is not possible. To update selector first delete existing deployment using.
kubectl delete deployment server-deployment
Then run
kubectl apply -f server-deployment.yml</p>
