美文网首页K8s安装
2.7、深入pod-调度

2.7、深入pod-调度

作者: yezide | 来源:发表于2019-06-15 17:29 被阅读0次

    kuke-scheduler负责pod的调度
    实际情况中,我们可以自己指定到一些node上

    1、RC、Deployment:全自动调度

    1.1 nodeSelector

    通过给node们设置标签,然后在pod的yaml文件中精确匹配,如果该node未能精确匹配到,则无法调度到

    kubectl label node izm5e4q7wqqi371ly7w5f6z location=north
    
    apiVersion: v1
    kind: ReplicationController 
    metadata:
      name: redis-master
      labels:
        name: redis-master 
    spec:
      replicas: 3
      selector:
        name: redis-master
      template:
        metadata:
          labels:
            name: redis-master
        spec:
          containers:
          - name: master
            image: kubeguide/redis-master
            ports:
            - containerPort: 6379
          nodeSelector:
            location: north
    

    1.2 nodeAffnity

    亲和性调度,可以用in、notIn、Exists、DoesNotExists、Gt、Lt等操作符来匹配,更灵活

    2、DaemonSet调度

    DaemonSet是k8s在1.2新增的一种资源对象,用于管理集群中每个node仅运行一份pod副本

    apiVersion: extensions/v1beta1
    kind: DaemonSet
    metadata:
      name: fluentd-cloud-logging
      namespace: kube-system
      labels:
        k8s-app: fluentd-cloud-logging
    spec:
      template:
        metadata:
          namespace: kube-system
          labels:
            k8s-app: fluentd-cloud-logging
        spec:
          containers:
          - name: fluentd-cloud-logging
            image: gcr.io/google_containers/fluentd-elasticsearch:1.17
            resources:
              limits:
                cpu: 100m
                memory: 200Mi
            env:
            - name: FLUENTD_ARGS
              value: -q
            volumeMounts:
            - name: varlog
              mountPath: /var/log
              readOnly: false
            - name: containers
              mountPath: /var/lib/docker/containers
              readOnly: false
          volumes:
          - name: containers
            hostPath:
              path: /var/lib/docker/containers
          - name: varlog
            hostPath:
              path: /var/log
    
    # 查看daemonset, 要指定namespace
     kubectl get daemonset --namespace=kube-system
    # 查看pods,要指定namespace
    kubectl get po --namespace=kube-system
    

    3、job调度

    。。

    相关文章

      网友评论

        本文标题:2.7、深入pod-调度

        本文链接:https://www.haomeiwen.com/subject/xfbbfctx.html