Openshift Jobs - apply configuration

3/6/2018

For Openshift jobs, one way is to use the oc run command to execute a command against an image, this will run the command inside a pod. Is there way to apply configuration such as a config map or secret to this mechanism (oc run).

Please advise. B

-- user518066
kubernetes
openshift

2 Answers

3/8/2018

see this example pod in kind. in this you can also add command and env variables. it will not restart the container itself. not complete but you will get the idea.

apiVersion: v1
kind: Pod
metadata:
  name: pod-elasticsearch-1
  namespace: common-data
  labels:
    elasticsearch-name: pod-elasticsearch-1
    node: elasticsearch
    type: elasticsearch-logs
spec:
  containers:
    - resources:
        limits:
          memory: "24Gi"
          cpu: "2"
        requests:
          memory: "16Gi"
          cpu: "1"
      ulimits:
        memlock:
          soft: -1
          hard: -1
        nofile:
          soft: 65536
          hard: 65536
      image: docker.elastic.co/elasticsearch/elasticsearch:5.5.2
      name: elasticsearch-custom
      command: [ "elasticsearch"]
      args: ["-E" , "cluster.name=es-ocp-app-cluster",
                "-E" , "node.name=master-es-node-1",
                "-E" , "node.master=true",
                "-E" , "node.data=true",
                "-E" , "network.publish_host= svc-elasticsearch-1 ",
                #"-E" , "network.host=_site_",
                "-E" , "http.host=0.0.0.0",
-- Amit Bondwal
Source: StackOverflow

3/7/2018

Create a deployment config for these requirement. In which you can declare environment variables, commands, declare secrets etc. It will be easy to maintain too.

-- Amit Bondwal
Source: StackOverflow