pingcap / tidb-operator

TiDB operator creates and manages TiDB clusters running in Kubernetes.
https://docs.pingcap.com/tidb-in-kubernetes/
Apache License 2.0
1.22k stars 493 forks source link

more tests for host network feature #1042

Closed cofyc closed 4 years ago

cofyc commented 4 years ago

Feature Request

Is your feature request related to a problem? Please describe:

see https://github.com/pingcap/tidb-operator/pull/1032.

Describe the feature you'd like:

we need more tests for host network feature

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

cofyc commented 4 years ago

found an e2e bug in https://internal.pingcap.net/idc-jenkins/blue/organizations/jenkins/operator_ghpr_e2e_test_kind/detail/operator_ghpr_e2e_test_kind/588/pipeline/

it's possible that a TiKV pod has hostNetwork set to true but dnsPolicy is ClusterFirst, e.g.

apiVersion: v1
kind: Pod
metadata:
  annotations:
    pingcap.com/last-applied-configuration: '{"volumes":[{"name":"annotations","downwardAPI":{"items":[{"path":"annotations","fieldRef":{"fieldPath":"metadata.annotations"}}]}},{"name":"config","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"config-file","path":"tikv.toml"}]}},{"name":"startup-script","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"startup-script","path":"tikv_start_script.sh"}]}}],"containers":[{"name":"tikv","image":"pingcap/tikv:v3.0.2","command":["/bin/sh","/usr/local/bin/tikv_start_script.sh"],"ports":[{"name":"server","containerPort":20160,"protocol":"TCP"}],"env":[{"name":"NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"CLUSTER_NAME","value":"cluster1"},{"name":"HEADLESS_SERVICE_NAME","value":"cluster1-tikv-peer"},{"name":"CAPACITY","value":"0"},{"name":"TZ","value":"UTC"}],"resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"200m","memory":"200Mi"}},"volumeMounts":[{"name":"annotations","readOnly":true,"mountPath":"/etc/podinfo"},{"name":"tikv","mountPath":"/var/lib/tikv"},{"name":"config","readOnly":true,"mountPath":"/etc/tikv"},{"name":"startup-script","readOnly":true,"mountPath":"/usr/local/bin"}],"imagePullPolicy":"IfNotPresent","securityContext":{"privileged":false}}],"restartPolicy":"Always","dnsPolicy":"ClusterFirst","securityContext":{},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":50,"podAffinityTerm":{"labelSelector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1"}},"namespaces":["e2e"],"topologyKey":"rack"}}]}},"schedulerName":"tidb-scheduler"}'
    prometheus.io/path: /metrics
    prometheus.io/port: "20180"
    prometheus.io/scrape: "true"
  creationTimestamp: 2019-10-30T03:13:33Z
  generateName: cluster1-tikv-
  labels:
    app.kubernetes.io/component: tikv
    app.kubernetes.io/instance: cluster1
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
    controller-revision-hash: cluster1-tikv-685dbb976d
    statefulset.kubernetes.io/pod-name: cluster1-tikv-1
    tidb.pingcap.com/cluster-id: "6753421464904045947"
    tidb.pingcap.com/store-id: "4"
  name: cluster1-tikv-1
  namespace: e2e
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: StatefulSet
    name: cluster1-tikv
    uid: 37685ebf-fabf-11e9-9445-0242ac110003
  resourceVersion: "14380"
  selfLink: /api/v1/namespaces/e2e/pods/cluster1-tikv-1
  uid: 419a5db0-fac3-11e9-9445-0242ac110003
spec:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchLabels:
              app.kubernetes.io/component: tikv
              app.kubernetes.io/instance: cluster1
          namespaces:
          - e2e
          topologyKey: rack
        weight: 50
  containers:
  - command:
    - /bin/sh
    - /usr/local/bin/tikv_start_script.sh
    env:
    - name: NAMESPACE
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.namespace
    - name: POD_NAME
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.name
    - name: CLUSTER_NAME
      value: cluster1
    - name: HEADLESS_SERVICE_NAME
      value: cluster1-tikv-peer
    - name: CAPACITY
      value: "0"
    - name: TZ
      value: UTC
    image: pingcap/tikv:v3.0.2
    imagePullPolicy: IfNotPresent
    name: tikv
    ports:
    - containerPort: 20160
      hostPort: 20160
      name: server
      protocol: TCP
    resources:
      limits:
        cpu: "2"
        memory: 4Gi
      requests:
        cpu: 200m
        memory: 200Mi
    securityContext:
      privileged: false
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /etc/podinfo
      name: annotations
      readOnly: true
    - mountPath: /var/lib/tikv
      name: tikv
    - mountPath: /etc/tikv
      name: config
      readOnly: true
    - mountPath: /usr/local/bin
      name: startup-script
      readOnly: true
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-mgffh
      readOnly: true
  dnsPolicy: ClusterFirst
  hostNetwork: true
  hostname: cluster1-tikv-1
  nodeName: kind-worker4
  priority: 0
  restartPolicy: Always
  schedulerName: tidb-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  subdomain: cluster1-tikv-peer
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: tikv
    persistentVolumeClaim:
      claimName: tikv-cluster1-tikv-1
  - downwardAPI:
      defaultMode: 420
      items:
      - fieldRef:
          apiVersion: v1
          fieldPath: metadata.annotations
        path: annotations
    name: annotations
  - configMap:
      defaultMode: 420
      items:
      - key: config-file
        path: tikv.toml
      name: cluster1-tikv-321b2c5c
    name: config
  - configMap:
      defaultMode: 420
      items:
      - key: startup-script
        path: tikv_start_script.sh
      name: cluster1-tikv-321b2c5c
    name: startup-script
  - name: default-token-mgffh
    secret:
      defaultMode: 420
      secretName: default-token-mgffh
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: 2019-10-30T03:13:34Z
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: 2019-10-30T03:13:39Z
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: 2019-10-30T03:13:39Z
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: 2019-10-30T03:13:34Z
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: containerd://a0fb14fef61df217817c739e14d767dd68c607214de71c51a5d5f4deff07e2a2
    image: docker.io/pingcap/tikv:v3.0.2
    imageID: docker.io/pingcap/tikv@sha256:fb86968df444c77f31950fb910be5377b8ba15c8b94b1af52b155804910c2e7a
    lastState: {}
    name: tikv
    ready: true
    restartCount: 0
    state:
      running:
        startedAt: 2019-10-30T03:13:38Z
  hostIP: 172.17.0.5
  phase: Running
  podIP: 172.17.0.5
  qosClass: Burstable
  startTime: 2019-10-30T03:13:34Z
apiVersion: apps/v1
data:
  spec:
    template:
      $patch: replace
      metadata:
        annotations:
          pingcap.com/last-applied-configuration: '{"volumes":[{"name":"annotations","downwardAPI":{"items":[{"path":"annotations","fieldRef":{"fieldPath":"metadata.annotations"}}]}},{"name":"config","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"config-file","path":"tikv.toml"}]}},{"name":"startup-script","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"startup-script","path":"tikv_start_script.sh"}]}}],"containers":[{"name":"tikv","image":"pingcap/tikv:v3.0.2","command":["/bin/sh","/usr/local/bin/tikv_start_script.sh"],"ports":[{"name":"server","containerPort":20160,"protocol":"TCP"}],"env":[{"name":"NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"CLUSTER_NAME","value":"cluster1"},{"name":"HEADLESS_SERVICE_NAME","value":"cluster1-tikv-peer"},{"name":"CAPACITY","value":"0"},{"name":"TZ","value":"UTC"}],"resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"200m","memory":"200Mi"}},"volumeMounts":[{"name":"annotations","readOnly":true,"mountPath":"/etc/podinfo"},{"name":"tikv","mountPath":"/var/lib/tikv"},{"name":"config","readOnly":true,"mountPath":"/etc/tikv"},{"name":"startup-script","readOnly":true,"mountPath":"/usr/local/bin"}],"imagePullPolicy":"IfNotPresent","securityContext":{"privileged":false}}],"restartPolicy":"Always","dnsPolicy":"ClusterFirst","securityContext":{},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":50,"podAffinityTerm":{"labelSelector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1"}},"namespaces":["e2e"],"topologyKey":"rack"}}]}},"schedulerName":"tidb-scheduler"}'
          prometheus.io/path: /metrics
          prometheus.io/port: "20180"
          prometheus.io/scrape: "true"
        creationTimestamp: null
        labels:
          app.kubernetes.io/component: tikv
          app.kubernetes.io/instance: cluster1
          app.kubernetes.io/managed-by: tidb-operator
          app.kubernetes.io/name: tidb-cluster
      spec:
        affinity:
          podAntiAffinity:
            preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app.kubernetes.io/component: tikv
                    app.kubernetes.io/instance: cluster1
                namespaces:
                - e2e
                topologyKey: rack
              weight: 50
        containers:
        - command:
          - /bin/sh
          - /usr/local/bin/tikv_start_script.sh
          env:
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.namespace
          - name: POD_NAME
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.name
          - name: CLUSTER_NAME
            value: cluster1
          - name: HEADLESS_SERVICE_NAME
            value: cluster1-tikv-peer
          - name: CAPACITY
            value: "0"
          - name: TZ
            value: UTC
          image: pingcap/tikv:v3.0.2
          imagePullPolicy: IfNotPresent
          name: tikv
          ports:
          - containerPort: 20160
            name: server
            protocol: TCP
          resources:
            limits:
              cpu: "2"
              memory: 4Gi
            requests:
              cpu: 200m
              memory: 200Mi
          securityContext:
            privileged: false
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
          - mountPath: /etc/podinfo
            name: annotations
            readOnly: true
          - mountPath: /var/lib/tikv
            name: tikv
          - mountPath: /etc/tikv
            name: config
            readOnly: true
          - mountPath: /usr/local/bin
            name: startup-script
            readOnly: true
        dnsPolicy: ClusterFirst
        restartPolicy: Always
        schedulerName: tidb-scheduler
        securityContext: {}
        terminationGracePeriodSeconds: 30
        volumes:
        - downwardAPI:
            defaultMode: 420
            items:
            - fieldRef:
                apiVersion: v1
                fieldPath: metadata.annotations
              path: annotations
          name: annotations
        - configMap:
            defaultMode: 420
            items:
            - key: config-file
              path: tikv.toml
            name: cluster1-tikv-321b2c5c
          name: config
        - configMap:
            defaultMode: 420
            items:
            - key: startup-script
              path: tikv_start_script.sh
            name: cluster1-tikv-321b2c5c
          name: startup-script
kind: ControllerRevision
metadata:
  annotations:
    pingcap.com/last-applied-configuration: '{"replicas":4,"selector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1","app.kubernetes.io/managed-by":"tidb-operator","app.kubernetes.io/name":"tidb-cluster"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1","app.kubernetes.io/managed-by":"tidb-operator","app.kubernetes.io/name":"tidb-cluster"},"annotations":{"prometheus.io/path":"/metrics","prometheus.io/port":"20180","prometheus.io/scrape":"true"}},"spec":{"volumes":[{"name":"annotations","downwardAPI":{"items":[{"path":"annotations","fieldRef":{"fieldPath":"metadata.annotations"}}]}},{"name":"config","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"config-file","path":"tikv.toml"}]}},{"name":"startup-script","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"startup-script","path":"tikv_start_script.sh"}]}}],"containers":[{"name":"tikv","image":"pingcap/tikv:v3.0.2","command":["/bin/sh","/usr/local/bin/tikv_start_script.sh"],"ports":[{"name":"server","containerPort":20160,"protocol":"TCP"}],"env":[{"name":"NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"CLUSTER_NAME","value":"cluster1"},{"name":"HEADLESS_SERVICE_NAME","value":"cluster1-tikv-peer"},{"name":"CAPACITY","value":"0"},{"name":"TZ","value":"UTC"}],"resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"200m","memory":"200Mi"}},"volumeMounts":[{"name":"annotations","readOnly":true,"mountPath":"/etc/podinfo"},{"name":"tikv","mountPath":"/var/lib/tikv"},{"name":"config","readOnly":true,"mountPath":"/etc/tikv"},{"name":"startup-script","readOnly":true,"mountPath":"/usr/local/bin"}],"imagePullPolicy":"IfNotPresent","securityContext":{"privileged":false}}],"restartPolicy":"Always","dnsPolicy":"ClusterFirst","securityContext":{},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":50,"podAffinityTerm":{"labelSelector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1"}},"namespaces":["e2e"],"topologyKey":"rack"}}]}},"schedulerName":"tidb-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"tikv","creationTimestamp":null},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"local-storage","dataSource":null},"status":{"phase":"Pending"}}],"serviceName":"cluster1-tikv-peer","podManagementPolicy":"Parallel","updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":4}},"revisionHistoryLimit":10}'
  creationTimestamp: 2019-10-30T02:56:47Z
  labels:
    app.kubernetes.io/component: tikv
    app.kubernetes.io/instance: cluster1
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
    controller.kubernetes.io/hash: 685dbb976d
  name: cluster1-tikv-685dbb976d
  namespace: e2e
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: StatefulSet
    name: cluster1-tikv
    uid: 37685ebf-fabf-11e9-9445-0242ac110003
  resourceVersion: "14712"
  selfLink: /apis/apps/v1/namespaces/e2e/controllerrevisions/cluster1-tikv-685dbb976d
  uid: e9a96d37-fac0-11e9-9445-0242ac110003
revision: 4
apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    pingcap.com/last-applied-configuration: '{"replicas":4,"selector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1","app.kubernetes.io/managed-by":"tidb-operator","app.kubernetes.io/name":"tidb-cluster"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1","app.kubernetes.io/managed-by":"tidb-operator","app.kubernetes.io/name":"tidb-cluster"},"annotations":{"prometheus.io/path":"/metrics","prometheus.io/port":"20180","prometheus.io/scrape":"true"}},"spec":{"volumes":[{"name":"annotations","downwardAPI":{"items":[{"path":"annotations","fieldRef":{"fieldPath":"metadata.annotations"}}]}},{"name":"config","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"config-file","path":"tikv.toml"}]}},{"name":"startup-script","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"startup-script","path":"tikv_start_script.sh"}]}}],"containers":[{"name":"tikv","image":"pingcap/tikv:v3.0.2","command":["/bin/sh","/usr/local/bin/tikv_start_script.sh"],"ports":[{"name":"server","containerPort":20160,"protocol":"TCP"}],"env":[{"name":"NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"CLUSTER_NAME","value":"cluster1"},{"name":"HEADLESS_SERVICE_NAME","value":"cluster1-tikv-peer"},{"name":"CAPACITY","value":"0"},{"name":"TZ","value":"UTC"}],"resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"200m","memory":"200Mi"}},"volumeMounts":[{"name":"annotations","readOnly":true,"mountPath":"/etc/podinfo"},{"name":"tikv","mountPath":"/var/lib/tikv"},{"name":"config","readOnly":true,"mountPath":"/etc/tikv"},{"name":"startup-script","readOnly":true,"mountPath":"/usr/local/bin"}],"imagePullPolicy":"IfNotPresent","securityContext":{"privileged":false}}],"restartPolicy":"Always","dnsPolicy":"ClusterFirst","securityContext":{},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":50,"podAffinityTerm":{"labelSelector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1"}},"namespaces":["e2e"],"topologyKey":"rack"}}]}},"schedulerName":"tidb-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"tikv","creationTimestamp":null},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"local-storage","dataSource":null},"status":{"phase":"Pending"}}],"serviceName":"cluster1-tikv-peer","podManagementPolicy":"Parallel","updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":5}},"revisionHistoryLimit":10}'
  creationTimestamp: 2019-10-30T02:44:38Z
  generation: 17
  labels:
    app.kubernetes.io/component: tikv
    app.kubernetes.io/instance: cluster1
    app.kubernetes.io/managed-by: tidb-operator
    app.kubernetes.io/name: tidb-cluster
  name: cluster1-tikv
  namespace: e2e
  ownerReferences:
  - apiVersion: pingcap.com/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: TidbCluster
    name: cluster1
    uid: 07fd4614-fabf-11e9-9445-0242ac110003
  resourceVersion: "15285"
  selfLink: /apis/apps/v1/namespaces/e2e/statefulsets/cluster1-tikv
  uid: 37685ebf-fabf-11e9-9445-0242ac110003
spec:
  podManagementPolicy: Parallel
  replicas: 4
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/component: tikv
      app.kubernetes.io/instance: cluster1
      app.kubernetes.io/managed-by: tidb-operator
      app.kubernetes.io/name: tidb-cluster
  serviceName: cluster1-tikv-peer
  template:
    metadata:
      annotations:
        pingcap.com/last-applied-configuration: '{"volumes":[{"name":"annotations","downwardAPI":{"items":[{"path":"annotations","fieldRef":{"fieldPath":"metadata.annotations"}}]}},{"name":"config","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"config-file","path":"tikv.toml"}]}},{"name":"startup-script","configMap":{"name":"cluster1-tikv-321b2c5c","items":[{"key":"startup-script","path":"tikv_start_script.sh"}]}}],"containers":[{"name":"tikv","image":"pingcap/tikv:v3.0.2","command":["/bin/sh","/usr/local/bin/tikv_start_script.sh"],"ports":[{"name":"server","containerPort":20160,"protocol":"TCP"}],"env":[{"name":"NAMESPACE","valueFrom":{"fieldRef":{"fieldPath":"metadata.namespace"}}},{"name":"POD_NAME","valueFrom":{"fieldRef":{"fieldPath":"metadata.name"}}},{"name":"CLUSTER_NAME","value":"cluster1"},{"name":"HEADLESS_SERVICE_NAME","value":"cluster1-tikv-peer"},{"name":"CAPACITY","value":"0"},{"name":"TZ","value":"UTC"}],"resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"200m","memory":"200Mi"}},"volumeMounts":[{"name":"annotations","readOnly":true,"mountPath":"/etc/podinfo"},{"name":"tikv","mountPath":"/var/lib/tikv"},{"name":"config","readOnly":true,"mountPath":"/etc/tikv"},{"name":"startup-script","readOnly":true,"mountPath":"/usr/local/bin"}],"imagePullPolicy":"IfNotPresent","securityContext":{"privileged":false}}],"restartPolicy":"Always","dnsPolicy":"ClusterFirst","securityContext":{},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":50,"podAffinityTerm":{"labelSelector":{"matchLabels":{"app.kubernetes.io/component":"tikv","app.kubernetes.io/instance":"cluster1"}},"namespaces":["e2e"],"topologyKey":"rack"}}]}},"schedulerName":"tidb-scheduler"}'
        prometheus.io/path: /metrics
        prometheus.io/port: "20180"
        prometheus.io/scrape: "true"
      creationTimestamp: null
      labels:
        app.kubernetes.io/component: tikv
        app.kubernetes.io/instance: cluster1
        app.kubernetes.io/managed-by: tidb-operator
        app.kubernetes.io/name: tidb-cluster
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/component: tikv
                  app.kubernetes.io/instance: cluster1
              namespaces:
              - e2e
              topologyKey: rack
            weight: 50
      containers:
      - command:
        - /bin/sh
        - /usr/local/bin/tikv_start_script.sh
        env:
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        - name: POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        - name: CLUSTER_NAME
          value: cluster1
        - name: HEADLESS_SERVICE_NAME
          value: cluster1-tikv-peer
        - name: CAPACITY
          value: "0"
        - name: TZ
          value: UTC
        image: pingcap/tikv:v3.0.2
        imagePullPolicy: IfNotPresent
        name: tikv
        ports:
        - containerPort: 20160
          name: server
          protocol: TCP
        resources:
          limits:
            cpu: "2"
            memory: 4Gi
          requests:
            cpu: 200m
            memory: 200Mi
        securityContext:
          privileged: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /etc/podinfo
          name: annotations
          readOnly: true
        - mountPath: /var/lib/tikv
          name: tikv
        - mountPath: /etc/tikv
          name: config
          readOnly: true
        - mountPath: /usr/local/bin
          name: startup-script
          readOnly: true
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: tidb-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - downwardAPI:
          defaultMode: 420
          items:
          - fieldRef:
              apiVersion: v1
              fieldPath: metadata.annotations
            path: annotations
        name: annotations
      - configMap:
          defaultMode: 420
          items:
          - key: config-file
            path: tikv.toml
          name: cluster1-tikv-321b2c5c
        name: config
      - configMap:
          defaultMode: 420
          items:
          - key: startup-script
            path: tikv_start_script.sh
          name: cluster1-tikv-321b2c5c
        name: startup-script
  updateStrategy:
    rollingUpdate:
      partition: 5
    type: RollingUpdate
  volumeClaimTemplates:
  - metadata:
      creationTimestamp: null
      name: tikv
    spec:
      accessModes:
      - ReadWriteOnce
      dataSource: null
      resources:
        requests:
          storage: 10Gi
      storageClassName: local-storage
    status:
      phase: Pending
status:
  collisionCount: 0
  currentReplicas: 2
  currentRevision: cluster1-tikv-685dbb976d
  observedGeneration: 17
  readyReplicas: 4
  replicas: 4
  updateRevision: cluster1-tikv-685dbb976d
  updatedReplicas: 2
cofyc commented 4 years ago
[root@localhost ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:54:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.10", GitCommit:"e3c134023df5dea457638b614ee17ef234dc34a6", GitTreeState:"clean", BuildDate:"2019-08-20T19:46:37Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
cofyc commented 4 years ago

I guess the root cause is https://github.com/kubernetes/kubernetes/issues/78420 and fixed by https://github.com/kubernetes/kubernetes/pull/78853.

cofyc commented 4 years ago

this bug has been fixed in Kubernetes 1.13+

cofyc commented 4 years ago

right now, we should disable the host network test in 1.12.x cluster

we can add some unit tests to verify that hostNetwork fields can be set correctly