Kubernetes资源观测工具怎么用

发布时间:2021-11-15 11:10:05 作者:小新
来源:亿速云 阅读:172

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

前言

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

我这边开发了钉钉的通知渠道,但是在上游 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.git
cd kubewatch-chat
helm 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。

Kubernetes资源观测工具怎么用

安全设置

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

Kubernetes资源观测工具怎么用

项目配置

编辑 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:
#     - myRegistryKeySecretName

slack:
  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 watch
resourcesToWatch:
  deployment: true
  replicationcontroller: false
  replicaset: false
  daemonset: false
  services: false
  pod: true
  job: false
  persistentvolume: false

image:
  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: true

serviceAccount:
  # 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.git
cd kubewatch-chat
helm install my-release -f kubewatch/values.yaml

Slack 配置

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

创建一个 APP

进去创建 APP 页面

Kubernetes资源观测工具怎么用

选择 App NameDevelopment Slack Workspace

Kubernetes资源观测工具怎么用

添加 Bot 用户

Kubernetes资源观测工具怎么用

添加 App 到 Workspace

Kubernetes资源观测工具怎么用

获取 Bot-token

Kubernetes资源观测工具怎么用

通知效果

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

Kubernetes资源观测工具怎么用

在钉钉中,我进行了汉化

Kubernetes资源观测工具怎么用

Kubernetes资源观测工具怎么用

结语

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

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

推荐阅读:
  1. Kubernetes的Job资源对象怎么用
  2. Kubernetes中的Job和CronJob资源对象怎么用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

kubernetes

上一篇:高效的性能测试工具wrk怎么用

下一篇:怎么用Java实现判断括号的合法性

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》