I try to use bash script to run a few k8s commands. During the deployment, I need to wait for a secret to be generated by cert-manager or Vault before it can continue. I know there is a command called kubectl wait
but it doesn't seem to work with secret
resources, so I came up with this bash script:
while [ -z "$matched" ]
do
echo "Waiting for ($secret_name) to be created"
matched=$(kubectl get secret $secret_name -n $namespace -o jsonpath="{$path}" --ignore-not-found=true)
sleep 10;
done
But it fails on first run after waiting for a minute. It only works on second try. Do you have any suggestions?