-
-
Save resouer/378bcdaef1d9601ed6aa to your computer and use it in GitHub Desktop.
--- | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: server | |
spec: | |
containers: | |
- image: resouer/sample:v2 | |
name: war | |
lifecycle: | |
postStart: | |
exec: | |
command: | |
- "cp" | |
- "/sample.war" | |
- "/app" | |
volumeMounts: | |
- mountPath: /app | |
name: hostv1 | |
- name: peer | |
image: busybox | |
command: ["tail", "-f", "/dev/null"] | |
volumeMounts: | |
- name: hostv2 | |
mountPath: /app/sample.war | |
volumes: | |
- name: hostv1 | |
hostPath: | |
path: /tmp | |
- name: hostv2 | |
hostPath: | |
path: /tmp/sample.war |
What will happen if I want to use rolling update?
Is rolling update of one container inside a pod possible? Without touching second container?
@akamanocha It works well in your case. Just make sure that Tomcat can automatically load your wars, otherwise you need to restart it manually.
Keep the side car alive so that it doesn't get restarted. This could also be implemented
withpause
.
Note: This won't be necessary when per-pod restart policies are implemented
while true; do sleep 10; done
@kjvalencik What do you mean by "pause"? Java Web Application with Tomcat and Sidercar Container keeps its sidecar container alive by invoking tail -f /dev/null
.
Guys, this can be solved more elegant by using initContainer
, see my update in the original answer: http://stackoverflow.com/questions/30538210/how-to-mimic-volumes-from-in-kubernetes/33118902#33118902
I use a couple of simple start scripts to atomically copy the data and wait until it is ready.