I have a init container in which I'm storing file but while running it's showing the file is not present. Is there any way I can exec inside init container and check where the file is being stored.
One of the things that I do with init containers (assuming you have the source) is to put a sleep 600 on failure in the entrypoint. At least for debugging. This lets you exec into the container to poke around to see the cause of the failure. Show activity on this post.
Accessing logs from Init Containers Init Containers that run a shell script print commands as they're executed. For example, you can do this in Bash by running set -x at the beginning of the script.
In this Kubernetes tutorial we learned about initContainer and it's usage in Kubernetes Cluster nodes. A Pod can have multiple containers running apps within it, but it can also have one or more init containers, which are run before the app containers are started.
During Pod startup, the kubelet delays running init containers until the networking and storage are ready. Then the kubelet runs the Pod's init containers in the order they appear in the Pod's spec. Each init container must exit successfully before the next container starts.
Init containers have all of the fields of an app container. However, Kubernetes prohibits readinessProbe from being used because init containers cannot define readiness distinct from completion. This is enforced during validation.
The regular container will only be started once the init container has been started An init container in a Pod must run and complete before any other application containers in the Pod start. This is a great way to initialize a Kubernetes Pod.
Use kubectl describe <pod>
to get the id of the initContainer you need to exec into then use kubectl exec -ti <pod> -c <container> sh
to access its shell. You may need to add some kind of delay, like sleep
to the initContainer to access it before it completes or fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With