安装 Helm 和 Prometheus
安装 Helm
将以下命令复制后粘贴到终端:
install_helmv3() {
if ! hash wget &>/dev/null;then
if grep 'Ubuntu' /etc/os-release &>/dev/null;then
apt install wget -y
else
yum install wget -y
fi
fi
wget http://ops.dosec.cn/directlink/tools/helm-v3.3.0-linux-amd64.tar.gz
tar xf helm-v3.3.0-linux-amd64.tar.gz
cp linux-amd64/helm /usr/local/bin
rm -rf linux-amd64
# helm completion
echo "source <(helm completion bash)" >> ~/.bashrc
exec $SHELL -l
}
init_helmv3() {
# 添加阿里云 APPHub 和微软 Azure 提供的 Charts 镜像
# helm repo add local http://127.0.0.1:8879/charts
# v2 版本默认会增加上面这个本地 repo, 这里记录一下备用
helm repo add stable https://apphub.aliyuncs.com
helm repo add azure http://mirror.azure.cn/kubernetes/charts/
helm repo add incubator http://mirror.azure.cn/kubernetes/charts/
# 更新本地 charts repo
helm repo update
}
安装 Helmv3
install_helmv3
初始化 Helm 仓库
init_helmv3
安装 Prometheus
创建命名空间
kubectl create namespace monitoring
安装 Prometheus
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