Score:0

Replacing arbitrary fields in Kubernetes YAML

gb flag

I want to use configMap variables inside my Kubernetes YAML outside of my container specification.

Basically, I am looking for a way to replace text in my configuration with the value of a configMap entry due to me having almost the same resources in multiple namespaces.

For example, imagine the following configMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  system.host: host.example.com

Then, I want to use the values of this configMap inside of other resources, e.g. an HttpRoute:

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: my-system-route
spec:
  parentRefs:
  - name: my-gateway
    namespace: my-gateway-namespace
  hostnames:
    # I would imagine something along the lines of this
  - ${config/my-config/system.host}
  rules:
  - matches:
    - path:
        value: /
    backendRefs:
    - name: my-backend-service
      port: 8080
      kind: Service

and get ${config/my-config/system.host} replaced with host.example.com.

Ideally, I want Kubernetes to replace that and not using other CLI tools as I want it to be possible to apply the configuration from different systems/OSes.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.