yml file that provides cluster-wide access has the following elements: Namespaces are designed to limit permissions of default roles if we want to retrieve cluster-wide data we need to give Prometheus access to all resources of that cluster. A service that gives you access to the Prometheus user interface.Ĭluster Role, Service Account and Cluster Role Binding.The Prometheus configMap that defines which elements should be scrapped.Permissions that allow Prometheus to access all pods and nodes.The prometheus.yml file in our example instructs the kubectl to submit a request to the Kubernetes API server. In this example, all the elements are placed into a single. After you create each file, it can be applied by entering the following command: kubectl -f apply. The sections can be implemented as individual. The following section contains the necessary elements to successfully set up Prometheus scraping on your Kubernetes cluster and its elements. Regardless of the method used, list existing namespaces by using this command: kubectl get namespaces Configure Prometheus Deployment File Apply the file to your cluster by entering the following command in your command terminal: kubectl -f apply namespace monitoring.yml This method is convenient as you can deploy the same file in future instances. There are two ways to create a monitoring namespace for retrieving metrics from the Kubernetes API.Įnter this simple command in your command-line interface and create the monitoring namespace on your host: kubectl create namespace monitoringĬreate and apply a. For easy reference, we are going to name the namespace: monitoring. The name of the namespace needs to be a label compatible with DNS. To have better control over the cluster monitoring process, we are going to specify a monitoring namespace. Unless one is specified, the system uses the default namespace. Create Monitoring NamespaceĪll the resources in Kubernetes are started in a namespace. Instead, you should adequately edit these files to fit your system requirements. yml files below, in their current form, are not meant to be used in a production environment.