前提
cronで.shのシェルスクリプトを実行する。
その中にkubectlコマンドがあるが実行されない。
※手動で実行すると問題なく動作する。
実現したいこと
- cronで定期的に実行し、kubectlコマンドの実行結果をファイルに出力したい。
発生している問題・エラーメッセージ
cronで実行するとkubectlコマンドが実行されない。
該当のソースコード
#!/bin/bash /usr/local/bin/kubectl get pod -A > sample.txt
試したこと
①
which kubectl
を実行した結果以下となりました。
/usr/local/bin/kubectl
②
試しにシェルスクリプト内構文で
/usr/local/bin/kubectl get pod -A > sample.txt 2>&1
を実行したところ以下の記述がみられました。
sh-4.2$ cat sample.txt
Unable to connect to the server: getting credentials: exec: executable aws not found
It looks like you are trying to use a client-go credential plugin that is not installed.
To learn more about this feature, consult the documentation available at:
https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins