In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
In earlier versions, Kubernetes provided a combination of heapster, influxDB and grafana to monitor the system, but now a more popular monitoring tool is that prometheus,prometheus is an open source version of Google's internal monitoring alarm system.
At present, the monitoring solutions of Kubernetes cluster mainly include the following:
1. Heapster:Heapster is a cluster-wide monitoring and data aggregation tool that runs in the cluster in the form of Pod.
2. Metrics-server:metrics-server is also a cluster-wide resource data aggregation tool and a substitute for Heapster. Similarly, metrics-server only displays data and does not provide data storage services.
3. CAdvisor:cAdvisor is an open source container resource monitoring and performance analysis tool for Google. It is specially made for containers and also supports Docker containers. In Kubernetes, we do not need to install it separately. CAdvisor can be used directly as a part of the built-in kubelet program.
4. Kube-state-metrics:kube-state-metrics generates status metrics about resource objects, such as Deployment, Node and Pod, by listening to API Server. It should be noted that kube-state-metrics simply provides metrics data and does not store these metrics data, so we can use Prometheus to grab these data and store them.
Compared with other traditional monitoring tools, Prometheus mainly has the following characteristics:
A multidimensional data model with time series data identified by metric name and key / value pairs
There is a flexible query language
Does not rely on distributed storage, only related to local disks
Pull time series data through HTTP service
Push is also supported to add time series data
It also supports discovery of targets through service discovery or static configuration
Multiple graphics and dashboard support
Prometheus consists of several components, but many of them are optional:
Prometheus Server: used to capture metrics and store time series data
Exporter: exposure indicators let the task catch
Pushgateway:push pushes metric data to the gateway
Alertmanager: alarm component for handling alarm
Adhoc: for data query
1. Create a separate namespace
ApiVersion: v1kind: Namespacemetadata: name: kube-ops
2. Manage the configuration file prometheus.yml as configmap
ApiVersion: v1kind: ConfigMapmetadata: name: prometheus-config namespace: kube-opsdata: prometheus.yml: | global: scrape_interval: 15s scrape_timeout: 15s scrape_configs:-job_name: 'prometheus' static_configs:-targets: [' localhost:9090']
The configuration file prometheus.yml contains three modules: global, rule_files and scrape_configs
Where the global module controls the global configuration of Prometheus Server
The rule_files module defines the location of the rules. Prometheus can load rules according to this configuration, which can be used to generate new time series data or alarm messages. Currently, we have not configured any rules.
Scrape_configs is used to control which resources are monitored by prometheus.
In the default configuration, there is a separate job called prometheus, which collects time series data from the prometheus service itself. This job contains a separate, statically configured target: listening on port 9090 on localhost.
By default, prometheus collects metrics through the / metrics path of the target. Therefore, the default job collects metrics through URL: http://localhost:9090/metrics.
3. Configure rbac authentication
ApiVersion: v1kind: ServiceAccountmetadata: name: prometheus namespace: kube-ops---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata: name: prometheusrules:- apiGroups:-"" resources:-nodes-services-endpoints-pods-nodes/proxy verbs:-get- list-watch- apiGroups:-"" resources:-configmaps-nodes/metrics verbs:-get- nonResourceURLs:-/ metrics verbs:-get---apiVersion: rbac. Authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata: name: prometheusroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: prometheussubjects:- kind: ServiceAccount name: prometheus namespace: kube-ops
4. Configure pv and pvc for data persistence
ApiVersion: v1kind: PersistentVolumemetadata: name: prometheusspec: capacity: storage: 10Gi accessModes:-ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: server: 192.168.1.244 path: / data/k8s---apiVersion: v1kind: PersistentVolumeClaimmetadata: name: prometheus namespace: kube-opsspec: accessModes:-ReadWriteOnce resources: requests: storage: 10Gi
5. Create Pod resources for prometheus
$docker pull prom/prometheus:v2.4.3
ApiVersion: extensions/v1beta1kind: Deploymentmetadata: name: prometheus namespace: kube-ops labels: app: prometheusspec: template: metadata: labels: app: prometheusspec: serviceAccountName: prometheus containers:-image: prom/prometheus:v2.4.3 name: prometheus command:-"/ bin/prometheus" args:-- config.file=/etc/prometheus/prometheus. Yml "--storage.tsdb.path=/prometheus"-- "--storage.tsdb.retention=24h"-web.enable-admin-api "# controls access to admin HTTP API It includes functions such as deleting time series-"--web.enable-lifecycle" # supports hot updates Execute localhost:9090/-/reload directly effective immediately ports:-containerPort: 9090 protocol: TCP name: http volumeMounts:-mountPath: "/ prometheus" subPath: prometheus name: data-mountPath: "/ etc/prometheus" name: config-volume resources: requests: cpu: 100m Memory: 512Mi limits: cpu: 100m memory: 512Mi securityContext: runAsUser: 0 volumes:-name: data persistentVolumeClaim: claimName: prometheus- configMap: name: prometheus-config name: config-volume
$kubectl get pod-n kube-ops
Prometheus-77d968648-w5j6z 1/1 Running 53 82d
6. Create a svc for prometheus pod
ApiVersion: v1kind: Servicemetadata: name: prometheus namespace: kube-ops labels: app: prometheusspec: selector: app: prometheus type: NodePort ports:-name: web port: 9090 targetPort: http
$kubectl get svc-n kube-ops
Prometheus NodePort 10.102.197.83 9090:32619/TCP
Http://192.168.1.243:32619
Click status----targets to view the status of the monitoring directory
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.