I have certain requirements where volumeMounts: should be an optional field.
spec:
volumes:
-
name: aaa
secret:
secretName: aaa-certs
containers:
-
name: my-celery
volumeMounts:
-
name: aaa
mountPath: /tmp/aaa_certs
readOnly: true
If secret is present then it will mount, else create an empty folder. Is this possible
Secret volumes can be marked as optional using tag "optional: true", and result in empty directories if the associated secret doesn't exist, rather than blocking pod startup.
Example:
spec:
volumes:
-
name: aaa
secret:
secretName: aaa-certs
optional: true
containers:
-
name: my-celery
volumeMounts:
-
name: aaa
mountPath: /tmp/aaa_certs
readOnly: true
No, that is not possible. You would need a higher level system like Helm or an operator to manage that kind of dynamic configuration.