From 50583c4b0e689de8f4a64f52e6c73b00e2e8df27 Mon Sep 17 00:00:00 2001 From: koba1t Date: Thu, 14 Apr 2022 23:58:32 +0900 Subject: [PATCH] add Story of yaml in configmap and json in Annotations --- .../22-03-value-in-the-structured-data.md | 101 +++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/proposals/22-03-value-in-the-structured-data.md b/proposals/22-03-value-in-the-structured-data.md index 91ea3c756..1e68da464 100644 --- a/proposals/22-03-value-in-the-structured-data.md +++ b/proposals/22-03-value-in-the-structured-data.md @@ -341,13 +341,112 @@ metadata: #### Story 3 -Scenario summary: As a [end user, extension developer, ...], I want to [...] +Scenario summary: Replacement the value inside for yaml in the configMap. +A few applications require to use yaml format config file, and some major cloudnative applications are using that.(ex, Prometheus,AlertManager)\ +A value you want to overlay in yaml is usually into a nested yaml structure. So if you can overlay value inside yaml, you won't need to copy a whole yaml file. + +```yaml +## source +apiVersion: v1 +kind: ConfigMap +metadata: + name: environment-config +data: + env: dev +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-config +data: + prometheus.yml: |- + global: + external_labels: + prometheus_env: TARGET_ENVIROMENT + scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] +``` + +```yaml +## replacement +replacements: +- source: + kind: ConfigMap + name: environment-config + fieldPath: data.env + targets: + - select: + kind: ConfigMap + name: prometheus-config + fieldPaths: + - prometheus\.yml + options: + format: 'yaml' + formatPath: '/global/external_labels/prometheus_env' +``` + +```yaml +## expected +apiVersion: v1 +kind: ConfigMap +metadata: + name: environment-config +data: + env: dev +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-config +data: + prometheus.yml: |- + global: + external_labels: + prometheus_env: dev + scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] +``` + +#### Story 4 + +Scenario summary: Replacement the value inside for json in the annotations. + + +A few times, an application on your cluster requires to set json format config for the *Annotations* on kubernetes yaml resources. We need to overlay in this position value. + +##### Example +```yaml +apiVersion: v1 +kind: Service +metadata: + annotations: + cloud-provider/backend-config: '{"ports": {"appA":"referrence_from_appA"}}' +spec: + ports: + - name: appA + port: 1234 + protocol: TCP + targetPort: 8080 +``` + +- https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features#unique_backendconfig_per_service_port +- https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.2/guide/ingress/annotations/#listen-ports + + ### Risks and Mitigations