• Pod控制器之DaemonSet


    Pod控制器之DaemonSet

    简介:
    DaemonSet 确保全部(或者一些)Node 上运行一个 Pod 的副本。当有 Node加入集群时,也会为他们新增一个 Pod 。当有 Node 从集群移除时,这些 Pod也会被回收。删除 DaemonSet将会删除它创建的所有 Pod
    使用 DaemonSet 的一些典型用法:
    运行集群存储 daemon,例如在每个 Node 上运行 glusterd 、 ceph
    在每个 Node 上运行日志收集 daemon,例如 fluentd 、 logstash
    在每个 Node 上运行监控 daemon,例如 Prometheus Node Exporter、 collectd 、Datadog 代理、New Relic 代理,或 Ganglia gmond



     

    创建一个DaemonSet

    cat >ds.yaml<<-EOF
    apiVersion: apps/v1
    kind: DaemonSet
    metadata: 
      name: nginx-ds
      namespace: default
    spec:
      selector:
        matchLabels:
          app: nginx 
          release: stable
      template:
        metadata:
          labels:
            app: nginx 
            release: stable
        spec:
          containers:
          - name: nginx 
            image: nginx 
            imagePullPolicy: IfNotPresent
            ports:
            - name: http
              containerPort: 80
        
    
    EOF
    root@ubuntu:~/tenant#  kubectl get pods  -o wide
    NAME                             READY   STATUS      RESTARTS   AGE     IP               NODE      NOMINATED NODE   READINESS GATES
    busybox                          1/1     Running     0          36m     10.244.129.145   centos7   <none>           <none>
    example-foo-54dc4db9fc-lqz9j     1/1     Running     0          19d     10.244.29.26     bogon     <none>           <none>
    job-1-nginx-0                    0/1     Completed   0          22d     10.244.29.19     bogon     <none>           <none>
    nginx-ds-f7sjm                   1/1     Running     0          48s     10.244.29.23     bogon     <none>           <none>
    nginx-ds-ldlrq                   1/1     Running     0          48s     10.244.41.1      cloud     <none>           <none>
    nginx-ds-p8nqz                   1/1     Running     0          48s     10.244.243.195   ubuntu    <none>           <none>
    nginx-ds-xrt8b                   1/1     Running     0          48s     10.244.129.146   centos7   <none>           <none>
    test-job-default-nginx-0         1/1     Running     0          14d     10.244.29.3      bogon     <none>           <none>
    test-job-default-nginx-1         1/1     Running     0          14d     10.244.29.9      bogon     <none>           <none>
    test-job-default-nginx-2         1/1     Running     0          14d     10.244.29.19     bogon     <none>           <none>
    test-job-default-nginx-3         1/1     Running     0          14d     10.244.29.63     bogon     <none>           <none>
    test-job-default-nginx-4         1/1     Running     0          14d     10.244.29.1      bogon     <none>           <none>
    test-job-default-nginx-5         1/1     Running     0          14d     10.244.29.2      bogon     <none>           <none>
    test-job-v2-default-nginx-v2-0   1/1     Running     0          14d     10.244.29.20     bogon     <none>           <none>
    web-0                            1/1     Running     0          3h12m   10.244.129.142   centos7   <none>           <none>
    web-1                            1/1     Running     0          3h6m    10.244.129.143   centos7   <none>           <none>
    root@ubuntu:~/tenant# 

    指定 Node 节点

    DaemonSet 会忽略 Node 的 unschedulable 状态,有两种方式来指定 Pod 只运行在指定的 Node 节点上:

    • nodeSelector:只调度到匹配指定 label 的 Node 上
    • nodeAffinity:功能更丰富的 Node 选择器,比如支持集合操作
    • podAffinity:调度到满足条件的 Pod 所在的 Node 上

    nodeSelector 示例

    DaemonSet 会忽略 Node 的 unschedulable 状态,有两种方式来指定 Pod 只运行在指定的 Node 节点上:

    nodeSelector:只调度到匹配指定 label 的 Node 上
    nodeSelector 示例
    1,首先给 Node 打上标签

    kubectl label nodes node-01 disktype=ssd
    

    2,然后在 daemonset 中指定 nodeSelector 为 disktype=ssd:

    spec:
      nodeSelector:
        disktype: ssd


     
  • 相关阅读:
    bug-- java.lang.RuntimeException: Type “Klass*"
    ThreadPoolExecutor源码分析二
    ThreadPoolExecutor源码分析一
    java动态代理框架
    liunx 中一个命令可以检测 ps -C java --no-heading| wc -l 一般用于shell脚步编写用
    log4j.properties 使用说明
    图文详解MyEclipse中新建Maven webapp项目的步骤(很详细)
    MySQL高可用性之Keepalived+Mysql(双主热备)
    使用cglib动态创建类,添加方法
    2017年5月5日 星红桉liunx动手实践mysql 主主双机热备
  • 原文地址:https://www.cnblogs.com/dream397/p/15075200.html
Copyright © 2020-2023  润新知