Skip to content

Commit

Permalink
Fix Prometheus API resources
Browse files Browse the repository at this point in the history
  • Loading branch information
firmansyahn authored Sep 24, 2024
1 parent a3ad1b1 commit 1eb58a2
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions charts/common/templates/_prometheus.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,108 @@ SPDX-License-Identifier: APACHE-2.0
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API AlertmanagerConfig */}}
{{- define "common.capabilities.coreosMonitoringAlertmanagerConfig.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1alpha1/AlertmanagerConfig" -}}
{{- print "monitoring.coreos.com/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API Alertmanager */}}
{{- define "common.capabilities.coreosMonitoringAlertmanager.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/Alertmanager" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/Alertmanager" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API PodMonitor */}}
{{- define "common.capabilities.coreosMonitoringPodMonitor.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PodMonitor" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/PodMonitor" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API Probe */}}
{{- define "common.capabilities.coreosMonitoringProbe.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/Probe" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/Probe" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API Prometheus */}}
{{- define "common.capabilities.coreosMonitoringPrometheus.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/Prometheus" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/Prometheus" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API PrometheusAgent */}}
{{- define "common.capabilities.coreosMonitoringPrometheusAgent.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1alpha1/PrometheusAgent" -}}
{{- print "monitoring.coreos.com/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API PrometheusRule */}}
{{- define "common.capabilities.coreosMonitoringPrometheusRule.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/PrometheusRule" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/PrometheusRule" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API ScrapeConfig */}}
{{- define "common.capabilities.coreosMonitoringScrapeConfig.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1alpha1/ScrapeConfig" -}}
{{- print "monitoring.coreos.com/v1alpha1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API ServiceMonitor */}}
{{- define "common.capabilities.coreosMonitoringServiceMonitor.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ServiceMonitor" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/ServiceMonitor" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

{{/* Return the appropriate apiVersion for Prometheus API ThanosRuler */}}
{{- define "common.capabilities.coreosMonitoringThanosRuler.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1/ThanosRuler" -}}
{{- print "monitoring.coreos.com/v1" -}}
{{- else if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1beta1/ThanosRuler" -}}
{{- print "monitoring.coreos.com/v1beta1" -}}
{{- else -}}
{{- false -}}
{{- end -}}
{{- end -}}

0 comments on commit 1eb58a2

Please sign in to comment.