# 下载Kube-Prometheus项目
git clone https://gitee.com/Cancerking/k8s-project.git
# 安装Kube-Prometheus项目
cd k8s-project/kube-prometheus
kubectl apply --server-side -f manifests/setup
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done
kubectl apply -f manifests/
# 查看安装的资源
kubectl get all -n monitoring
kubectl get svc -n monitoring
# 修改网络 grafana、alertmanager、prometheus都配置成type: NodePort
vi manifests/grafana-service.yaml
spec:
ports:
- name: http
port: 3000
targetPort: http
type: NodePort
vi manifests/alertmanager-service.yaml
vi manifests/prometheus-service.yaml
kubectl apply -f manifests/grafana-service.yaml
kubectl apply -f manifests/alertmanager-service.yaml
kubectl apply -f manifests/prometheus-service.yaml
# 查看端口并访问
kubectl get svc -n monitoring
# 访问略
# 卸载Prometheus方式
kubectl delete --ignore-not-found=true -f manifests/ -f manifests/setup
Kubernetes部署系列:自动化构建Prometheus
最新推荐文章于 2024-09-13 09:21:48 发布