Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

K8S practice Ⅸ (Cluster Monitoring)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Introduction of PrometheusOperator

PrometheusOperator is an open source CoreOS controller for managing Prometheus on Kubernetes clusters, simplifying the deployment, management, and operation of Prometheus and Alertmanager clusters on Kubernetes.

II. Deployment

1. Download deployment files from the official

# git clone https://github.com/coreos/kube-prometheus.git

two。 Change the address of the image warehouse

# mkdir prometheus# cp kube-prometheus/manifests/* prometheus/# sed-I's roomk8s.gcr.ioroomgcr.azk8s.CN _

3. Deploy all resources

# kubectl apply-f prometheus/

4. View the created ns and crd

# kubectl get ns | grep monitoringmonitoring Active 3m30s# kubectl get crdNAME CREATED ATalertmanagers.monitoring.coreos.com 2019-09-10T09:13:00Zpodmonitors.monitoring.coreos.com 2019-09-10T09:13:00Zprometheuses.monitoring.coreos.com 2019-09-10T09:13:01Zprometheusrules.monitoring.coreos.com 2019-09-10T09:13:02Zservicemonitors.monitoring.coreos.com 2019-09-10T09:13:03Z

5. View all pod and svc under monitoring

# kubectl get pod-n monitoringNAME READY STATUS RESTARTS AGEalertmanager-main-0 2 23halertmanager-main-2 2 Running 0 23halertmanager-main-1 2 23hgrafana-57bfdd47f8-bhkvv 2 Running 0 23halertmanager-main-2 2 Running 0 23hgrafana-57bfdd47f8-bhkvv 1/1 Running 0 23hkube-state-metrics-8cf4797dc-7dg4w 4/4 Running 0 23hnode-exporter-446xd 2/2 Running 0 23hnode-exporter-8sbsf 2/2 Running 0 23hnode-exporter-dk7qk 2/2 Running 0 23hnode-exporter-vdsqg 2/2 Running 0 23hnode-exporter-w7czt 2/2 Running 0 23hnode-exporter-wx7vj 2/2 Running 0 23hprometheus-adapter-6b9989ccbd-bcl2h 1/1 Running 0 23hprometheus-k8s-0 3/3 Running 1 23hprometheus -k8s-1 3 Running 1 23hprometheus-operator-7894d75578-rg2gl 1 Running 0 23h# kubectl get svc-n monitoringNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEalertmanager-main NodePort 10.97.155.71 9093:30093/TCP 23halertmanager-operated ClusterIP None 9093/TCP 9094/TCP,9094/UDP 23hgrafana NodePort 10.110.28.251 3000:30030/TCP 23hkube-state-metrics ClusterIP None 8443/TCP 9443/TCP 23hnode-exporter ClusterIP None 9100/TCP 23hprometheus-adapter ClusterIP 10.111.75.114 443/TCP 23hprometheus-k8s NodePort 10.109.3.70 9090:30090/TCP 23hprometheus-operated ClusterIP None 9090/TCP 23hprometheus-operator ClusterIP None 8080/TCP 23h

6. Change the port mode to NodePort mapped port

# kubectl edit svc prometheus-k8s-n monitoringservice/prometheus-k8s edited# kubectl edit svc grafana-n monitoringservice/grafana edited# kubectl edit svc alertmanager-main-n monitoringservice/alertmanager-main edited# kubectl get svc-n monitoring | grep NodePortalertmanager-main NodePort 10.97.155.71 9093:30093/TCP 21hgrafana NodePort 10.110.28.251 3000:30030/TCP 21hprometheus-k8s NodePort 10.109.3.70 9090:30090/TCP 21h

7. Access test

III. Configuration

1. View the targets page of prometheus

It is found that the two system components kube-controller-manager and kube-scheduler are not monitored, which is related to the definition of ServiceMonitor.

# cat prometheus/prometheus-serviceMonitorKubeScheduler.yamlapiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata: labels: k8s-app: kube-scheduler name: kube-scheduler namespace: monitoringspec: endpoints:-interval: 30s port: http-metrics jobLabel: k8s-app namespaceSelector: matchNames:-kube-system selector: matchLabels: k8s-app: kube-scheduler

Selector.matchLabels matches a Service with k8s-app=kube-scheduler under the namespace kube-system, but there is no corresponding Service in the system.

two。 Create Service corresponding to kube-controller-manager and kube-scheduler

# cat cms-svc.yaml apiVersion: v1kind: Servicemetadata: namespace: kube-system name: kube-controller-manager labels: k8s-app: selector: component: kube-controller-manager ports:-name: http-metrics port: 10252 targetPort: 10252 protocol: TCP---apiVersion: v1kind: Servicemetadata: namespace: kube-system name: kube-scheduler labels: k8s-app: kube-schedulerspec: selector: component: kube-scheduler ports:-name : http-metrics port: 10251 targetPort: 10251 protocol: TCP# kubectl describe pod kube-controller-manager-k8s-master01-n kube-systemLabels: component=kube-controller-manager tier=control-plane

3. Check to see if kube-controller-manager and kube-scheduler are normal

4. Visit Grafana

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report