onechart icon indicating copy to clipboard operation
onechart copied to clipboard

Init container support

Open lalyos opened this issue 3 years ago • 2 comments

Usecase: there are a lot of images which are almost perfect, but I'd like to modify the entrypoint.

Instead of maintaining a docker image:

  • create a deployment with an initContainer and an empty volume
  • the init container could create a custom entrypoint.sh on the volume
  • map the volume in the main container (let's say: /scripts)
  • you can refer the custom entrypoint in the main container

The init container could be used for example:

  • git clone a repo to the volume
  • git clone a static website repo (hugo,jekyll) build the html
  • serve it with nginx

Alternatively instead of creating the entrypoint.sh in an initscript, you could write the script as a configmap (or maybe as a sealed secret if its sensitive)

lalyos avatar Sep 19 '22 09:09 lalyos

So practically this would mean OneChart would get an initContainer field, and a place to put commands?

An example from https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ shows a similar syntax.

initContainers:
  - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', "until nslookup myservice.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local; do echo waiting for myservice; sleep 2; done"]
  - name: init-mydb
    image: busybox:1.28
    command: ['sh', '-c', "unt

How about OneChart gets an initContainers field and everything underneath is just passed through to the deployment? That could be quite flexible.

laszlocph avatar Sep 19 '22 12:09 laszlocph

@lalyos would this be a solution to your proposal?

laszlocph avatar Sep 29 '22 09:09 laszlocph

@lalyos check this out https://github.com/gimlet-io/onechart/pull/63

laszlocph avatar Mar 24 '23 10:03 laszlocph