K8S 容器可视化管理工具-kuboard 监控管理工具搭建

一、Kuboard 服务端整体部署

1. 创建目录

复制代码
mkdir -p /home/kuboard

2. Kuboard Servier 端拉去镜像内网启动

复制代码
docker run -d \

  --restart=unless-stopped \

  --name=kuboard \

  -p 6017:80/tcp \

  -p 10081:10081/tcp \

  -e KUBOARD_ENDPOINT="http://IP:6017" \

  -e KUBOARD_AGENT_SERVER_TCP_PORT="10081" \

  -v /home/kuboard:/data \

  eipwork/kuboard:v3.5.0.3

#注意:IP改为实际运行kuboard的ip地址,同时注意ECS放通端口: 6017和10081端口.

http://IP:6017/kuboard/cluster

admin/Kuboard123

二、Kuboard 客户端整体部署

客户端最简单的方式是通过 .kubeconfig的方式进行加载、这样不需要额外操作只需要获取K8S 集群的.kubeconfig文件即可.

三、Kuboard 客户端异常处理

>一、【问题在线】 Kuboard TEST 测试环境启动报错

http://IP :6017/kuboard/cluster

>错误信息如下:

复制代码
   {
      "message": "Failed to connect to the database.",
      "type": "Internal Server Error"
    }

> 二、【问题分析步骤】

1、查看kuboard 的 docker 运行时间

复制代码
[root@cicd snap]# docker ps |grep kuboard
    0ece0f16fc09   eipwork/kuboard:v3.5.0.3   "/entrypoint.sh"   15 months ago   Up 14 months   443/tcp, 0.0.0.0:10081->10081/tcp, :::10081->10081/tcp, 0.0.0.0:6017->80/tcp, :::6017->80/tcp   kuboard

2、查看kuboard的报错日志信息

复制代码
[root@cicd ~]# docker logs -f  --tail=10  0ece0f16fc09
    {"level":"warn","ts":"2024-10-29T10:30:59.723+0800","caller":"clientv3/retry_interceptor.go:61","msg":"retrying of unary invoker failed","target":"endpoint://client-06c8b576-e180-47a0-b8e5-aa9da8204bd7/127.0.0.1:2379","attempt":0,"error":"rpc error: code = ResourceExhausted desc = etcdserver: mvcc: database space exceeded"}
    time="2024-10-29T02:30:59Z" level=error msg="Storage health check failed: create auth request: etcdserver: mvcc: database space exceeded"

日志如上,发现提示ResourceExhausted desc = etcdserver: mvcc: database space exceeded, 这表示etcd服务磁盘空间不足了,默认的空间配额限制为2G,超出空间配额限制就会影响服务,所以需要定期清理。

故查看数据映射的空间大小,找到自己的kuboard-data,查看etcd db占用空间大小,发现从9月23日11点57的时候就是2GB了。已经达到默认的空间配额限制为2G的最大值。

3、查看kuboard etc 目录文件存储大小

复制代码
 [root@cicd snap]# pwd
    /home/kuboard/etcd-data/member/snap
    [root@cicd snap]# ls -lrth 
    total 2.1G
    -rw-r--r-- 1 root root 8.0K Oct 24 09:48 0000000000000005-00000000005c7a3e.snap
    -rw-r--r-- 1 root root 8.0K Oct 25 06:44 0000000000000005-00000000005ca14f.snap
    -rw-r--r-- 1 root root 8.0K Oct 26 05:39 0000000000000005-00000000005cc860.snap
    -rw-r--r-- 1 root root 8.0K Oct 27 09:31 0000000000000005-00000000005cef71.snap
    -rw------- 1 root root 2.0G Oct 28 13:22 db
    -rw-r--r-- 1 root root 8.0K Oct 28 13:22 0000000000000005-00000000005d1682.snap
    [root@cicd snap]# 

进入kuboard容器内部,查看etcd的情况:可以看到在ERRORS列里同样也提示了一个警告alarm:NOSPACE空间不足

复制代码
[root@cicd snap]# docker exec -it 0ece0f16fc09 bash
    root@0ece0f16fc09:/# ETCDCTL_API=3 etcdctl --endpoints="http://127.0.0.1:2379" --write-out=table endpoint status
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+
    |       ENDPOINT        |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX |             ERRORS             |
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+
    | http://127.0.0.1:2379 | 59a9c584ea2c3f35 |  3.4.14 |  2.1 GB |      true |      false |         5 |    6108266 |            6108266 |   memberID:6460912315094810421 |
    |                       |                  |         |         |           |            |           |            |                    |                 alarm:NOSPACE  |
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------------------------------+
    root@0ece0f16fc09:/# 

> 三、【问题解决步骤 】

1、在kuboard容器中依次做如下操作

复制代码
[root@cicd snap]# docker exec -it 0ece0f16fc09 bash
    root@0ece0f16fc09:/# ETCDCTL_API=3 etcdctl --endpoints="http://127.0.0.1:2379" --write-out=table endpoint status

备份db

复制代码
etcdctl snapshot save backup.db

查看当前版本

复制代码
 rev=$(ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*')

压缩旧版本

复制代码
 ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 compact $rev

整理多余的空间

ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 defrag ------> 执行报错, 因为etcdctl 的默认命令超时为 5 秒,但碎片整理花费的时间比这更长

复制代码
ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 --command-timeout=30s defrag    ------> 执行OK

取消告警信息(之前有nospace的告警)

复制代码
 ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 alarm disarm

再次查看etcd的状态(发现ERROR字段已为空)

复制代码
ETCDCTL_API=3 etcdctl --endpoints="http://127.0.0.1:2379" --write-out=table endpoint status
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
    |       ENDPOINT        |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
    | http://127.0.0.1:2379 | 59a9c584ea2c3f35 |  3.4.14 |  915 MB |      true |      false |         5 |    6108320 |            6108320 |        |
    +-----------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+

2、查看kuboard etc 目录文件存储大小 ---从2.1G 变成了 873M

复制代码
[root@cicd snap]# pwd
    /home/kuboard/etcd-data/member/snap
    [root@cicd snap]# ls -lrth 
    total 873M
    -rw-r--r-- 1 root root 8.0K Oct 24 09:48 0000000000000005-00000000005c7a3e.snap
    -rw-r--r-- 1 root root 8.0K Oct 25 06:44 0000000000000005-00000000005ca14f.snap
    -rw-r--r-- 1 root root 8.0K Oct 26 05:39 0000000000000005-00000000005cc860.snap
    -rw-r--r-- 1 root root 8.0K Oct 27 09:31 0000000000000005-00000000005cef71.snap
    -rw-r--r-- 1 root root 8.0K Oct 28 13:22 0000000000000005-00000000005d1682.snap
    -rw------- 1 root root 873M Oct 29 10:51 db
    [root@cicd snap]# 

> 四、【问题恢复-有效访问】

http://IP:6017/kuboard/cluster --- 有效访问OK !

相关推荐
咚咚?1 小时前
基于gitlab 构建CICD发布到K8S 平台
容器·kubernetes·gitlab
尘土哥4 小时前
Docker 快速上手
docker·容器·eureka
wenzhangli75 小时前
低代码引擎核心技术:OneCode常用动作事件速查手册及注解驱动开发详解
人工智能·低代码·云原生
胡耀超9 小时前
Umi-OCR 的 Docker安装(win制作镜像,Linux(Ubuntu Server 22.04)离线部署)
linux·深度学习·ubuntu·docker·容器·nlp·ocr
铃木隼.13 小时前
docker容器高级管理-dockerfile创建镜像
运维·docker·容器
容器魔方13 小时前
持续领跑,华为云连续5年蝉联中国容器软件市场份额第一
云原生·容器·云计算
樽酒ﻬق16 小时前
Prometheus Operator:Kubernetes 监控自动化实践
java·算法·云原生·运维开发
麟城Lincoln18 小时前
【Linux-云原生-笔记】Apache相关
linux·笔记·云原生·apache·webserver
IT成长日记19 小时前
【Docker基础】Dockerfile指令速览:文件与目录操作指令详解
docker·容器·volume·add·dockerfile·workdir
胡耀超19 小时前
GraphRAG Docker化部署,接入本地Ollama完整技术指南:从零基础到生产部署的系统性知识体系
运维·docker·容器·大模型·知识图谱·rag·ollama