BotKube

BotKube 是一个用于监控和调试 Kubernetes 集群的消息传递工具。 BotKube 可以与多个消息传递平台(如 Slack、Mattermost 或 Microsoft Teams)集成,以帮助您监控 Kubernetes 集群、调试关键部署,并通过对 Kubernetes 资源运行检查来提供标准实践建议。

安装BotKube

1、本文使用slack作为消息接收平台,需要自行注册slack,拿到Access token

xoxb-2169032185141-2256603089394-qeLWxe0sUtwfdlwnk6VWbw11

2、将 BotKube 用户添加到 Slack 频道

将 BotKube 应用程序安装到您的 Slack 工作区后,您会看到一个名为“BotKube”的新机器人用户添加到您的工作区中。 将该机器人添加到您想要接收通知的 Slack 频道。

(您可以通过在频道中邀请@BotKube 来添加它)

3、使用helm把BotKube安装到kubernrtes集群

helm repo add infracloudio https://infracloudio.github.io/charts
helm repo update 请自行替换<>内的信息:
helm install --version v0.12.1 botkube --namespace botkube \
--set communications.slack.enabled=true \
--set communications.slack.channel=<SLACK_CHANNEL_NAME> \
--set communications.slack.token=<SLACK_API_TOKEN_FOR_THE_BOT> \
--set config.settings.clustername=<CLUSTER_NAME> \
--set config.settings.kubectl.enabled=<ALLOW_KUBECTL> \
--set image.repository=infracloudio/botkube \
--set image.tag=v0.12.1 \
infracloudio/botkube - SLACK_CHANNEL_NAME 是添加@BotKube 的频道名称
- SLACK_API_TOKEN_FOR_THE_BOT 是将 BotKube 应用程序安装到 Slack 工作区后收到的令牌
- CLUSTER_NAME 是在传入消息中设置的集群名称
- ALLOW_KUBECTL 设置为 true 以允许 BotKube 在集群上执行 kubectl 命令

4、查看安装信息

# helm list -n botkube
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
botkube botkube 1 2021-07-09 10:41:35.813245746 +0800 CST deployed botkube-v0.12.1 v0.12.1
# kubectl get all -n botkube
NAME READY STATUS RESTARTS AGE
pod/botkube-747ff4dc5d-795hz 1/1 Running 0 2d22h NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/botkube 1/1 1 1 2d22h NAME DESIRED CURRENT READY AGE
replicaset.apps/botkube-747ff4dc5d 1 1 1 2d22h

5、如果你需要修改配置,可以更新botkube-configmap,默认设置如下

recommendations: true
resources:
- events:
- create
- delete
- error
name: v1/pods
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/services
namespaces:
ignore:
- null
include:
- all
- events:
- create
- update
- delete
- error
name: apps/v1/deployments
namespaces:
ignore:
- null
include:
- all
updateSetting:
fields:
- spec.template.spec.containers[*].image
- status.availableReplicas
includeDiff: true
- events:
- create
- update
- delete
- error
name: apps/v1/statefulsets
namespaces:
ignore:
- null
include:
- all
updateSetting:
fields:
- spec.template.spec.containers[*].image
- status.readyReplicas
includeDiff: true
- events:
- create
- delete
- error
name: networking.k8s.io/v1beta1/ingresses
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/nodes
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/namespaces
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/persistentvolumes
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/persistentvolumeclaims
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: v1/configmaps
namespaces:
ignore:
- null
include:
- all
- events:
- create
- update
- delete
- error
name: apps/v1/daemonsets
namespaces:
ignore:
- null
include:
- all
updateSetting:
fields:
- spec.template.spec.containers[*].image
- status.numberReady
includeDiff: true
- events:
- create
- update
- delete
- error
name: batch/v1/jobs
namespaces:
ignore:
- null
include:
- all
updateSetting:
fields:
- spec.template.spec.containers[*].image
- status.conditions[*].type
includeDiff: true
- events:
- create
- delete
- error
name: rbac.authorization.k8s.io/v1/roles
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: rbac.authorization.k8s.io/v1/rolebindings
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: rbac.authorization.k8s.io/v1/clusterrolebindings
namespaces:
ignore:
- null
include:
- all
- events:
- create
- delete
- error
name: rbac.authorization.k8s.io/v1/clusterroles
namespaces:
ignore:
- null
include:
- all
settings:
clustername: k8s-2
configwatcher: true
kubectl:
commands:
resources:
- deployments
- pods
- namespaces
- daemonsets
- statefulsets
- storageclasses
- nodes
verbs:
- api-resources
- api-versions
- cluster-info
- describe
- diff
- explain
- get
- logs
- top
- auth
- describe
defaultNamespace:
- default
- pro
- qa
enabled: true
restrictAccess: false
upgradeNotifier: true
ssl:
enabled: false

使用Slack与BotKube对话

1、先ping下BotKube,看看输出

2、查看可使用的命令

3、以对话的形式执行kubectl命令,例如获取pod,更多命令可以自己测试...

4、验证slack收集kubernetes事件信息,例如创建一个新的pod,这里以nginx为例

我这里直接用lens连接集群,创建一个名为nginx的deployment,



直接创建即可,然后来到slack可以看到如下信息,即botkube将这个create事件消息推送到了你的slack频道。



现在删除deployment,再看slack频道,收到delete的消息



更多好玩的功能,请自行体会吧。。。

以对话的形式管理你的Kubernetes集群的更多相关文章

  1. 谈一下Docker与Kubernetes集群的日志和日志管理

    本文的测试环境为CentOS 7.3,Kubernetes集群为1.11.2,安装步骤参见kubeadm安装kubernetes V1.11.1 集群 日志对于我们管理Kubernetes集群及其上的 ...

  2. kubeadm部署Kubernetes集群

    Preface 通过kubeadm管理工具部署Kubernetes集群,相对离线包的二进制部署集群方式而言,更为简单与便捷.以下为个人学习总结: 两者区别在于前者部署方式使得大部分集群组件(Kube- ...

  3. Kubernetes集群管理工具kubectl命令技巧大全

    一. kubectl概述 Kubectl是用于控制Kubernetes集群的命令行工具,通过kubectl能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署. kubectl命令的语法如下 ...

  4. 基于Python+Django的Kubernetes集群管理平台

    ➠更多技术干货请戳:听云博客 时至今日,接触kubernetes也有一段时间了,而我们的大部分业务也已经稳定地运行在不同规模的kubernetes集群上,不得不说,无论是从应用部署.迭代,还是从资源调 ...

  5. 高可用Kubernetes集群-15. 部署Kubernetes集群统一日志管理

    参考文档: Github:https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsear ...

  6. Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之集群部署环境规划(一)

    0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.环境规划 软件 版本 ...

  7. 快速部署Kubernetes集群管理

    这篇文章介绍了如何快速部署一套Kubernetes集群,下面就快速开始吧! 准备工作 //关闭防火墙 systemctl stop firewalld.service systemctl disabl ...

  8. kubernetes集群管理之通过jq来截取属性

    系列目录 首先要声明,这里的jq并不是批前端框架里的jquery,而是一个处理json的命令行工具. jq工具相比yq,它更加成熟,功能也更加强大,主要表现在以下几个方面 支持递归查找(我点对我们平时 ...

  9. 阿里云上万个 Kubernetes 集群大规模管理实践

    点击下载<不一样的 双11 技术:阿里巴巴经济体云原生实践> 本文节选自<不一样的 双11 技术:阿里巴巴经济体云原生实践>一书,点击上方图片即可下载! 作者 | 汤志敏,阿里 ...

随机推荐

  1. Linux_yum命令详解

    一.yum命令语法 yum [options] [command] [package ...] 二.yum命令常用的选项: yum options -y //自动回答为"yes" ...

  2. nginx rewite重定向详解及实例解析

    静态和动态最大的区别是是否调用数据库. 什么是rewrite 将浏览器发送到服务器的请求重写,然后再返回给用户. 就是修改url,提高用户体验 rewrite的用途 80强转443 (优化用户体验) ...

  3. fprintf函数

    描述 C 库函数 int fprintf(FILE *stream, const char *format, ...) 发送格式化输出到流 stream 中. 声明 下面是 fprintf() 函数的 ...

  4. Prometheus监控软件部署方法

    背景:负责基于区块链的某公正项目的状态上报模块设计编码,基于Prometheus进行二次开发 1.说明Prometheus 是一个开源的服务监控软件,它通过 HTTP 协议从远程机器收集数据并存储在本 ...

  5. GO学习-(21) Go语言基础之Go性能调优

    Go性能调优 在计算机性能调试领域里,profiling 是指对应用程序的画像,画像就是应用程序使用 CPU 和内存的情况. Go语言是一个对性能特别看重的语言,因此语言中自带了 profiling ...

  6. 鱼眼摄像头SLAM

    鱼眼摄像头SLAM 在机器人技术.摄影测量学和计算机视觉等领域,鲁棒相机位姿估计是许多视觉应用的核心.近年来,在复杂.大规模的室内外环境中,人们越来越关注相机位姿估计方法的实时性.通用性和可操作性.其 ...

  7. NVIDIA GPU的神经网络自动调度

    NVIDIA GPU的神经网络自动调度 针对特定设备和工作负载的自动调整对于获得最佳性能至关重要.这是一个关于如何使用自动调度器为NVIDIA GPU调整整个神经网络的资料. 为了自动调整一个神经网络 ...

  8. CVPR2020:点云分析中三维图形卷积网络中可变形核的学习

    CVPR2020:点云分析中三维图形卷积网络中可变形核的学习 Convolution in the Cloud: Learning Deformable Kernels in 3D Graph Con ...

  9. 简化可视SLAM应用程序的开发

    简化可视SLAM应用程序的开发 Easing the development of visual SLAM applications 同步定位和映射(SLAM)描述了一个设备(如机器人)使用传感器数据 ...

  10. vue3函数setUp和reactive函数详细讲解

    1 setUp的执行时机 我们都知道,现在vue3是可以正常去使用methods的. 但是我们却不可以在setUp中去调用methods中的方法. 为什么了??? 我们先了解一下下面这两个生命周期函数 ...