Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceMonitor not found in monitoring.coreos.com/v1

I am using kubeadm to deploy single node kubernetes 1.11 cluster. I am unable to find servicemonitor resources.

➜  kube-prometheus git:(master) ✗ kubectl get servicemonitor
error: the server doesn't have a resource type "servicemonitor"

➜  kube-prometheus git:(master) ✗ kubectl create -f manifests/prometheus-serviceMonitor.yaml
error: unable to recognize "manifests/prometheus-serviceMonitor.yaml": no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"

How do I enable servicemonitor with kubeadm?

like image 873
Steve Avatar asked Jun 29 '18 06:06

Steve


People also ask

What is Kubernetes ServiceMonitor?

The ServiceMonitor is used to define an application you wish to scrape metrics from within Kubernetes, the controller will action the ServiceMonitors we define and automatically build the required Prometheus configuration.

What is a Podmonitor?

ServiceMonitors and PodMonitors are both pseudo-CRDs that map the scrape configuration of the Prometheus custom resource. These configuration objects declaratively specify the endpoints that Prometheus will scrape metrics from.


2 Answers

The ServiceMonitor resource not part of Kubernetes itself. It is a custom resource which is part of the Prometheus operator as described here.

Make sure that you have installed the Prometheus operator (including the custom resources) beforehand to enable creating a ServiceMonitor object.

like image 155
Andreas Jägle Avatar answered Sep 21 '22 01:09

Andreas Jägle


kubectl create -f manifests/prometheus-serviceMonitor.yaml try to create resource type of ServiceMontor for prometheus. But you haven't created that custom resource type yet. So first create CustomResource ServiceMonitor by using this custom resource definition(CRD). you can use following command

kubectl create -f manifests/0prometheus-operator-0servicemonitorCustomResourceDefinition.yaml

But if you are trying to put up kube-prometheus or any other sub project of prometheus-operator. You can deploy the kube-prometheus stack by running all deployments in folder level as below.

kubectl create -f manifests/
like image 35
Hansika Weerasena Avatar answered Sep 21 '22 01:09

Hansika Weerasena