stackanetes / kubernetes-entrypoint

Used as a container entrypoint, it will wait for specified k8s dependencies, create files based on ConfigMaps, and much more - before running a given command.
Apache License 2.0
50 stars 18 forks source link

init-container #12

Closed kfox1111 closed 8 years ago

kfox1111 commented 8 years ago

I'd like to use kubernetes-entrypoint in a k8s init-container instead of embededing it in directly into each regular container. This allows unmodified containers to be used, and also allows you to restrict k8s service tokens to just the init container, enhancing security.

I think this would work well, but the current implementation in kubernetes-entrypoint.go looks to fail if command is empty:

if comm = env.SplitEnvToList("COMMAND", " "); len(comm) == 0 { logger.Error.Printf("COMMAND env is empty") os.Exit(1) }

Can a feature be added to allow it to simply os.Exit(0) after deps are resolved when set so it can be used as an init-container?

PiotrProkop commented 8 years ago

Sure,

i think entrypoint should first check if it is inside init-container, if so exit(0). Otherwise exit(1).

PiotrProkop commented 8 years ago

Until this feature is not implemented. Please use COMMAND="echo Done".

DTadrzak commented 8 years ago

Dear @PiotrProkop, In order to implement easy check, whether instance is init-container or not, user needs to pass container-name via env. I think it's not generic approach. So what I'd suggest is to change return code to 0 and log it as a warning. Yours sincerely Daniel

PiotrProkop commented 8 years ago

Merged.

PiotrProkop commented 8 years ago

Closing due to #13 .