How to run once an openshift job with configmap

6/12/2019

I have figured how to run a one time job in openshift (alternative to docker run):

oc run my-job --replicas=1 --restart=Never --rm -ti --command /bin/true --image busybox

How can I mount a configmap into the job container?

-- Rbjz
kubernetes
openshift

1 Answer

6/12/2019

You can use --overrides flag :

oc run my-job --overrides='
{
"apiVersion": "v1",
"kind": "Pod",
"spec": {
    "containers": [
        {
            "image": "busybox",
            "name": "mypod",
            "volumeMounts": [
                {
                    "mountPath": "/path",
                    "name": "configmap"
                }
            ]
        }
    ],
    "volumes": [
        {
            "configMap": {
                "name": "myconfigmap"
            },
            "name": "configmap"
        }
    ]
  }
}
' --replicas=1 --restart=Never --rm -ti --command /bin/true --image busybox
-- Nicolas Pepinster
Source: StackOverflow