I have a simple bash script to execute at postStart, but i get an error which is not informative at all:
Exec lifecycle hook ([/bin/bash -c sleep 30;/xcom/scripts/sidecar_postStart.sh]) for Container "perfcibuddy" in Pod "xcomapp-597fb859c5-6r4g2_ns(412852d1-5eea-11ea-b641-0a31ddb9a71e)" failed - error: command '/bin/bash -c sleep 120;/xcom/scripts/sidecar_postStart.sh' exited with 7: , message: ""
The sleep is there because I got a tip that there might be a race condition, that the script is not in place at the time Kubernetes calls it.
And if I log into the container I can execute the script from the shell without any problem.
The script is just doing a simple curl call (IP obviously sanitized):
# ----------------------------------------------------------------------------
# Script to perform postStart lifecycle hook triggered actions in container
# ----------------------------------------------------------------------------
# -------------------------------------------[ get token from Kiam server ]---
role_name=$( curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/ )
curl -s http://1.1.1.1/latest/meta-data/iam/security-credentials/${role_name}
I tried numerous form to set the command in the template (everything in quotes, with && instead of ;), this is the current one:
exec:
command: [/bin/bash, -c, "sleep 120;/xcom/scripts/sidecar_postStart.sh"]
What could be the problem here?
Curl exit code 7 is generally “unable to connect” so your IP is probably wrong or the kiam agent is not set up correctly.