k8s——daemonset

daemonset

为每一个匹配的node都部署一个守护进程

# daemonset   node:type=logs

daemonset 选择节点

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

daemonset 的实例

[root@master daemonset]# cat fluentd.yml 
apiVersion: apps/v1
kind: DaemonSet   # 创建daemonset 资源
metadata:
  name: fluentd   # 名字
spec:
  selector:
    matchLabels:
        app: loging
  template:
    metadata:
      labels:
        app: loging
        id: fluentd
      name: fluentd   # pod的名字
    spec:
      containers:
      - name: fluentd-es
        image: agilestacks/fluentd-elasticsearch:v1.3.0
        env:  # 环境变量
        - name: FLUENTD_ARGS   # 环境变量的key
          value: -qq     # 环境变量的value
        volumeMounts:    # 加载数据卷,避免数据丢失
        - name: containers   # 数据卷的名字 
          mountPath: /var/lib/docker/containers   # 将数据卷挂载到容器内的哪个目录
        - name: varlog
          mountPath: /varlog
      volumes:   # 定义数据卷
         - hostPath:   # 数据卷类型,主机路径的模式,也就是与node共享目录
             path: /var/lib/docker/containers    # node中的共享目录
           name: containers    # 定义的数据卷的名称 
         - hostPath:  # 数据卷采用的是主机目录的方式
             path: /var/log
           name: varlog
[root@master daemonset]# 

使用标签

spec:
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: loging
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: loging
        id: fluentd
      name: fluentd
    spec:
      nodeSelector:
         type: microservices    
# 层级关系: spec.template.spec.nodeSelector

滚动更新(不建议使用)

因为滚动更新一旦修改模版内的内容就会自动进行更新。
在一定程度上会浪费资源,所以我们一般会把更新策略换成OnDelete策略

posted on   代码你敲我不敲  阅读(34)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了

导航

统计

返回顶端
点击右上角即可分享
微信分享提示