Can I reference to configmap dynamically in deployment?

Hi,

I have a ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: poc-es-indx-mgmt
  labels:
    cluster: poc
    app: es-index-mgmt
    product: elasticStack
data:
  tasks.csv: |
    plx_;7
    plx_fulltext;1
    metricbeat;7

I have a deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: poc-es-index-management
  labels:
    cluster: poc
    app: es-index-mgmt
    product: elasticStack
spec:
  selector:
    matchLabels:
      app: es-index-mgmt
      cluster: poc
  replicas: 1
  template:
    metadata:
      labels:
        app: es-index-mgmt
        cluster: poc
    spec:
      securityContext:
        runAsNonRoot: true
      containers:
      - name: es-idx-mgmt
        image: docker-registry:443/elastic.job.index-management:0.1.3
        env:
          - name: ES_HOST
            value: "poc-es-master"
          - name: ES_PORT
            value: "9200"
        volumeMounts:
        - name: tasklist-config
          mountPath: /plx/elastic/index_management/delete/config/tasks.csv
          subPath: tasks.csv
          readOnly: true
      volumes:
        - name: tasklist-config
          configMap:
            name: poc-es-indx-mgmt

Is it possible to use some selectors or sth similar dynamical fetch the configMap.name of the volume section?
I want to:

  • get the value of label cluster of this deployment
  • use configMap which fulfills following labels: cluster=(value of label cluster of this deployment),app=es-index-mgmt,product=elasticStack

This would make it much easier if I deploy a second application cluster.

Is this possible?
Thanks a lot, Andreas