其他分享
首页 > 其他分享> > k8s安装prometheus

k8s安装prometheus

作者:互联网

根据自己的k8s版本下载prometheus,我的是1.23

git clone -b v0.10.0 https://github.com/prometheus-operator/kube-prometheus.git

查看需要单独下载的镜像,从hub.docker.com上自己查找下同样版本的镜像,下载完后改下yaml文件image

grep image ./* | grep k8s.
docker pull bitnami/kube-state-metrics:2.3.0
docker pull rgwrgw555/prometheus-adapter:v0.9.1
vim ./kubeStateMetrics-deployment.yaml
vim ./prometheusAdapter-deployment.yaml

部署

cd kube-prometheus
kubectl apply --server-side -f manifests/setup
kubectl create -f .

修改Prometheus的Service为NodePort

vim prometheus-service.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: prometheus
    app.kubernetes.io/instance: k8s
    app.kubernetes.io/name: prometheus
    app.kubernetes.io/part-of: kube-prometheus
    app.kubernetes.io/version: 2.32.1
  name: prometheus-k8s
  namespace: monitoring
spec:
  type: NodePort
  ports:
  - name: web
    port: 9090
    targetPort: web
    nodePort: 31090
  - name: reloader-web
    port: 8080
    targetPort: reloader-web
  selector:
    app.kubernetes.io/component: prometheus
    app.kubernetes.io/instance: k8s
    app.kubernetes.io/name: prometheus
    app.kubernetes.io/part-of: kube-prometheus
  sessionAffinity: ClientIP
  
kubectl apply -f prometheus-service.yaml

浏览器访问

修改Grafana的Service

vim grafana-service.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: grafana
    app.kubernetes.io/name: grafana
    app.kubernetes.io/part-of: kube-prometheus
    app.kubernetes.io/version: 8.3.3
  name: grafana
  namespace: monitoring
spec:
  type: NodePort
  ports:
  - name: http
    port: 3000
    targetPort: http
    nodePort: 30300
  selector:
    app.kubernetes.io/component: grafana
    app.kubernetes.io/name: grafana
    app.kubernetes.io/part-of: kube-prometheus

kubectl apply -f grafana-service.yaml

 

标签:name,kubernetes,app,yaml,prometheus,io,k8s,安装
来源: https://www.cnblogs.com/zyyang1993/p/16553959.html