k8s 部署 kuboard v3

下载 kuboard 部署清单

# wget https://addons.kuboard.cn/kuboard/kuboard-v3-swr.yaml

修改部署清单 configmap

# vim kuboard-v3-swr.yaml

修改内容

# KUBOARD_AGENT_KEY 是 Agent 与 Kuboard 通信时的密钥,请修改为一个任意的包含字母、数字的32位字符串,此密钥变更后,需要删除 Kuboard Agent 重新导入。
  KUBOARD_AGENT_KEY: 32b7d6572c6255211b4eec9009e4a816

确认 etcd 节点数量

在集群中 Master Role 节点不足3个个时, 需要在 worker 节点添加 k8s.kuboard.cn/role=etcd 的标签,使etcd最少为奇数3个节点。
添加 label 命令:
kubectl label nodes your-node-name k8s.kuboard.cn/role=etcd

部署 kuboard

# kubectl apply -f kuboard-v3-swr.yaml

查看 kuboard 信息

查看 pod 信息

# kubectl get pods -n kuboard
NAME                               READY   STATUS    RESTARTS      AGE
kuboard-agent-2-6bb4fcbbdc-c78bn   1/1     Running   0             59s
kuboard-agent-776559d789-s2tkn     1/1     Running   0             59s
kuboard-etcd-ff5ht                 1/1     Running   0             80s
kuboard-etcd-gsctg                 1/1     Running   0             80s
kuboard-etcd-kkptg                 1/1     Running   0             80s
kuboard-v3-7979bc788f-hxq4p        1/1     Running   0             80s

查看 svc 信息

# kubectl get svc -n kuboard
NAME         TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)                                        AGE
kuboard-v3   NodePort   10.100.98.91   <none>        80:30080/TCP,10081:30081/TCP,10081:30081/UDP   2m16s

访问 kuboard

http://your-node-ip-address:30080
用户名: admin
密码: Kuboard123

暴露 kuboard 服务

通过 Ingress  暴露 Kuboard

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kuboard
  namespace: kuboard
spec:
  ingressClassName: nginx
  rules:
  - host: kuboard.wgs.com
    http:
      paths:
      - path: /
        backend:
          service:
            name: kuboard-v3
            port:
              number: 80
        pathType: Prefix

通过反向代理访问 Kuboard

http {

  # 您需要的其他配置

  map $http_upgrade $connection_upgrade {
      default upgrade;
      '' close;
  }

  server {
    listen       80; 
    server_name  kuboard.this-is-a-sample.com; # 替换成你的域名

    location / {
      proxy_pass http://192.168.32.205:30080/;  # 替换成你的 Kuboard IP 地址和端口,应该是 IP 地址,而不是 KUBOARD_ENDPOINT 参数的值
      client_max_body_size 10m;
      gzip on;
    }

    location /k8s-ws/ {
      proxy_pass  http://192.168.32.205:30080/k8s-ws/;  # 替换成你的 Kuboard IP 地址和端口
      proxy_http_version 1.1;
      proxy_pass_header Authorization;
      proxy_set_header Upgrade "websocket";
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      # proxy_set_header X-Forwarded-Proto https; # 如果您在反向代理上启用了 HTTPS
    }

    location /k8s-proxy/ {
      proxy_pass  http://192.168.32.205:30080/k8s-proxy/;  # 替换成你的 Kuboard IP 地址和端口
      proxy_http_version 1.1;
      proxy_pass_header Authorization;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;

      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      # proxy_set_header X-Forwarded-Proto https; # 如果您在反向代理上启用了 HTTPS
      gzip on;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
  }
}

卸载 kuboard

删除 kuboard

# kubectl delete -f kuboard-v3-swr.yaml

清理遗留数据

在 master 节点以及带有 k8s.kuboard.cn/role=etcd 标签的节点上执行
# rm -rf /usr/share/kuboard

参考文档

https://kuboard.cn/install/v3/install-in-k8s.html#%E6%96%B9%E6%B3%95%E4%B8%80-%E4%BD%BF%E7%94%A8-hostpath-%E6%8F%90%E4%BE%9B%E6%8C%81%E4%B9%85%E5%8C%96

posted @ 2023-12-26 09:42  小吉猫  阅读(657)  评论(0编辑  收藏  举报