I am trying to copy a file (jar file) so that I can run the jar (java -jar) in my pod. But the copy command just doesn't work. The pod logs don't throw any error also.
My deployment.yaml looks like (in brief):
- name: glowroot-jar-init-container
image: "{{ .Values.images.repository }}/{{ .Values.config.aptm.image }}"
securityContext:
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true
readOnlyRootFilesystem: true
imagePullPolicy: {{ .Values.images.pullPolicy }}
command: ["cp","/opt/tools/aptm/glowroot.jar","/aptm"]
volumeMounts:
- name: aptm-data-glowroot
mountPath: /aptm
.
.
.
.
.
.
containers:
- name: {{ template "name" . }}
image: "{{ .Values.images.repository }}/com.gtt.ecomp.vod.dev/vod:{{ .Values.images.vodTag }}"
imagePullPolicy: {{ .Values.images.pullPolicy }}
securityContext:
runAsUser: 1000
runAsGroup: 1000
runAsNonRoot: true
readOnlyRootFilesystem: true
command:
- sh
- -c
- -x
- >
.
.
.
.
echo "Copying aptm JAR."
cp /usr/local/tomcat/webapps/vod/WEB-INF/lib/hram-agent-0.13.jar /opt/tools/aptm;
.
.
.
bash /mounted-config/start_tomcat.sh;
args:
- "30000"
.
.
.
.
- name: aptm-data
mountPath: /opt/tools/aptm
- name: aptm-data-glowroot
mountPath: /aptm
.
.
.
.
- name: aptm-data
emptyDir: {}
- name: aptm-data-glowroot
emptyDir: {}
.
.
.
The file hram-agent-0.13.jar is present in the WEB-INF/lib/ folder. But when I do a bash and get into the pod to check the if the jar file was copied or not I do not see it.
vodadmin@vod-58867c5dc6-lg8ch:/usr/local/tomcat/webapps/vod/WEB-INF/lib$ ls -lrt hr*
-rw-r--r-- 1 vodadmin vodadmin 13864793 Apr 25 12:56 hram-agent-0.13.jar
vodadmin@vod-58867c5dc6-lg8ch:/usr/local/tomcat/webapps/vod/WEB-INF/lib$
But when cd to the target folder:
vodadmin@vod-58867c5dc6-lg8ch:/opt/tools/aptm$ ls -lrt
total 0
All the trouble started when I changed everything to read only root file system in my pod.
COPYcommand, much earlier in the build-test-and-deploy process. You shouldn't need any special setup for your application to be in theimage:you're deploying.