gpt4 book ai didi

kubernetes - 在 Kubernetes 中将 Deployment 转换为 StatefulSet

转载 作者:行者123 更新时间:2023-12-05 00:57:08 26 4
gpt4 key购买 nike

我正在尝试在 Kubernetes 中将一个 Deployment 转换为 StatefulSet。下面是我的部署描述。

# 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

错误:

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]

我已将持久卷附加到此部署,但每当重新启动 pod 时我都会丢失数据。现在我正在尝试将这个现有的部署类型转换为 statefulSet。我跟踪了几个链接,但徒劳无功导致错误。

你能帮帮我吗?

最佳答案

你有几个字段不能在 statefulset 中使用。

unknown field "strategy" in io.k8s.api.apps.v1.StatefulSetSpec

应该是UpdateStrategy

unknown field "progressDeadlineSeconds" in io.k8s.api.apps.v1.StatefulSetSpec

据我所知,它是部署字段,它在 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]

您应该删除 status 中的所有内容 field 。它是在部署后创建的。

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

您必须使用您的服务名称添加 spec.serviceName。


应该是这样的

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

在使用有状态集时可能会有所帮助的链接。

关于kubernetes - 在 Kubernetes 中将 Deployment 转换为 StatefulSet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61142132/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com