apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-monitoring-config
  namespace: {{ openshift_cluster_monitoring_operator_namespace }}
data:
  config.yaml: |+
    prometheusOperator:
      baseImage: {{ openshift_cluster_monitoring_operator_prometheus_operator_repo }}
      prometheusConfigReloaderBaseImage: {{ openshift_cluster_monitoring_operator_prometheus_reloader_repo }}
      configReloaderBaseImage: {{ openshift_cluster_monitoring_operator_configmap_reloader_repo }}
{% if openshift_cluster_monitoring_operator_node_selector is iterable and openshift_cluster_monitoring_operator_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in openshift_cluster_monitoring_operator_node_selector.items() %}
        {{ key }}: "{{ value }}"
{% endfor %}
{% endif %}
    prometheusK8s:
{% if openshift_cluster_monitoring_operator_prometheus_retention %}
      retention: {{ openshift_cluster_monitoring_operator_prometheus_retention }}
{% endif %}
      baseImage: {{ openshift_cluster_monitoring_operator_prometheus_repo }}
{% if openshift_cluster_monitoring_operator_node_selector is iterable and openshift_cluster_monitoring_operator_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in openshift_cluster_monitoring_operator_node_selector.items() %}
        {{ key }}: "{{ value }}"
{% endfor %}
{% endif %}
      externalLabels:
        cluster: {{ openshift_cluster_monitoring_operator_cluster_id }}
{% if openshift_cluster_monitoring_operator_prometheus_storage_enabled | bool %}
      volumeClaimTemplate:
        spec:
{% if openshift_cluster_monitoring_operator_prometheus_storage_class_name %}
          storageClassName: {{ openshift_cluster_monitoring_operator_prometheus_storage_class_name }}
{% endif %}
          resources:
            requests:
              storage: {{ openshift_cluster_monitoring_operator_prometheus_storage_capacity }}
{% endif %}
    alertmanagerMain:
      baseImage: {{ openshift_cluster_monitoring_operator_alertmanager_repo }}
{% if openshift_cluster_monitoring_operator_node_selector is iterable and openshift_cluster_monitoring_operator_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in openshift_cluster_monitoring_operator_node_selector.items() %}
        {{ key }}: "{{ value }}"
{% endfor %}
{% endif %}
{% if openshift_cluster_monitoring_operator_alertmanager_storage_enabled | bool %}
      volumeClaimTemplate:
        spec:
{% if openshift_cluster_monitoring_operator_alertmanager_storage_class_name %}
          storageClassName: {{ openshift_cluster_monitoring_operator_alertmanager_storage_class_name }}
{% endif %}
          resources:
            requests:
              storage: {{ openshift_cluster_monitoring_operator_alertmanager_storage_capacity }}
{% endif %}
    nodeExporter:
      baseImage: {{ openshift_cluster_monitoring_operator_node_exporter_repo }}
    grafana:
      baseImage: {{ openshift_cluster_monitoring_operator_grafana_image }}
{% if openshift_cluster_monitoring_operator_node_selector is iterable and openshift_cluster_monitoring_operator_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in openshift_cluster_monitoring_operator_node_selector.items() %}
        {{ key }}: "{{ value }}"
{% endfor %}
{% endif %}
    kubeStateMetrics:
      baseImage: {{ openshift_cluster_monitoring_operator_kube_state_metrics_image }}
{% if openshift_cluster_monitoring_operator_node_selector is iterable and openshift_cluster_monitoring_operator_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in openshift_cluster_monitoring_operator_node_selector.items() %}
        {{ key }}: "{{ value }}"
{% endfor %}
{% endif %}
    kubeRbacProxy:
      baseImage: {{ openshift_cluster_monitoring_operator_kube_rbac_proxy_image }}
    auth:
      baseImage: {{ openshift_cluster_monitoring_operator_proxy_image }}
{% if 'http_proxy' in openshift.common or 'https_proxy' in openshift.common or 'no_proxy' in openshift.common %}
    http:
{% endif %}
{% if 'http_proxy' in openshift.common %}
      httpProxy: {{ openshift.common.http_proxy }}
{% endif %}
{% if 'https_proxy' in openshift.common %}
      httpsProxy: {{ openshift.common.https_proxy }}
{% endif %}
{% if 'no_proxy' in openshift.common %}
      noProxy: {{ openshift.common.no_proxy }}
{% endif %}
{% if openshift_cluster_monitoring_operator_etcd_enabled | bool %}
    etcd:
      targets:
{% if openshift_cluster_monitoring_operator_etcd_hosts | default([], True) | length > 0 %}
        ips:
{% for host in openshift_cluster_monitoring_operator_etcd_hosts %}
        - "{{ host }}"
{% endfor %}
{% else %}
        selector:
          openshift.io/component: etcd
          openshift.io/control-plane: "true"
{% endif %}
{% endif %}
