<p>Note: nfs server and permission are fine, I have checked PV and PVC is creating fine only statefulSet is giving me this error.</p>
<p>Error Message: The StatefulSet &quot;auth-mongo-ss&quot; is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden
(err msg is straightforward but didn't help to solve it! what am I missing here ?)</p>
<p>Kubernetes(minkube) version:</p>
<p>Client Version: v1.20.2
Server Version: v1.20.2</p>
<p>OS:</p>
<p>Linux mint - 20</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: auth-pv
spec:
  capacity:
    storage: 250Mi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  nfs:
    path: /nfs/auth
    server: 192.168.10.104
---
apiVersion: v1
kind: Service
metadata:
  name: auth-mongo-serv
  labels:
    app: auth-mongo-serv
spec:
  ports:
    - name: db
      protocol: TCP
      port: 27017
      targetPort: 27017
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: auth-mongo-ss
spec:
  selector:
    matchLabels:
      app: auth-mongo-serv # has to match .spec.template.metadata.labels
  serviceName: auth-mongo-ss
  replicas: 1 # by default is 1
  template:
    metadata:
      labels:
        app: auth-mongo-serv # has to match .spec.selector.matchLabels
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: auth-mongo-docker
          image: mongo
          ports:
            - containerPort: 27017
          resources:
            limits:
              memory: &quot;250Mi&quot;
              cpu: &quot;250m&quot;
          volumeMounts:
            - name: auth-mongo-data
              mountPath: /data/db
  volumeClaimTemplates:
    - metadata:
        name: auth-mongo-data
      spec:
        storageClassName: manual
        accessModes: [&quot;ReadWriteMany&quot;]
        resources:
          requests:
            storage: 250Mi
    ```
</code></pre>

Meet Patel
<p>The error <code>spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden</code> saying it all.</p>
<p>In <code>StatefultSet</code> only mutable (you can change/update) is <code>replicas</code>, <code>template</code>, and <code>updateStrategy</code>. Other than these fields in <code>Spec</code> you cannot change others fields during updates.</p>
<h1>Update</h1>
<p>You have multiple issues:</p>
<ol>
<li><p>in the <code>StatefuleSet</code> Spec you used <code>serviceName: auth-mongo-ss</code>, do you have this headless service?</p>
</li>
<li><p>In this service spec you did not give <code>selector</code></p>
</li>
</ol>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: auth-mongo-serv
  labels:
    app: auth-mongo-serv
spec:
  ports:
    - name: db
      protocol: TCP
      port: 27017
      targetPort: 27017
</code></pre>
<p>An example of StatefulSet from k8s doc is given below, for statefulset you need one headless service.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx # has to match .spec.template.metadata.labels
  serviceName: &quot;nginx&quot;
  replicas: 3 # by default is 1
  template:
    metadata:
      labels:
        app: nginx # has to match .spec.selector.matchLabels
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ &quot;ReadWriteOnce&quot; ]
      storageClassName: &quot;my-storage-class&quot;
      resources:
        requests:
          storage: 1Gi
</code></pre>
