千家信息网

Kubernetes资源观测工具怎么用

发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,这篇文章主要介绍Kubernetes资源观测工具怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!前言这次要介绍一个 Kubernetes 资源观测工具,实时监控 Kuber
千家信息网最后更新 2025年12月03日Kubernetes资源观测工具怎么用

这篇文章主要介绍Kubernetes资源观测工具怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

前言

这次要介绍一个 Kubernetes 资源观测工具,实时监控 Kubernetes 集群中各种资源的新建、更新和删除,并实时通知到各种协作软件/聊天软件,目前支持的通知渠道有:

  • slack

  • hipchat

  • mattermost

  • flock

  • webhook

我这边开发了钉钉的通知渠道,但是在上游 ISSUE#198 中提出的贡献请求并没有得到回应,所以这边只能 fork 了代码,然后自己进行了开发,以支持钉钉通知。

安装

这里推荐使用 helm 进行安装,快速部署

helm install kubewatch stable/kubewatch \--set rbac.create=true \--set slack.channel='#YOUR_CHANNEL' \--set slack.token='xoxb-YOUR_TOKEN' \--set resourcesToWatch.pod=true \--set resourcesToWatch.daemonset=true

如果想使用钉钉通知,则可以在 GitHub 上拉取我的代码,代码中包含 helm chart 包,可直接进行安装

git clone https://github.com/sunny0826/kubewatch-chat.gitcd kubewatch-chathelm install kubewatch kubewatch \--set dingtalk.sign="XXX" \--set dingtalk.token="XXXX-XXXX-XXXX"

钉钉配置

在钉钉中创建 智能群助手 ,之后

获取 token

复制的 webhook 中 https://oapi.dingtalk.com/robot/send?access_token={YOUR_TOKEN}, {YOUR_TOKEN} 就是要填入的 token。

安全设置

钉钉智能群助手在更新后新增了安全设置,提供三种验证方式 自定义关键词 加签 IP地址(段),这里推荐使用 IP地址(段)的方式,直接将 Kubernetes 集群的出口 IP 填入设置即可。同时也提供了 加签 的方式,拷贝秘钥,将其填入 dingtalk.sign 中。

项目配置

编辑 kubewatch/value.yaml ,修改配置

## Global Docker image parameters## Please, note that this will override the image parameters, including dependencies, configured to use the global value## Current available global Docker image parameters: imageRegistry and imagePullSecrets### global:#   imageRegistry: myRegistryName#   imagePullSecrets:#     - myRegistryKeySecretNameslack:  enabled: false  channel: ""  token: "xoxb"hipchat:  enabled: false  # room: ""  # token: ""  # url: ""mattermost:  enabled: false  # channel: ""  # url: ""  # username: ""flock:  enabled: false  # url: ""webhook:  enabled: false  # url: ""dingtalk:  enabled: true  token: ""  sign: ""# namespace to watch, leave it empty for watching all.namespaceToWatch: ""# Resources to watchresourcesToWatch:  deployment: true  replicationcontroller: false  replicaset: false  daemonset: false  services: false  pod: true  job: false  persistentvolume: falseimage:  registry: docker.io#  repository: bitnami/kubewatch  repository: guoxudongdocker/kubewatch-chart#  tag: 0.0.4-debian-9-r405  tag: latest  pullPolicy: Always  ## Optionally specify an array of imagePullSecrets.  ## Secrets must be manually created in the namespace.  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/  ##  # pullSecrets:  #   - myRegistryKeySecretName## String to partially override kubewatch.fullname template (will maintain the release name)### nameOverride:## String to fully override kubewatch.fullname template### fullnameOverride:rbac:  # If true, create & use RBAC resources  #  create: trueserviceAccount:  # Specifies whether a ServiceAccount should be created  create: true  # The name of the ServiceAccount to use.  # If not set and create is true, a name is generated using the fullname template  name:resources: {}  # limits:  #   cpu: 100m  #   memory: 300Mi  # requests:  #   cpu: 100m  #   memory: 300Mi# Affinity for pod assignment# Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity# affinity: {}# Tolerations for pod assignment# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/tolerations: []# Node labels for pod assignment# Ref: https://kubernetes.io/docs/user-guide/node-selection/nodeSelector: {}podAnnotations: {}podLabels: {}replicaCount: 1

使用 value.yaml 安装

git clone https://github.com/sunny0826/kubewatch-chat.gitcd kubewatch-chathelm install my-release -f kubewatch/values.yaml

Slack 配置

Slack 为 kubewatch 默认的通知软件,这里就不简介 Slack 的安装和注册,直接从创建 APP 开始

创建一个 APP

进去创建 APP 页面

选择 App NameDevelopment Slack Workspace

添加 Bot 用户

添加 App 到 Workspace

获取 Bot-token

通知效果

在 Slack 中,创建 更新 删除 分别以绿、黄和红色代表

在钉钉中,我进行了汉化

结语

对于 kubewatch 我们这里主要用作监控各种 CronJob 的定时触发状态,已经 ConfigMap 和 Secrets 的状态变化,同时也观察 HPA 触发的弹性伸缩的状态,可以实时观测到业务高峰的到来,是一个不错的小工具。

以上是"Kubernetes资源观测工具怎么用"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

工具 资源 观测 配置 代码 实时 方式 状态 软件 更新 安全 内容 助手 同时 地址 智能 渠道 篇文章 集群 开发 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 海南英图互联网科技有限公司 方舟进化生存手游免费创建服务器 网络安全小学生手抄报简单 日喀则有几个软件开发公司 昆明java软件开发招聘 海南高宇网络技术有限公司梦想花园 菏泽高校诚信积分管理软件开发 区块链软件开发犯法吗 网络安全图画说明 生成导入数据库文件 信息网络技术基础课程 南京邮电大学网络安全学院怎样 宁江区中小学生网络安全知识问答 数据库多媒体及安全题库 数据库入门创建基本表 宇轩网络安全小组 现在的最新的网络技术 网络安全班级简讯 宝山区新能源网络技术哪家好 通州网络安全产业园规划 怎么检查服务器的网卡名 网络安全保护制度首要措施 西集网络安全园入驻企业 智慧芽数据库中可以查文献吗 数据库优化如何应对百万并发 数字管理服务器 云计算工程师网络安全与 河南金山云网络技术公司 的士高视频软件开发 发发圈app软件开发
0