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

Example Analysis of K8S deployment Monitoring

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

Share

Shulou(Shulou.com)05/31 Report--

K8S deployment monitoring example analysis, for this problem, this article details the corresponding analysis and solution, hoping to help more small partners who want to solve this problem find a simpler and easier way.

kubernetes cluster monitoring scheme has many combinations to monitor it, but after version 1.12, prometheus-operator + grafana is usually selected for monitoring.

1 Download Project

git clone https://github.com/coreos/kube-prometheus.git is because this year prometheus-operator project moved to coreos/kube-prometheus

2 typesetting

cd kube-prometheus/manifests/mkdir -p operator node-exporter alertmanager grafana kube-state-metrics prometheus serviceMonitor adaptermv *-serviceMonitor* serviceMonitor/mv 0prometheus-operator* operator/mv grafana-* grafana/mv kube-state-metrics-* kube-state-metrics/mv alertmanager-* alertmanager/mv node-exporter-* node-exporter/mv prometheus-adapter* adapter/mv prometheus-* prometheus/

3 Creating a namespace

kubectl apply -f 00namespace-namespace.yaml

4 Creating an operator

kubectl apply -f operator/view podkubectl get pods -n monitoring etc. pods are created in the next step

5 Creating other CRDs

kubectl apply -f adapter/kubectl apply -f alertmanager/kubectl apply -f node-exporter/kubectl apply -f kube-state-metrics/kubectl apply-f grafana/kubectl apply -f prometheus/kubectl apply -f serviceMonitor/view podkubectl get pods -n monitoring View servicekubectl get svc -n monitoring Found all prometheus and grafana are accessible inside the cluster

6 Make prometheus and grafana accessible outside the cluster

There are two ways to achieve this function 1) nodeport mode 2) ingress-nginx mode here for testing select nodeport mode modify prometheus# vim prometheus/prometheus-service.yaml apiVersion: v1kind: Servemetatus: labels: prometheus: k8s name: prometheus-k8s namespace: monitoringspec: ports: - name: web port: 9090 targetPort: web type: NodePort selector: app: prometheus prometheus: k8s sessionAffinity: ClientIP~ add nodeportkubectl apply -f prometheus/prometheus-service.yaml grafana# vim grafana/grafana-service.yaml apiVersion: v1kind: Servicemetadata: labels: app: grafana name: grafana namespace: monitoringspec: ports: - name: http port: 3000 targetPort: http type: NodePort selector: app: grafanakubectl apply -f grafana/grafana-service.yaml View sevice Mainly View nodeport We can visit # kubectl get svc -n monitoringNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEalertmanager-main ClusterIP 10.99.60.117 9093/TCP 67malertmanager-operated ClusterIP None 9093/TCP,6783/TCP 67mgrafana NodePort 10.105.159.125 3000:31746/TCP 67mkube-state-metrics ClusterIP None 8443/TCP,9443/TCP 67mnode-exporter ClusterIP None 9100/TCP 67mprometheus-adapter ClusterIP 10.102.146.18 443/TCP 67mprometheus-k8s NodePort 10.107.201.125 9090:32040/TCP 67mprometheus-operated ClusterIP None 9090/TCP 67mprometheus-operator ClusterIP None ~

7 Visit grafana web page

http://masterip:31746

About K8S deployment monitoring sample analysis questions to share the answer here, I hope the above content can have some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.

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