0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kubectlコマンド

Last updated at Posted at 2020-03-27

kubectlコマンド

よく使いそうなkubectlコマンドをメモしておきます。

基本的なkubectlコマンド

コマンド 内容
kubectl create deployment --image=<イメージ名> <デプロイメント名> イメージ<イメージ名>を<デプロイメント名>で実行する
kubectl scale --replicas=<レプリカ数> deployment/<デプロイメント名> デプロイメント<デプロイメント名>のレプリカを<レプリカ数>に設定する
kubectl create job <ジョブ名> --image=<イメージ名> イメージ<イメージ名>を<ジョブ名>で実行する
kubectl run <ポッド名> --image=<イメージ名> -it --restart=Never --rm sh イメージ<イメージ名>を<ポッド名>で実行する
kubectl exec -it <ポッド名> -c <コンテナ名> sh ポッド<ポッド名>のコンテナ<コンテナ名>を別ターミナルで起動する
kubectl delete pod <ポッド名> ポッド<ポッド名>を削除する
kubectl delete deployment <デプロイメント名> デプロイメント<デプロイメント名>を削除する
kubectl delete job <ジョブ名> ジョブ<ジョブ名>を削除する
kubectl logs <ポッド名> ポッド<ポッド名>のログを表示する
kubectl logs <ポッド名> -c <コンテナ名> ポッド<ポッド名>のコンテナ<コンテナ名>のログを表示する
kubectl cluster-info クラスタ情報を表示する
kubectl get node ノード一覧を表示する
kubectl get pods ポッド一覧を表示する
kubectl get pod -o wide ポッド一覧を表示する
kubectl get deployment デプロイメント一覧を表示する
kubectl get jobs ジョブ一覧を表示する
kubectl get componentstatus コンポーネントの状態を表示する
kubectl get all いろいろ表示する
kubectl describe pod <ポッド名> ポッド<ポッド名>の詳細情報を表示する
kubectl version Kubernetesのバージョンを確認する
kubectl expose deployment <デプロイメント名> --port 80 --type LoadBalancer ポート80で外部ロードバランサを作成する(インターネットに公開する)
kubectl get services サービス一覧を表示する
kubectl get replicasets レプリカを表示する

マニフェスト関連のkubectlコマンド

コマンド 内容
kubectl apply -f <ファイル名> マニフェストファイル<ファイル名>から実行する
kubectl delete -f <ファイル名> マニフェストファイル<ファイル名>から精製したオブジェクトを削除する
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?