ani*_*mar 2 kubernetes kubectl
我正在尝试将一个部署转换为 Kubernetes 中的 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
Run Code Online (Sandbox Code Playgroud)
错误:
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]
Run Code Online (Sandbox Code Playgroud)
我已将持久卷附加到此部署,但每当 pod 重新启动时,我都会丢失数据。现在我正在尝试将此现有部署类型转换为 statefulSet。我遵循了几个链接,但徒劳地导致错误。
你可以帮帮我吗。
您有几个不能在 statefulset 中使用的字段。
io.k8s.api.apps.v1.StatefulSetSpec 中的未知字段“策略”
应该是 UpdateStrategy
io.k8s.api.apps.v1.StatefulSetSpec 中的未知字段“progressDeadlineSeconds”
据我所知,它是部署领域,它在 statefulset 中不可用。
ValidationError(StatefulSet.status): io.k8s.api.apps.v1.StatefulSetStatus 中的未知字段“availableReplicas”,
ValidationError(StatefulSet.status.conditions[0]): io.k8s.api.apps.v1.StatefulSetCondition 中的未知字段“lastUpdateTime”,
ValidationError(StatefulSet.status.conditions[1): io.k8s.api.apps.v1.StatefulSetCondition 中的未知字段“lastUpdateTime”]
您应该从状态字段中删除所有内容。它是在部署后创建的。
ValidationError(StatefulSet.spec):io.k8s.api.apps.v1.StatefulSetSpec 中缺少必填字段“serviceName”
您必须添加 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
Run Code Online (Sandbox Code Playgroud)
使用 statefulsets 时可能有用的链接。
| 归档时间: |
|
| 查看次数: |
4255 次 |
| 最近记录: |