in kubernetes a variable within a path can be used

To use mountpath with env variable you can use subPath with expanded environment variables (k8s v1.17+).

In your case it would look like following:

containers:
- env:
  - name: MY_POD_NAME
    valueFrom:
      fieldRef:
        fieldPath: metadata.name
  volumeMounts:
  - mountPath: /cache
    name: shared-folder
    subPathExpr: $(MY_POD_NAME)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top