ServiceMonitor not found in monitoring.coreos.com/v1
Asked Answered
A

3

12

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?

Adaadabel answered 29/6, 2018 at 6:28 Comment(1)
Check on what K8s versions support that resource.Butchery
P
10

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.

Pilcomayo answered 30/6, 2018 at 10:28 Comment(0)
H
2

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/
Harness answered 20/12, 2018 at 21:58 Comment(2)
The link is not working anymore. can you update it?Congruency
the CRD has been moved here: github.com/prometheus-operator/kube-prometheus/blob/main/…Scientist
P
2

serviceMonitor kind is not default in kubernetes cluster and it can be installed in the cluster by

kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml

This will be install few more other components, create this in separate namespace and remove it !!

Partisan answered 29/4, 2022 at 6:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.