前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Kubernetes运维之工作负载DaemonSet

Kubernetes运维之工作负载DaemonSet

作者头像
王先森sec
发布2023-04-24 17:15:15
3940
发布2023-04-24 17:15:15
举报
文章被收录于专栏:王先森

DaemonSet简介

DaemonSet 确保全部(或者某些)节点上运行一个 Pod 的副本。 当有节点加入集群时, 也会为他们新增一个 Pod 。 当有节点从集群移除时,这些 Pod 也会被回收。删除 DaemonSet 将会删除它创建的所有 Pod。 使用 DaemonSet 的一些典型用法:

  • 在每个节点上运行集群守护进程,例如在每个 Node 上运行 glusterd 、 ceph
  • 在每个节点上运行日志收集守护进程,例如 fluentd 、 logstash
  • 在每个节点上运行监控守护进程,例如 Prometheus Node Exportercollectd 、Datadog 代理、New Relic 代理,或 Ganglia gmond

一种简单的用法是为每种类型的守护进程在所有的节点上都启动一个 DaemonSet。 一个稍微复杂的用法是为同一种守护进程部署多个 DaemonSet;每个具有不同的标志, 并且对不同硬件类型具有不同的内存、CPU 要求。

DaemonSet模板

查看DaemonSet必要字段

DaemonSet的描述文件和Deployment非常相似,只需要修改Kind,并去掉副本数量的配置即可。

代码语言:javascript
复制
[root@k8s-master1 ~]# kubectl explain ds
KIND:     DaemonSet
VERSION:  apps/v1

DESCRIPTION:
     DaemonSet represents the configuration of a daemon set.

FIELDS:
   apiVersion   <string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources

   kind <string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds

   metadata     <Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

   spec <Object>
     The desired behavior of this daemon set. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

   status       <Object>
     The current status of this daemon set. This data may be out of date by some
     window of time. Populated by the system. Read-only. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

模板:

代码语言:javascript
复制
[root@k8s-master mnt]# cat daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ds-test
  labels:
    app: daemonset
spec:
  selector:
    matchLabels:
      name: ds-test
  template:
    metadata:
      labels:
        name: ds-test
    spec:
      containers:
      - name: ds-test
        image: nginx

Daemon Pods 是如何被调度的

DaemonSet 确保所有符合条件的节点都运行该 Pod 的一个副本。 通常,运行 Pod 的节点由 Kubernetes 调度器选择。 不过,DaemonSet Pods 由 DaemonSet 控制器创建和调度。这就带来了以下问题:

  • Pod 行为的不一致性:正常 Pod 在被创建后等待调度时处于 Pending 状态, DaemonSet Pods 创建后不会处于 Pending 状态下。这使用户感到困惑。
  • Pod 抢占由默认调度器处理。启用抢占后,DaemonSet 控制器将在不考虑 Pod 优先级和抢占 的情况下制定调度决策。

污点和容忍度

尽管 Daemon Pods 遵循污点和容忍度 规则,根据相关特性,控制器会自动将以下容忍度添加到 DaemonSet Pod:

容忍度键名

效果

版本

描述

node.kubernetes.io/not-ready

NoExecute

1.13+

当出现类似网络断开的情况导致节点问题时,DaemonSet Pod 不会被逐出。

node.kubernetes.io/unreachable

NoExecute

1.13+

当出现类似于网络断开的情况导致节点问题时,DaemonSet Pod 不会被逐出。

node.kubernetes.io/disk-pressure

NoSchedule

1.8+

DaemonSet Pod 被默认调度器调度时能够容忍磁盘压力属性。

node.kubernetes.io/memory-pressure

NoSchedule

1.8+

DaemonSet Pod 被默认调度器调度时能够容忍内存压力属性。

node.kubernetes.io/unschedulable

NoSchedule

1.12+

DaemonSet Pod 能够容忍默认调度器所设置的 unschedulable 属性.

node.kubernetes.io/network-unavailable

NoSchedule

1.12+

DaemonSet 在使用宿主网络时,能够容忍默认调度器所设置的 network-unavailable 属性。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-12-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • DaemonSet简介
  • DaemonSet模板
    • Daemon Pods 是如何被调度的
      • 污点和容忍度
相关产品与服务
Prometheus 监控服务
Prometheus 监控服务(TencentCloud Managed Service for Prometheus,TMP)是基于开源 Prometheus 构建的高可用、全托管的服务,与腾讯云容器服务(TKE)高度集成,兼容开源生态丰富多样的应用组件,结合腾讯云可观测平台-告警管理和 Prometheus Alertmanager 能力,为您提供免搭建的高效运维能力,减少开发及运维成本。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档