Skip to content

Massive problem trying to replace strings within a configmap yaml file #423

@cheuk209

Description

@cheuk209

Hello I have created a bunch of Alert rules (for Grafana) in the form of a configmap:

kind: ConfigMap
apiVersion: v1
metadata:
  name: thanos-ruler-custom-rules
  namespace: open-cluster-management-observability
  annotations:
    argocd.argoproj.io/sync-wave: "2"
data:
  custom_rules.yaml: |
    groups:
      - name: app-XXXXX
        rules:
        - alert: XXXRefreshXX
          annotations:
            description: "TEST TESTXXXXX {{ $labels.zoneId }} {{ $labels.cluster }}"
            summary: "EPC Refresh rate above 7s for more than 1 minute."
            runbook_url: bitbucket-xxx.com/projects/XXX/rXXXXXX/k8s/argocd/overlay/env/XXXXrunbook.md
            dashboard_url: "grafana-xxx.com/d/bey8yi92day2oe/XXXXX=1&from=now-1h&to=now&timezone=XXX%2FLondon&var-cluster=$__all&var-envname=XXXXr&var-App=$__all&var-Filters=&var-XXX=$__all&refresh=1m&actionView=breakdown&var-groupby=app_type&metricPrefix=all&viewPanel=panel-886"
          expr: max by (zoneId, cluster)(zone_cache_update_times_seconds_max) > 5
          for: 1m
          labels:
            severity: critical
            ServiceType: "App XXX"

This DOES WORK. My problem is I need to promote this configmap into many different environments.

So currently the runbook and dashboard URLs are both hardcoded. Is there a way to use Kustomize to painlessly substitute these URLs?

I have experimented with patchstrategicmerge locally, but it is a pain. It seems there is no "elegant" way to replace them strings. I have tried using replacement and it does not work well at all, and I fell down a rabbit hole experimenting with delimiters and replacements.

No good. PLease halp!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions