0

kubernetes 版本:1.21.1 主机:Linux CO4AEAP000110FB 5.0.0-1032-azure #34-Ubuntu

我应用了一个带有“OnDelete”的守护进程作为更新策略。这会在两个节点中运行 pod。我将 nodeAffinity 更新为不在其中一个节点中部署(排除一个节点)并应用更新的守护程序集(kubectl apply -f ...)

期望: daemonet pods 继续在两个节点中运行,即使一个被添加到反关联中,因为 OnDelete 应该只在 pod 删除时起作用。后来当我手动删除excluded-node中的pod时,我希望k8s不会重新部署

发生了什么: k8s 立即终止了排除节点上的 pod。

我什至尝试过“kubectl cascade=orphan apply -f”

守护进程:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sonic-test-container
  labels:
    app: k8s-test-container
spec:
  selector:
    matchLabels:
      app: k8s-test-container
  updateStrategy:
    type: OnDelete
  template:
    metadata:
      labels:
        app: k8s-test-container
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: "test_enabled"
                operator: "In"
                values:
                - "true"
              - key: "kubernetes.io/hostname"
                operator: NotIn
                values:
                - str-s6000-acs-8
      hostname: sonic
      hostNetwork: true
      containers:
      - name: sonic-test-container
        image: sonicanalytics.azurecr.io/sonic-dockers/any/docker-sonic_test_container:20210908.0129
        tty: true
        env:
        securityContext:
          privileged: true
        volumeMounts:
        - name: sonic-scripts
          mountPath: /usr/share/sonic/scripts
          readOnly: true
        imagePullPolicy: IfNotPresent
      volumes:
      - name: sonic-scripts
        hostPath:
          path: /usr/share/sonic/scripts

任何提示将非常方便?

谢谢!

4

0 回答 0