Kubernetes livenessProbe / readinessProbe部署问题

时间:2019-07-18 12:52:40

标签: kubernetes readinessprobe

我尝试将pod与livenessProbe和readinessProbe结合使用。 问题是我得到一个错误:应用后:kubectl apply -f test1.yaml

错误:

The Pod "test1" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)....
apiVersion: v1
kind: Pod
metadata:
  name: test1
  labels:
    app: web
spec:
  containers:
    - image: test/test1.0
      name: test1
      ports:
        - containerPort: 8080
          name: http
          protocol: TCP
      livenessProbe:
        httpGet:
          path: /healthy
          port: 8080
        initialDelaySeconds: 5
        timeoutSeconds: 1
        periodSeconds: 10
        failureThreshold: 3
      readinessProbe:
        httpGet:
          path: /ready
          port: 8080
        initialDelaySeconds: 30
        timeoutSeconds: 1
        periodSeconds: 10
        failureThreshold: 3

1 个答案:

答案 0 :(得分:2)

检查是否已经运行了一个名为test1的Pod,当您应用Yaml时,Kubernetes认为您想修改已运行的Pod,并且此操作仅允许更改特定字段,如消息所示。 要检查是否有Pod正在运行,请使用此命令进行检查。

kubectl get pod test1 

然后删除吊舱并应用您的Yaml。

kubectl delete pod test1

kubectl apply -f xxxx