K8S Scheduler-玩转 Pod 调度

基础

查看运行中的pod的状态

[hemei@master ~]$ kubectl get pods
NAME                                               READY   STATUS    RESTARTS   AGE
nfs-subdir-external-provisioner-6dcc58bb4b-8fc84   1/1     Running   11         150d
tomcat-demo-54cbbcffdb-2hn5h                       1/1     Running   0          15h
[hemei@master ~]$ kubectl get pods tomcat-demo-54cbbcffdb-2hn5h -o yaml

查看结果:

[heimei@master ~]$ kubectl get pods tomcat-demo-54cbbcffdb-2hn5h -o yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    cni.projectcalico.org/containerID: 7f3cd0a77dcc6b0e9ad63c56b2c437a85a7c48b7fe48a19d49d009c209107532
    cni.projectcalico.org/podIP: 172.16.123.32/32
    cni.projectcalico.org/podIPs: 172.16.123.32/32
  creationTimestamp: "2022-05-01T08:40:19Z"
  generateName: tomcat-demo-54cbbcffdb-
  labels:
    app: tomcat-demo
    pod-template-hash: 54cbbcffdb
  name: tomcat-demo-54cbbcffdb-2hn5h
  namespace: default
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicaSet
    name: tomcat-demo-54cbbcffdb
    uid: 44f7c932-2fd4-4adf-8342-ce7278f83707
  resourceVersion: "63099769"
  uid: e719842b-6d9c-40b2-adab-51d33fc4b47f
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/liuyi01/tomcat:8.0.51-alpine
    imagePullPolicy: IfNotPresent
    name: tomcat-demo
    ports:
    - containerPort: 8080
      protocol: TCP
    resources: {}
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-6zr8z
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: work2
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  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: kube-api-access-6zr8z
    projected:
      defaultMode: 420
      sources:
      - serviceAccountToken:
          expirationSeconds: 3607
          path: token
      - configMap:
          items:
          - key: ca.crt
            path: ca.crt
          name: kube-root-ca.crt
      - downwardAPI:
          items:
          - fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
            path: namespace
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2022-05-01T08:40:19Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2022-05-01T08:40:35Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2022-05-01T08:40:35Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2022-05-01T08:40:19Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://13bfe7fd94f1a006d10a001b5c11b9fe5cd87c65f8ec7385dda2d52115fae79b
    image: registry.cn-hangzhou.aliyuncs.com/liuyi01/tomcat:8.0.51-alpine
    imageID: docker-pullable://registry.cn-hangzhou.aliyuncs.com/liuyi01/tomcat@sha256:f72d0063ec5d015364e32a2e63a3316b7e09e3b29764ac1795d215357771e62c
    lastState: {}
    name: tomcat-demo
    ready: true
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2022-05-01T08:40:34Z"
  hostIP: 192.168.1.63
  phase: Running
  podIP: 172.16.123.32
  podIPs:
  - ip: 172.16.123.32
  qosClass: BestEffort
  startTime: "2022-05-01T08:40:19Z"
[heimei@master ~]$ 

file

file

affinity 亲和性(节点亲和性,pod 亲和性)

kubectl get nodes --show-labels

查看正在运行的原因:

kubectl describe tomcat-demo-54cbbcffdb-2hn5h pods -n dev

相关文章:
B站|玩转Pod调度

为者常成,行者常至