helm kube-prometheus-stack 部署

2024-08-06 319 0

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
[root@harbor ~]# helm repo update

[root@harbor ~]# helm search repo prometheus
NAME                                                CHART VERSION   APP VERSION DESCRIPTION                                       
prometheus-community/kube-prometheus-stack          61.7.1          v0.75.2     kube-prometheus-stack collects Kubernetes manif...
prometheus-community/prometheus                     25.25.0         v2.53.1     Prometheus is a monitoring system and time seri...
prometheus-community/prometheus-adapter             4.10.0          v0.11.2     A Helm chart for k8s prometheus adapter           
prometheus-community/prometheus-blackbox-exporter   9.0.0           v0.25.0     Prometheus Blackbox Exporter                      
prometheus-community/prometheus-cloudwatch-expo...  0.25.3          0.15.5      A Helm chart for prometheus cloudwatch-exporter   
prometheus-community/prometheus-conntrack-stats...  0.5.10          v0.4.18     A Helm chart for conntrack-stats-exporter         
prometheus-community/prometheus-consul-exporter     1.0.0           0.4.0       A Helm chart for the Prometheus Consul Exporter   
prometheus-community/prometheus-couchdb-exporter    1.0.0           1.0         A Helm chart to export the metrics from couchdb...
prometheus-community/prometheus-druid-exporter      1.1.0           v0.11.0     Druid exporter to monitor druid metrics with Pr...
....

安装

helm show values prometheus-community/kube-prometheus-stack > kube-prometheus-stack.yaml-default
[root@harbor ~]# cp kube-prometheus-stack.yaml-default kube-prometheus-stack.yaml
[
root@harbor ~]# kube-prometheus-stack.yaml
# true -> false
serviceMonitorSelectorNilUsesHelmValues: false

# helm install kps prometheus-community/kube-prometheus-stack -f kube-prometheus-stack.yaml -n monitoring --create-namespace --version 37.2.0 --debug
[root@harbor ~]# helm install kps  prometheus-community/kube-prometheus-stack -f kube-prometheus-stack.yaml -n monitoring --create-namespace --version 61.7.1 --debug
[root@harbor ~]# kubectl --namespace monitoring get pods -l "release=kps"
[root@harbor ~]# kubectl --namespace monitoring get pods
NAME                                                    READY   STATUS    RESTARTS   AGE
alertmanager-kps-kube-prometheus-stack-alertmanager-0   2/2     Running   0          3m5s
kps-grafana-7f845845bd-zqvfn                            3/3     Running   0          4m46s
kps-kube-prometheus-stack-operator-6ff646b6ff-rggpx     1/1     Running   0          4m46s
kps-kube-state-metrics-c5669c4d8-x6qkr                  1/1     Running   0          4m46s
kps-prometheus-node-exporter-27rs4                      1/1     Running   0          4m46s
kps-prometheus-node-exporter-7bk6j                      1/1     Running   0          4m46s
kps-prometheus-node-exporter-7wp57                      1/1     Running   0          4m46s
kps-prometheus-node-exporter-cnqzd                      1/1     Running   0          4m46s
kps-prometheus-node-exporter-m7q5z                      1/1     Running   0          4m46s
prometheus-kps-kube-prometheus-stack-prometheus-0       2/2     Running   0          3m4s

服务暴露

[root@harbor ~]# kubectl get pod -n ingress-nginx -owide
NAME                             READY   STATUS    RESTARTS   AGE    IP              NODE           NOMINATED NODE   READINESS GATES
ingress-nginx-controller-n7l8m   1/1     Running   0          5d9h   192.168.77.92   k8s-master02   <none>           <none>
ingress-nginx-controller-nrk4q   1/1     Running   0          5d9h   192.168.77.91   k8s-master01   <none>           <none>
ingress-nginx-controller-t47ph   1/1     Running   0          5d9h   192.168.77.93   k8s-master03   <none>           <none>

prometheus ingress

[root@harbor ~]# cat prometheus-ingress.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-prometheus                    #自定义ingress名称
  namespace: monitoring
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: prometheus.sundayhk.com                   # 自定义域名
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: kps-kube-prometheus-stack-prometheus     # 对应上面创建的service名称
            port:
              number: 9090
[root@harbor ~]# kubectl apply -f prometheus-ingress.yaml 
ingress.networking.k8s.io/ingress-prometheus created

prometheus.sundayhk.com域名与ingress 节点对应的IP进行解析即可访问。

192.168.77.91 prometheus.sundayhk.com

image.png

grafana ingress

[root@harbor ~]# cat grafana-ingress.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-grafana                    #自定义ingress名称
  namespace: monitoring
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: grafana.sundayhk.com                   # 自定义域名
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: kps-grafana     # 对应上面创建的service名称
            port:
              number: 80
[root@harbor ~]# kubectl apply -f grafana-ingress.yaml 
ingress.networking.k8s.io/ingress-grafana created

dns解析

192.168.77.92 grafana.sundayhk.com

image.png

查看用户名和密码

[root@harbor ~]# kubectl get secret kps-grafana -n monitoring -o yaml
apiVersion: v1
data:
  admin-password: cHJvbS1vcGVyYXRvcg==
  admin-user: YWRtaW4=
  ldap-toml: ""
kind: Secret

[root@harbor ~]# echo -n "YWRtaW4=" | base64 -d
admin
[root@harbor ~]# echo -n "cHJvbS1vcGVyYXRvcg==" | base64 -d
prom-operator

相关文章

KubeSphere DevOps 流水线JAVA项目配置
虚拟机热添加内存 Kubernetes未生效
Containerd镜像加速及私有仓库配置(用户密码和忽略HTTPS)
在Kubernetes集群部署kubesphere
使用KubeKey快速部署Kubernetes集群1.28.8
Rancher 快速创建RKE K8S集群

发布评论