Reputation: 101
I am trying to convert one Deployment to StatefulSet in Kubernetes. Below is my Deployment description .
# 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
Error:
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]
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.
Could you help me.
Upvotes: 4
Views: 17147
Reputation: 8840
You have few fields which can't be used in statefulset.
unknown field "strategy" in io.k8s.api.apps.v1.StatefulSetSpec
It should be UpdateStrategy
unknown field "progressDeadlineSeconds" in io.k8s.api.apps.v1.StatefulSetSpec
As far as I know it's deployment field, it's not available in statefulset.
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]
You should delete everything from the status field. It's created after deployment.
ValidationError(StatefulSet.spec): missing required field "serviceName" in io.k8s.api.apps.v1.StatefulSetSpec
You have to add spec.serviceName with name of your service.
It should look like this
apiVersion: apps/v1
kind: StatefulSet
metadata:
annotations:
deployment.kubernetes.io/revision: "4"
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: [ "ReadWriteOnce" ]
storageClassName: "my-storage-class"
resources:
requests:
storage: 1Gi
Links which might be helpful when working with statefulsets.
Upvotes: 8