I'm trying to make use of init container to prepare some files before the main container starts up. In the init container I'd like to mount a hostPath volume so that I can share prepare some file for the main container.
My cluster is using pre 1.6 version of kubernetes so I'm using the meta.annotation syntax:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init-myservice",
"image": "busybox",
"command": ["sh", "-c", "mkdir /tmp/jack/ && touch cd /tmp/jack && touch a b c"],
"volumeMounts": [{
"mountPath": "/tmp/jack",
"name": "confdir"
}]
}
]'
But it doesn't seem to work. The addition of volumeMounts cause the container init-myserver go into CrashLoop. Without it the pod gets created successfully but it doesn't achieve what I want.
Is it not possible in <1.5 to mount volume in init container? What about 1.6+?