This project is the integration of kube-prometheus-stack, including deployment, installation, setup, and usage.
- Add the repository of project
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm search repo prometheus-community --versions- Select a version and export the file 'values.yaml' to the current directory
helm show values prometheus-community/kube-prometheus-stack --version 78.3.2 > ./values.yaml- Install the project
helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --version 78.3.2 -n monitoring -f ./values.yaml- Check the running status of the project, which is installed by default in the namespace 'monitoring'
helm list -n monitoringDirectly deleting the helm chart project will delete all related resources
helm uninstall kube-prometheus-stack -n monitoringUse the following command to apply your values.yaml file
helm upgrade kube-prometheus-stack prometheus-community/kube-prometheus-stack -n monitoring -f ./values.yaml- You can set the type of prometheus service to NodePort and expose a port, and then access the web page through this node and port.
# values.yaml
prometheus:
service:
type: NodePort
nodePort: 32006- You can set the type of grafana service to NodePort and expose a port, and then access the web page through this node and port.
# values.yaml
grafana:
service:
type: NodePort
nodePort: 32007Prometheus listens to the created ServiceMonitors, which indicate how Prometheus accesses the metrics server.
- Create a ServiceMonitor for the specified metrics server in this project.
If your environment does not have a ServiceMonitor CRD and you do not want to create it, you can use this method to create the ServiceMonitor in the namespace.
# Monitor the specified serviceMonitor for the namespace 'mongodb-k8s-operator-system'
# values.yaml
prometheus:
additionalServiceMonitors:
- name: "mongodb-k8s-operator-controller-manager-metrics-monitor"
selector:
matchLabels:
app.kubernetes.io/name: "mongodb-k8s-operator"
namespaceSelector:
matchNames:
- "mongodb-k8s-operator-system"
endpoints:
- port: "https"
bearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token"
path: /metrics
scheme: https
tlsConfig:
insecureSkipVerify: true- Monitor an existing ServiceMonitor
# Monitor the specified serviceMonitor for the namespace 'mongodb-k8s-operator-system'
# values.yaml
prometheus:
prometheusSpec:
serviceMonitorSelector:
matchLabels:
app.kubernetes.io/name: "mongodb-k8s-operator"
serviceMonitorNamespaceSelector:
matchLabels:
kubernetes.io/metadata.name: mongodb-k8s-operator-system