Skip to content

cilium install fails if serviceMonitors are enabled #1107

Closed

Description

Bug report

CLI fails to install Cilium if any of the serviceMonitors is enabled, even if correct CRDs are present in the cluster:

$ cilium install --helm-set prometheus.enabled=true --helm-set prometheus.serviceMonitor.enabled=true
🔮 Auto-detected Kubernetes kind: kind
✨ Running "kind" validation checks
✅ Detected kind version "0.17.0"
ℹ️  Using Cilium version 1.12.2
🔮 Auto-detected cluster name: kind-kind
🔮 Auto-detected datapath mode: tunnel
🔮 Auto-detected kube-proxy has been installed
ℹ️  helm template --namespace kube-system cilium cilium/cilium --version 1.12.2 --set cluster.id=0,cluster.name=kind-kind,encryption.nodeEncryption=false,ipam.mode=kubernetes,kubeProxyReplacement=disabled,operator.replicas=1,prometheus.enabled=true,prometheus.serviceMonitor.enabled=true,serviceAccounts.cilium.name=cilium,serviceAccounts.operator.name=cilium-operator,tunnel=vxlan
↩️ Rolling back installation...

Error: Unable to install Cilium: execution error at (cilium/templates/validate.yaml:21:9): Service Monitor requires monitoring.coreos.com/v1 CRDs. Please refer to https://github.com/prometheus-operator/prometheus-operator/blob/master/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml

$ kubectl get crd
NAME                                        CREATED AT
alertmanagerconfigs.monitoring.coreos.com   2022-09-26T09:14:26Z
alertmanagers.monitoring.coreos.com         2022-09-26T09:14:26Z
podmonitors.monitoring.coreos.com           2022-09-26T09:14:26Z
probes.monitoring.coreos.com                2022-09-26T09:14:26Z
prometheuses.monitoring.coreos.com          2022-09-26T09:14:26Z
prometheusrules.monitoring.coreos.com       2022-09-26T09:14:26Z
servicemonitors.monitoring.coreos.com       2022-09-26T09:14:26Z
thanosrulers.monitoring.coreos.com          2022-09-26T09:14:26Z

The helm template command fails to pass Cilium chart validation checking .Capabilities.APIVersions:

{{- if and .Values.prometheus.enabled (or .Values.prometheus.serviceMonitor.enabled .Values.operator.prometheus.serviceMonitor.enabled) }}
  {{- if not (.Capabilities.APIVersions.Has "monitoring.coreos.com/v1") }}
      {{ fail "Service Monitor requires monitoring.coreos.com/v1 CRDs. Please refer to https://github.com/prometheus-operator/prometheus-operator/blob/master/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml" }}
  {{- end }}
{{- end }}

As it doesn't interact with k8s API, it's not surprising. Still a bug though.

helm template allows to pass API versions in --api-versions argument (see docs), so it could be used to trick the validation check.

General Information

  • Cilium CLI v0.12.4
  • Kubernetes v1.25.2
  • kind

How to reproduce the issue

  1. create a fresh cluster
kind create cluster
  1. install prometheus-operator CRDs
helm template kube-prometheus prometheus-community/kube-prometheus-stack --include-crds \
  | yq 'select(.kind == "CustomResourceDefinition") * {"metadata": {"annotations": {"meta.helm.sh/release-name": "kube-prometheus", "meta.helm.sh/release-namespace": "monitoring"}}}' \
  | kubectl create -f - || true
  1. try to install Cilium
cilium install --helm-set prometheus.enabled=true --helm-set prometheus.serviceMonitor.enabled=true

Activity

  1. ghost added
    kind/bug
    on Sep 26, 2022
  2. added 4 commits that reference this issue on Oct 26, 2022
    1cda8b8
    89e54ea
    25c7d70
    b012dd6
  3. added a commit that references this issue on Oct 29, 2022
    aec044a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions