Deploying Prometheus

The templates we've prepared for this chapter can be found at the following link: https://github.com/PacktPublishing/DevOps-with-Kubernetes-Second-Edition/tree/master/chapter7.

Under 7-1_prometheus are the manifests of components to be used for this section, including a Prometheus deployment, exporters, and related resources. These will be deployed at a dedicated namespace, monitoring, except those components required to work in kube-system namespaces. Please review them carefully. For now, let's create our resources in the following order:

$ kubectl apply -f monitoring-ns.yml
$ kubectl apply -f prometheus/configs/prom-config-default.yml
$ kubectl apply -f prometheus

The resource usage, such as storage and memory, at the provided manifest for Prometheus is confined to a relatively low level. If you'd like to use them in a more realistic way, you can adjust your parameters according to your actual requirements. After the Prometheus server is up, we can connect to its web UI at port 9090 with kubectl port-forward. We can also use NodePort or Ingress to connect to the UI if we modify its service (prometheus/prom-svc.yml) accordingly. The first page we will see when entering the UI is the Prometheus expression browser, where we build queries and visualize metrics. Under the default settings, Prometheus will collect metrics by itself. All valid scraping targets can be found at the /targets path. To speak to Prometheus, we have to gain some understanding of its language: PromQL.

To run Prometheus in production, there is also a Prometheus Operator (https://github.com/coreos/prometheus-operator), which aims to simplify the monitoring task in Kubernetes by CoreOS. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset