How to attach a configmap to a workload in Tanzu Application Platform
search cancel

How to attach a configmap to a workload in Tanzu Application Platform

book

Article ID: 429288

calendar_today

Updated On:

Products

VMware Tanzu Platform - Kubernetes VMware Tanzu Application Platform

Issue/Introduction

I need to mount a configmap to a workload as a read-only volume (as per best practice). I found ResourceClaims could work, but the documentation mentions that a resource claimed with a ResourceClaim can only be associated to a single Workload.

Resolution

Depending on what you want to share via the configmap, here are two options:

Cartographer Workload object reference

Workload configuration variable reference

You can use a configuration like this:

apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
  name: my-workload
spec:
  env:
    - name: LOG_LEVEL
      valueFrom:
        configMapKeyRef:
          name: my-configmap
          key: log_level


... or you can attach a full configmap with a YAML file like this:

apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
  name: my-workload
spec:
  params:
    - name: configmap_name
      value: my-configmap