I've mounted the configmap in my deployment file but conditionally create a configmap through oc create configmap command during deployment. Is there a way I could mount the path in my deployment.yaml but when configmap is not there it can ignore that error and bring up the pods any how.
Writing CRD and CRD controller for your app can solve this. You can deploy the yaml for your crd, the controller will check whether there exist a configmap or not. Depending on the result, the controller will change the deployment yaml and deploy it.
Please refer to ConfigMapVolumeSource and ValidatingWebhookConfiguration you can find optional parameter:
Specify whether the ConfigMap or it's keys must be defineSo please try and add "optional: true" in your volumes configmap properties:
volumes:
- name: config-volume
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: special-config
optional: trueNote:
You must create a ConfigMap before referencing it in a Pod specification (unless you mark the ConfigMap as “optional”). If you reference a ConfigMap that doesn’t exist, the Pod won’t start. Likewise, references to keys that don’t exist in the ConfigMap will prevent the pod from starting.
Please let me know if it helped.