following imports to enable its patches // (import 'kube-prometheus/kube-prometheus-anti-affinity.libsonnet') + // (import 'kube-prometheus/kube-prometheus-managed-cluster.libsonnet') + // (import 'kube-prometheus/kube-prometheus-node-ports.libsonnet') + // (import 'kube-prometheus/kube-prometheus-static-etcd.libsonnet') + // (import 'kube-prometheus/kube-prometheus-thanos-sidecar.libsonnet') + // (import 'kube-prometheus/kube-prometheus-custom-metrics.libsonnet') + { _config+:: { namespace: 'monitoring', }, }; { ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields (kp.kubePrometheus) } + { ['setup/prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.filter((function(name) name != 'serviceMonitor' ), std.objectFields (kp.prometheusOperator)) } + // serviceMonitor is separated so that it can be created after the CRDs are ready { 'prometheus-operator-serviceMonitor' : kp.prometheusOperator.serviceMonitor } + { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields (kp.nodeExporter) } + { ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields (kp.kubeStateMetrics) } + { ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields (kp.alertmanager) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields (kp.prometheus) } + { ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields (kp.prometheusAdapter) } + { ['grafana-' + name]: kp.grafana[name] for name in std.objectFields (kp.grafana) }
and then wait for them to be availble before creating the remaining resources kubectl create -f manifests/setup until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done kubectl create -f manifests/