Deploy peromethues in new cluster crd issue

3/13/2019

Im trying to create prometheus with operator in fresh new k8s cluster I use the following files ,

  1. First step I’m creating a namespace monitoring
  2. apply this file , which works ok
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  labels:
    k8s-app: prometheus-operator
  name: prometheus-operator
  namespace: monitoring
spec:
  replicas: 2
  selector:
    matchLabels:
      k8s-app: prometheus-operator
  template:
    metadata:
      labels:
        k8s-app: prometheus-operator
    spec:
      priorityClassName: "operator-critical"
      tolerations:
      - key: "WorkGroup"
        operator: "Equal"
        value: "operator"
        effect: "NoSchedule"
      - key: "WorkGroup"
        operator: "Equal"
        value: "operator"
        effect: "NoExecute"
      containers:
      - args:
        - --kubelet-service=kube-system/kubelet
        - --logtostderr=true
        - --config-reloader-image=quay.io/coreos/configmap-reload:v0.0.1
        - --prometheus-config-reloader=quay.io/coreos/prometheus-config-reloader:v0.29.0
        image: quay.io/coreos/prometheus-operator:v0.29.0
        name: prometheus-operator
        ports:
        - containerPort: 8080
          name: http
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
      nodeSelector:
      serviceAccountName: prometheus-operator

Now I want to apply this file (CRD)

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: prometheus
  namespace: monitoring
  labels: 
    prometheus: prometheus
spec:
  replica: 1
  priorityClassName: "operator-critical"
  serviceAccountName: prometheus
  nodeSelector:
        worker.garden.sapcloud.io/group: operator
  serviceMonitorNamespaceSelector: {}
  serviceMonitorSelector:
    matchLabels:
      role: observeable
  tolerations:
  - key: "WorkGroup"
    operator: "Equal"
    value: "operator"
    effect: "NoSchedule"
  - key: "WorkGroup"
    operator: "Equal"
    value: "operator"
    effect: "NoExecute"

And Im getting error :

error: unable to recognize "1500-prometheus-crd.yaml": no matches for kind "Prometheus" in version "monitoring.coreos.com/v1"

I found this https://github.com/coreos/prometheus-operator/issues/1866 , but I try to do it as mentioned, I.e. Wait a few second and deploy again but it doesn’t help. Any idea ?

Also tried to delete the ns and create it again with the configs and I got the same issue. please advice

-- Jenny M
amazon-web-services
google-cloud-platform
kubernetes
prometheus
prometheus-operator

1 Answer

3/13/2019

You need to install the custom resources as available objects in Kubernetes before you can create instances of them.

-- Lukas Eichler
Source: StackOverflow