Hi team,
We are using the K8s module to patch our config map file.
The config map file which we are patching has 2 data.
The data which we pass its replacing the actual data.
We want to append the data in the current data field
Our code:
- name: Configure prometheus-server-conf
kubernetes.core.k8s:
state: patched
kind: ConfigMap
name: prometheus-server-conf
namespace: monitoring
definition:
data:
prometheus.yml: |-
scrape_configs:
- job_name: "ceph"
static_configs:
- targets: [' 10.0.1.34:9283', ' 10.0.1.35:9283', ' 10.0.1.36:9283']
Example:
we have a following file:
apiVersion: v1
data:
prometheus.yml: |-
scrape_configs:
- job_name: 'kubernetes-apiservers'
kubernetes_sd_configs:
- role: endpoints
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
relabel_configs:
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: default;kubernetes;https
We want the following:
apiVersion: v1
data:
prometheus.yml: |-
scrape_configs:
- job_name: 'kubernetes-apiservers'
kubernetes_sd_configs:
- role: endpoints
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
relabel_configs:
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
action: keep
regex: default;kubernetes;https
- job_name: "ceph"
static_configs:
- targets: [' 10.0.1.34:9283', ' 10.0.1.35:9283', ' 10.0.1.36:9283']
The following is happening:
apiVersion: v1
data:
prometheus.yml: |-
scrape_configs:
- job_name: "ceph"
static_configs:
- targets: [' 10.0.1.34:9283', ' 10.0.1.35:9283', ' 10.0.1.36:9283']
Kindly help.