<p>I am trying to convert one Deployment to StatefulSet in Kubernetes. Below is my Deployment description .</p>

<pre><code># Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "4"
  creationTimestamp: "2020-04-02T07:43:32Z"
  generation: 6
  labels:
    run: jbpm-server-full
  name: jbpm-server-full
  namespace: dice-jbpm
  resourceVersion: "2689379"
  selfLink: /apis/apps/v1/namespaces/dice-jbpm/deployments/jbpm-server-full
  uid: 8aff5d46-533a-4178-b9b5-5015ff1cdd5d
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      run: jbpm-server-full
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        run: jbpm-server-full
    spec:
      containers:
      - image: jboss/jbpm-server-full:latest
        imagePullPolicy: Always
        name: jbpm-server-full
        ports:
        - containerPort: 8080
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /k8sdata/jbpmdata
          name: jbpm-pv-storage
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: jbpm-pv-storage
        persistentVolumeClaim:
          claimName: jbpm-pv-claim
status:
  availableReplicas: 1
  conditions:
  - lastTransitionTime: "2020-04-02T07:43:32Z"
    lastUpdateTime: "2020-04-09T12:35:19Z"
    message: ReplicaSet "jbpm-server-full-b48989789" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  - lastTransitionTime: "2020-04-09T12:37:05Z"
    lastUpdateTime: "2020-04-09T12:37:05Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  observedGeneration: 6
  readyReplicas: 1
  replicas: 1
  updatedReplicas: 1
</code></pre>

<p>Error:</p>

<pre><code>deployments.apps "jbpm-server-full" was not valid:
* : Invalid value: "The edited file failed validation": 

ValidationError(StatefulSet.spec): unknown field "progressDeadlineSeconds" in io.k8s.api.apps.v1.StatefulSetSpec, 

ValidationError(StatefulSet.spec): 
unknown field "strategy" in io.k8s.api.apps.v1.StatefulSetSpec, 

ValidationError(StatefulSet.spec): missing required field "serviceName" in io.k8s.api.apps.v1.StatefulSetSpec, 

ValidationError(StatefulSet.status): unknown field "availableReplicas" in io.k8s.api.apps.v1.StatefulSetStatus, 

ValidationError(StatefulSet.status.conditions[0]): unknown field "lastUpdateTime" in io.k8s.api.apps.v1.StatefulSetCondition, 

ValidationError(StatefulSet.status.conditions[1]): unknown field "lastUpdateTime" in io.k8s.api.apps.v1.StatefulSetCondition]
</code></pre>

<p>I have attached a persistent volume to this deployment , but i am losing the data whenever the pod is restarted. And now i am trying to convert this existing Deployment Type to statefulSet. I have followed several links , but in vain resulting in errors.</p>

<p>Could you help me.</p>

<p>You have few fields which can't be used in statefulset.</p>
<blockquote>
<p>unknown field &quot;strategy&quot; in io.k8s.api.apps.v1.StatefulSetSpec</p>
</blockquote>
<p>It should be  <a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies" rel="nofollow noreferrer">UpdateStrategy</a></p>
<blockquote>
<p>unknown field &quot;progressDeadlineSeconds&quot; in io.k8s.api.apps.v1.StatefulSetSpec</p>
</blockquote>
<p>As far as I know it's deployment field, it's not available in statefulset.</p>
<blockquote>
<p>ValidationError(StatefulSet.status): unknown field &quot;availableReplicas&quot; in io.k8s.api.apps.v1.StatefulSetStatus,</p>
</blockquote>
<blockquote>
<p>ValidationError(StatefulSet.status.conditions[0]): unknown field &quot;lastUpdateTime&quot; in io.k8s.api.apps.v1.StatefulSetCondition,</p>
</blockquote>
<blockquote>
<p>ValidationError(StatefulSet.status.conditions[1): unknown field &quot;lastUpdateTime&quot; in io.k8s.api.apps.v1.StatefulSetCondition]</p>
</blockquote>
<p>You should delete everything from the <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#deployment-status" rel="nofollow noreferrer">status</a> field. It's created after deployment.</p>
<blockquote>
<p>ValidationError(StatefulSet.spec): missing required field &quot;serviceName&quot; in io.k8s.api.apps.v1.StatefulSetSpec</p>
</blockquote>
<p>You have to add spec.serviceName with name of your service.</p>
<hr />
<p>It should look like this</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    deployment.kubernetes.io/revision: &quot;4&quot;
  labels:
    run: jbpm-server-full
  name: jbpm-server-full
spec:
  replicas: 1
  serviceName: jbpm-server-servicename
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      run: jbpm-server-full
  template:
    metadata:
      labels:
        run: jbpm-server-full
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: jbpm-server-full
        image: jboss/jbpm-server-full:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: jbpm-pv-storage
          mountPath: /k8sdata/jbpmdata
  volumeClaimTemplates:
  - metadata:
      name: jbpm-pv-storage
    spec:
      accessModes: [ &quot;ReadWriteOnce&quot; ]
      storageClassName: &quot;my-storage-class&quot;
      resources:
        requests:
          storage: 1Gi
</code></pre>
<hr />
<p>Links which might be helpful when working with statefulsets.</p>
<ul>
<li><a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/</a></li>
<li><a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/</a></li>
<li><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/statefulset" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/concepts/statefulset</a></li>
</ul>
