KubernetesでコマンドラインでPodを作成する際に実行するコマンドが成功するかを確認する方法を紹介します。
以下のようにkubectlの「run」コマンドでポッド名とコンテナイメージを指定し、「–dry-run=client」を指定します。
1 |
kubectl run ポッド名 --image=コンテナイメージ名 --dry-run=client |
試してみます。
1 2 3 4 |
root@controlplane:~# kubectl run nginx --image=nginx --dry-run=client pod/nginx created (dry run) root@controlplane:~# |
確認してみます。
1 2 3 |
</code><code>root@controlplane:~# kubectl get pod No resources found in default namespace. root@controlplane:~# |
Podは作成されていないことがわかります。