21天转型容器实战营(五kubernetes pod调度原理分析)

21天转型容器实战营(五kubernetes pod调度原理分析)_第1张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第2张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第3张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第4张图片

Kubernetes中的资源分配

21天转型容器实战营(五kubernetes pod调度原理分析)_第5张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第6张图片

Kubernetes中的高级调度及用法

21天转型容器实战营(五kubernetes pod调度原理分析)_第7张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第8张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第9张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第10张图片

手动调度和DaemonSet

21天转型容器实战营(五kubernetes pod调度原理分析)_第11张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第12张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第13张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第14张图片

调度结果和失败原因分析

21天转型容器实战营(五kubernetes pod调度原理分析)_第15张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第16张图片

多调度器及调度器配置

21天转型容器实战营(五kubernetes pod调度原理分析)_第17张图片

21天转型容器实战营(五kubernetes pod调度原理分析)_第18张图片

 

 

[root@cce-21day-cluster-62954-81jwz ~]# cat pod.yaml 
apiVersion: v1 
kind: Pod 
metadata:
  name: cce21days-xsjzdrxsjzdr
  labels:
    app: nginx 
spec:
  affinity: 
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution: 
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
              - 192.168.98.57 #有EIP的node节点的私网IP地址
  containers:
  - image: 100.125.0.198:20202/f00355482/tanks:v1
    imagePullPolicy: IfNotPresent 
    name: container-0
    resources: {}
  dnsPolicy: ClusterFirst 
  imagePullSecrets:
  - name: default-secret
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}

[root@cce-21day-cluster-62954-81jwz ~]# kubectl get pods -owide
NAME                     READY     STATUS    RESTARTS   AGE       IP            NODE
cce21days-xsjzdrxsjzdr   1/1       Running   0          15m       172.16.0.14   192.168.98.57
[root@cce-21day-cluster-62954-81jwz ~]# kubectl delete pods cce21days-xsjzdrxsjzdr
[root@cce-21day-cluster-62954-81jwz ~]# cat pod-2.yaml 
kind: Deployment
apiVersion: apps/v1
metadata:
  name: cce21days-app1-xsjzdrxsjzdr
  namespace: default
spec:
  replicas: 2
  selector:
   matchLabels:
     app: cce21days-app1-huaweicloud
  template:
    metadata:
      labels:
        app: cce21days-app1-huaweicloud
    spec:
      containers:
        - name: container-0
          image: '100.125.0.198:20202/f00355482/tanks:v1'
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: default-secret
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - cce21days-app1-huaweicloud
              topologyKey: kubernetes.io/hostname
      schedulerName: default-scheduler 
[root@cce-21day-cluster-62954-81jwz ~]# kubectl create -f pod-2.yaml 
deployment "cce21days-app1-xsjzdrxsjzdr" created
[root@cce-21day-cluster-62954-81jwz ~]# kubectl get pods -owide
NAME                                          READY     STATUS    RESTARTS   AGE       IP            NODE
cce21days-app1-xsjzdrxsjzdr-6548fd657-c7sff   1/1       Running   0          9s        172.16.0.15   192.168.98.57
cce21days-app1-xsjzdrxsjzdr-6548fd657-k7mjh   1/1       Running   0          9s        172.16.0.43   192.168.162.50
[root@cce-21day-cluster-62954-81jwz ~]# 
[root@cce-21day-cluster-62954-81jwz ~]# cat pod-3.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    appgroup: ''
  name: cce21days-app2-xsjzdrxsjzdr
  namespace: default
spec:
  replicas: 2
  selector:
    matchLabels:
      app: cce21days-app2-huaweicloud
  template:
    metadata:
      labels:
        app: cce21days-app2-huaweicloud
    spec:
      containers:
        - image: '100.125.0.198:20202/f00355482/tanks:v1'
          name: container-0
      imagePullSecrets:
        - name: default-secret
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app
                    operator: In
                    values:
                      - cce21days-app1-huaweicloud
              topologyKey: kubernetes.io/hostname

[root@cce-21day-cluster-62954-81jwz ~]# kubectl create -f pod-3.yaml 
deployment "cce21days-app2-xsjzdrxsjzdr" created
[root@cce-21day-cluster-62954-81jwz ~]# kubectl get pods -owide
NAME                                          READY     STATUS    RESTARTS   AGE       IP            NODE
cce21days-app1-xsjzdrxsjzdr-6548fd657-c7sff   1/1       Running   0          1m        172.16.0.15   192.168.98.57
cce21days-app1-xsjzdrxsjzdr-6548fd657-k7mjh   1/1       Running   0          1m        172.16.0.43   192.168.162.50
cce21days-app2-xsjzdrxsjzdr-b8d788c6b-nvzfv   1/1       Running   0          4s        172.16.0.44   192.168.162.50
cce21days-app2-xsjzdrxsjzdr-b8d788c6b-tcz56   1/1       Running   0          4s        172.16.0.5    192.168.98.57

[root@cce-21day-cluster-62954-81jwz ~]# kubectl get deployment -owide
NAME                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE       CONTAINERS    IMAGES                                   SELECTOR
cce21days-app1-xsjzdrxsjzdr   2         2         2            2           3m        container-0   100.125.0.198:20202/f00355482/tanks:v1   app=cce21days-app1-huaweicloud
cce21days-app2-xsjzdrxsjzdr   2         2         2            2           1m        container-0   100.125.0.198:20202/f00355482/tanks:v1   app=cce21days-app2-huaweicloud
[root@cce-21day-cluster-62954-81jwz ~]# 
[root@cce-21day-cluster-62954-81jwz ~]# kubectl delete deployment cce21days-app1-xsjzdrxsjzdr cce21days-app2-xsjzdrxsjzdr
deployment "cce21days-app1-xsjzdrxsjzdr" deleted
deployment "cce21days-app2-xsjzdrxsjzdr" deleted
[root@cce-21day-cluster-62954-81jwz ~]# kubectl get deployment -owide
No resources found.
[root@cce-21day-cluster-62954-81jwz ~]# 

 

 

 

 

你可能感兴趣的:(21天转型容器实战营)