We are moving applications between different environments/different kubernetes cluster and I have a case where the same shell script is behaving totally different on different kubernetes clusters.
We are running the application on on-premise kubernetes clusters
The issue is with the deployment on new k8s cluster. We have a script node.sh executed in the container like:
#!/usr/bin/env ash
. ./scripts/functions.sh
source /.env
Both scrips node.sh and functions.sh are mounted in the container in /scripts directory as configMaps with defaultMode 0755
In the new cluster I receive errors like "': No such file or directory can't open '/scripts/functions.sh"
If remove the execution of functions.sh it will complain that /.env can't be found and so on
Tried all possible variants like - sh /scripts/functions.sh, #!/usr/bin/env sh, tried different mount directory like / but without success, I receive same kind of error When running a sleep loop as a command I can execute the container and I can see both of the scripts mounted in the right path read-only. I execute node.sh but I get same error
Tried to mount both sh scripts on the nodes using hostPath, I get the exact same error
When I try to run the script from inside the container, same issue:
/ # ls -la /scripts
total 24
drwxr-xr-x 2 root root 4096 May 4 22:26 .
drwxr-xr-x 1 root root 4096 May 4 22:26 ..
-rwxr-xr-x 1 root root 452 May 4 22:26 functions.sh
-rwxr-xr-x 1 root root 1076 May 4 22:26 node.sh
/ # sh /scripts/node.sh
': No such file or directory can't open '/scripts/functions.sh
Older cluster where the script runs without any issue is on kubernetes v1.26.3 and the new one on v1.27.1
Same containerd version same OS and kernel
It's like nothing makes any sense
Does anyone have any idea how is this possible ?