运维八一 运维八一
首页
运维杂记
编程浅尝
周积跬步
专栏
生活
关于
收藏
  • 分类
  • 标签
  • 归档
Source (opens new window)

运维八一

运维,运维!
首页
运维杂记
编程浅尝
周积跬步
专栏
生活
关于
收藏
  • 分类
  • 标签
  • 归档
Source (opens new window)
  • Devops笔记

  • Kubernetes

    • k8s 使用YAML配置文件管理资源
    • k8s 调度约束
    • k8s 资源约束
    • k8s 健康检测
    • k8s 重启策略
    • k8s pod管理
    • k8s DaemonSet典型应用
      • 1. DaemonSet的典型应用场景
      • 2. DaemonSet 案例分析
    • k8s Job任务
    • k8s service服务
  • 运维监控系统

  • go分布式爬虫

  • Linux性能优化

  • 夜莺(nightingale)开源观测平台

  • kubernetes-network-policy-recipes

  • 专栏
  • Kubernetes
lyndon
2022-10-05
目录

k8s DaemonSet典型应用

# 1. DaemonSet的典型应用场景

  • 在集群的每个节点上运行存储 Daemon,比如 glusterd 或 ceph
  • 在每个节点上运行日志收集 Daemon,比如 flunentd 或 logstash
  • 在每个节点上运行监控 Daemon,比如 Prometheus Node Exporter 或 collectd

# 2. DaemonSet 案例分析

k8s自身的 DaemonSet:

  • kube-flannel-ds
  • kube-proxy

kube-flannel-ds的yml文件中关于daemonset的内容:

apiVersion: extensions/v1beta1
kind: DaemonSet                     # DaemonSet 配置文件的语法和结构与 Deployment 几乎完全一样,只是将 kind 设为 DaemonSet
metadata:
  name: kube-flannel-ds-amd64
  namespace: kube-system
  labels:
    tier: node
    app: flannel
spec:
  template:
    metadata:
      labels:
        tier: node
        app: flannel
    spec:
      hostNetwork: true             # 指定Pod直接使用Node的网络,相当于docker run --network=host,考虑到flannel需要为集群提供网络连接,这个要求是合理的
      nodeSelector:
        beta.kubernetes.io/arch: amd64
      containers:                   # containers 定义了运行 flannel 服务的两个容器。

   - name: kube-flannel
     image: quay.io/coreos/flannel:v0.11.0-amd64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

Prometheus 是流行的系统监控方案,Node Exporter 是 Prometheus 的 agent,以 Daemon 的形式运行在每个被监控节点上,运行一个daemonset示例:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: node-exporter-daemonset
spec:
  template:
    metadata:
      labels:
        app: prometheus
    spec:
      hostNetwork: true
      containers:
   - name: node-exporter
     image: prom/node-exporter
     imagePullPolicy: IfNotPresent
     command:
     - /bin/node_exporter
     - --path.procfs
     - /host/proc
     - --path.sysfs
     - /host/sys
     - --collector.filesystem.ignored-mount-points
     - ^/(sys|proc|dev|host|etc)($|/)
       volumeMounts:
     - name: proc
       mountPath: /host/proc
     - name: sys
       mountPath: /host/sys
     - name: root
       mountPath: /rootfs
           volumes:
          - name: proc
            hostPath:
            path: /proc
               - name: sys
                 hostPath:
                 path: /sys
                    - name: root
                      hostPath:
                      path: /
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
上次更新: 2022/10/05, 15:51:58
k8s pod管理
k8s Job任务

← k8s pod管理 k8s Job任务→

最近更新
01
ctr和crictl显示镜像不一致
03-13
02
alpine镜像集成常用数据库客户端
03-13
03
create-cluster
02-26
更多文章>
Theme by Vdoing | Copyright © 2015-2024 op81.com
苏ICP备18041258号-2
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式