如何使用configmap运行一次openshift作业

时间:2019-06-12 11:25:40

标签: kubernetes openshift

我想出了如何在openshift中运行一次作业(替代docker run):

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

如何将configmap装入作业容器?

1 个答案:

答案 0 :(得分:0)

您可以使用--overrides标志:

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