溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Kubernetes資源觀測工具怎么用

發(fā)布時間:2021-11-15 11:10:05 來源:億速云 閱讀:182 作者:小新 欄目:云計算

這篇文章主要介紹Kubernetes資源觀測工具怎么用,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

前言

這次要介紹一個 Kubernetes 資源觀測工具,實時監(jiān)控 Kubernetes 集群中各種資源的新建、更新和刪除,并實時通知到各種協(xié)作軟件/聊天軟件,目前支持的通知渠道有:

  • slack

  • hipchat

  • mattermost

  • flock

  • webhook

我這邊開發(fā)了釘釘?shù)耐ㄖ?,但是在上?ISSUE#198 中提出的貢獻請求并沒有得到回應(yīng),所以這邊只能 fork 了代碼,然后自己進行了開發(fā),以支持釘釘通知。

安裝

這里推薦使用 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"

釘釘配置

在釘釘中創(chuàng)建 智能群助手 ,之后

獲取 token

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

Kubernetes資源觀測工具怎么用

安全設(shè)置

釘釘智能群助手在更新后新增了安全設(shè)置,提供三種驗證方式 自定義關(guān)鍵詞 加簽 IP地址(段),這里推薦使用 IP地址(段)的方式,直接將 Kubernetes 集群的出口 IP 填入設(shè)置即可。同時也提供了 加簽 的方式,拷貝秘鑰,將其填入 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 默認(rèn)的通知軟件,這里就不簡介 Slack 的安裝和注冊,直接從創(chuàng)建 APP 開始

創(chuàng)建一個 APP

進去創(chuàng)建 APP 頁面

Kubernetes資源觀測工具怎么用

選擇 App NameDevelopment Slack Workspace

Kubernetes資源觀測工具怎么用

添加 Bot 用戶

Kubernetes資源觀測工具怎么用

添加 App 到 Workspace

Kubernetes資源觀測工具怎么用

獲取 Bot-token

Kubernetes資源觀測工具怎么用

通知效果

在 Slack 中,創(chuàng)建 更新 刪除 分別以綠、黃和紅色代表

Kubernetes資源觀測工具怎么用

在釘釘中,我進行了漢化

Kubernetes資源觀測工具怎么用

Kubernetes資源觀測工具怎么用

結(jié)語

對于 kubewatch 我們這里主要用作監(jiān)控各種 CronJob 的定時觸發(fā)狀態(tài),已經(jīng) ConfigMap 和 Secrets 的狀態(tài)變化,同時也觀察 HPA 觸發(fā)的彈性伸縮的狀態(tài),可以實時觀測到業(yè)務(wù)高峰的到來,是一個不錯的小工具。

以上是“Kubernetes資源觀測工具怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI