I have a Spring batch application with few jobs and it is being executed as highlighted below
java -jar /appl/myapp/my-bat-spr-jobs-*.jar updtTablJob java -cp /opt/mqm/java/lib/com.ibm.mq.allclient.jar:/appl/myapp/my-bat-spr-jobs-*.jar com.demo.jobs.mappingApp jsonToQueue
I have defined my docker file like mentioned below
FROM openjdk:8-jre-alpine ENV my-bat-spr-jobs.jar WORKDIR /root/apps COPY . /appl/myapp ENTRYPOINT ["java "]
I want to deploy/run this dockerized application on Azure Kubernetes.
I have defined my POD.YAML as mentioned below
apiVersion: v1 kind: Pod metadata: name: my_app labels: app: my_app spec: containers: - name: my_app image: docker:5000/path_to_my_custom_image
How do I deploy the POD with the required cmd args – like “-jar /appl/myapp/my-bat-spr-jobs-.jar updtTablJob” or “-cp /opt/mqm/java/lib/com.ibm.mq.allclient.jar:/appl/myapp/my-bat-spr-jobs-.jar com.demo.jobs.mappingApp jsonToQueue”?
should I just run the image without defining the POD definition? something like below?
kubectl run -ti --rm test --image=path_to_my_custom_image --namespace default -- sh -c "-jar /appl/myapp/my-bat-spr-jobs-*.jar updtTablJob" kubectl run -ti --rm test --image=path_to_my_custom_image --namespace default -- sh -c "-cp /opt/mqm/java/lib/com.ibm.mq.allclient.jar:/appl/myapp/my-bat-spr-jobs-*.jar com.demo.jobs.mappingApp jsonToQueue"
My intention is to spin up the container, execute the job based on the runtime arg & destroy the container.
Advertisement
Answer
You can pass in the running parameters through the command parameter or the args parameter (even env)
As follows:
deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: "test" spec: template: spec: containers: - name: "test" image: "test:v1.0" {{- if .Values.command }} command: {{ toYaml .Values.command | nindent 12 }} {{- end }} {{- if .Values.args }} args: {{ toYaml .Values.args | nindent 12 }} {{- end }} {{- if .Values.env }} env: {{ toYaml .Values.env | nindent 12 }} {{- end }}
- if use command
values.yaml
command: - java - -jar - /appl/myapp/my-bat-spr-jobs-*.jar - updtTablJob
- if use args
values.yaml
args: - -cp - /opt/mqm/java/lib/com.ibm.mq.allclient.jar:/appl/myapp/my-bat-spr-jobs-*.jar com.demo.jobs.mappingApp - jsonToQueue
- if use env
values.yaml
args: - $env0 - $env1 - $env2 env: - name: "env0" value: "-cp" - name: "env1" value: "/opt/mqm/java/lib/com.ibm.mq.allclient.jar:/appl/myapp/my-bat-spr-jobs-*.jar com.demo.jobs.mappingApp" - name: "env2" value: "jsonToQueue "