0

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.

dan1st
  • 101
  • 3

0 Answers0