• Kubernetes 调度器


    1、Kubernetes 调度器 - 调度说明
      https://blog.csdn.net/wtl1992/article/details/104982548
    2、Kubernetes 调度器 - 调度亲和性
       https://blog.csdn.net/wtl1992/article/details/104983234
    3、Kubernetes 调度器 - 污点
      https://blog.csdn.net/wtl1992/article/details/105041339
    4、Kubernetes 调度器 - 固定节点
      https://blog.csdn.net/wtl1992/article/details/105043138
     
    案例:

      节点亲和性
        pod.spec.nodeAffinity
        preferredDuringSchedulingIgnoredDuringExecution:软策略
        requiredDuringSchedulingIgnoredDuringExecution:硬策略

    指定到 kubernetes.io/hostname=xgcloud-ops-k8s-cluster-2.novalocal  有这个标签的机器


     requiredDuringSchedulingIgnoredDuringExecution:硬策略

    [root@xgcloud-ops-k8s-cluster-4 nodeaff]# cat pod2.yaml 
    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        version: v1
    spec:
      containers: 
      -  name: app
         image: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-2.novalocal

     preferredDuringSchedulingIgnoredDuringExecution:软策略

    [root@xgcloud-ops-k8s-cluster-4 nodeaff]# cat pod3.yaml 
    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod3
      labels:
        app: myapp-pod3
        version: v1
    spec:
      containers: 
      -  name: myapp-pod3
         image: nginx
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-5.novalocal

    kubectl apply -f pod3.yaml

    kubectl get pod -o wide

     指定了xgcloud-ops-k8s-cluster-5.novalocal,没有这个node,但是还是成功running,调度到了 xgcloud-ops-k8s-cluster-1.novalocal

    preferredDuringSchedulingIgnoredDuringExecution:软策略
    requiredDuringSchedulingIgnoredDuringExecution:硬策略

    一起进行配置:

    [root@xgcloud-ops-k8s-cluster-4 nodeaff]# cat pod4.yaml 
    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod4
      labels:
        app: myapp-pod4
        version: v1
    spec:
      containers: 
      -  name: myapp-pod4
         image: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-3.novalocal
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-5.novalocal

    kubectl apply -f pod4.yaml

    kubectl describe pod/myapp-pod4

    kubectl get pod -o wide

     pod亲和性

    pod.spec.affiffiffinity.podAffiffiffinity/podAntiAffiffiffinity
     
    没找到别的容器,暂时不测了,用法差不多

     

     

    跑一个pod2

    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        version: v1
    spec:
      containers: 
      -  name: app
         image: nginx
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - xgcloud-ops-k8s-cluster-2.novalocal

    跑一个pod3跟他pod亲和

    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod3
      labels:
        app: myapp-pod3
        version: v1
    spec:
      containers: 
      - command:
        - "sleep"
        - "3600"
        name: myapp-pod3
        image: busybox
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - myapp
            topologyKey: kubernetes.io/hostname 
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            podAffinityTerm:
              labelSelector:
                matchExpressions:      
                - key: app
                  operator: In      
                  values:       
                  - myapp-pod4       
              topologyKey: kubernetes.io/hostname

     

  • 相关阅读:
    渗透测试中的文件传输通道1- cmd下下载文件
    内网渗透常用命令
    技术剖析中国菜刀原理
    win8 iis安装及网站发布
    C++与C的区别一
    C语言实现单链表,并完成链表常用API函数
    C语言实现数组及链表的快速排序
    使用C语言封装数组,动态实现增删改查
    C语言中静态断言的使用
    二分查找法C语言实现
  • 原文地址:https://www.cnblogs.com/litzhiai/p/14963486.html
Copyright © 2020-2023  润新知