安装 Helm 和 Prometheus

安装 Helm

将以下命令复制后粘贴到终端:

  1. install_helmv3() {
  2. if ! hash wget &>/dev/null;then
  3. if grep 'Ubuntu' /etc/os-release &>/dev/null;then
  4. apt install wget -y
  5. else
  6. yum install wget -y
  7. fi
  8. fi
  9. wget http://ops.dosec.cn/directlink/tools/helm-v3.3.0-linux-amd64.tar.gz
  10. tar xf helm-v3.3.0-linux-amd64.tar.gz
  11. cp linux-amd64/helm /usr/local/bin
  12. rm -rf linux-amd64
  13. # helm completion
  14. echo "source <(helm completion bash)" >> ~/.bashrc
  15. exec $SHELL -l
  16. }
  17. init_helmv3() {
  18. # 添加阿里云 APPHub 和微软 Azure 提供的 Charts 镜像
  19. # helm repo add local http://127.0.0.1:8879/charts
  20. # v2 版本默认会增加上面这个本地 repo, 这里记录一下备用
  21. helm repo add stable https://apphub.aliyuncs.com
  22. helm repo add azure http://mirror.azure.cn/kubernetes/charts/
  23. helm repo add incubator http://mirror.azure.cn/kubernetes/charts/
  24. # 更新本地 charts repo
  25. helm repo update
  26. }

安装 Helmv3

  1. install_helmv3

初始化 Helm 仓库

  1. init_helmv3

安装 Prometheus

创建命名空间

  1. kubectl create namespace monitoring

安装 Prometheus

  1. helm install monitor --namespace monitoring stable/prometheus-operator --set 'grafana.adminPassword=bRmG9agqbdQUFUqw,grafana.service.type=NodePort,grafana.service.nodePort=3000'

访问监控界面

URL: 节点IP:3000
用户名: admin
密码: bRmG9agqbdQUFUqw