I'm planning to run a .sh script after some containers are up to make some REST requests.
Created a job to wait for these initial containers, filled initContainers
tag in .yaml.
First, i thought creating a container with using a Linux distro as a base image. Then it didn't seem quite right.
Isn't that waste of resources ? What is the best practice for this situation ?
Thanks in advance.
You can use any kind of image as base image. The only resource you're consuming (not wasting) is disk space.
Kubernetes will pull the image and that will consume disk space on the node. As soon as the init container has done it's work, it will be stopped and won't use any more RAM or CPU which are the real precious resources in the cloud or on bare metal.
If you're worried about the image size, you can also try to use the same image as the user container (the main container) but starting a different command from it.
This will make the node just pull on image and no additional space appart from your script will be consumed.
Another option could be to use a very small distro like alpine.
If you can write your initialization routine in go you can also use your go binary as image like discribed here.