kubernetes 部署prometheus笔记 (四)

时间:2025-05-13 07:07:16
  • apiVersion: apps/v1
  • kind: Deployment
  • metadata:
  • name: monitoring-grafana
  • namespace: kube-system
  • spec:
  • replicas: 1
  • selector:
  • matchLabels:
  • k8s-app: grafana
  • template:
  • metadata:
  • labels:
  • k8s-app: grafana
  • spec:
  • containers:
  • - name: grafana
  • image: grafana/grafana
  • # command: ["grafana-cli plugins install grafana-kubernetes-app & service grafana-server restart"]
  • # ports:
  • # - containerPort: 3000
  • # protocol: TCP
  • volumeMounts:
  • - mountPath: /etc/ssl/certs
  • name: ca-certificates
  • readOnly: true
  • - mountPath: /var
  • name: grafana-storage
  • env:
  • #- name: INFLUXDB_HOST
  • # value: monitoring-influxdb
  • #- name: GF_SERVER_HTTP_PORT
  • # value: "3000"
  • # The following env variables are required to make Grafana accessible via
  • # the kubernetes api-server proxy. On production clusters, we recommend
  • # removing these env variables, setup auth for grafana, and expose the grafana
  • # service using a LoadBalancer or a public IP.
  • - name: GF_AUTH_BASIC_ENABLED
  • value: "false"
  • - name: GF_AUTH_ANONYMOUS_ENABLED
  • value: "true"
  • - name: GF_AUTH_ANONYMOUS_ORG_ROLE
  • value: Admin
  • - name: GF_SERVER_ROOT_URL
  • # If you're only using the API Server proxy, set this value instead:
  • # value: /api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
  • value: /
  • - name: GF_INSTALL_PLUGINS
  • value: grafana-kubernetes-app #install kubernetes plugin
  • volumes:
  • - name: ca-certificates
  • hostPath:
  • path: /etc/ssl/certs
  • - name: grafana-storage
  • emptyDir: {}
  • ---
  • apiVersion: v1
  • kind: Service
  • metadata:
  • #labels:
  • # For use as a Cluster add-on (/kubernetes/kubernetes/tree/master/cluster/addons)
  • # If you are NOT using this as an addon, you should comment out this line.
  • # /cluster-service: 'true'
  • # /name: monitoring-grafana
  • name: monitoring-grafana
  • namespace: kube-system
  • spec:
  • # In a production setup, we recommend accessing Grafana through an external Loadbalancer
  • # or through a public IP.
  • # type: LoadBalancer
  • # You could also use NodePort to expose the service at a randomly-generated port
  • type: NodePort
  • ports:
  • - port: 80
  • targetPort: 3000
  • selector:
  • k8s-app: grafana