LoginSignup
0

More than 1 year has passed since last update.

【GCP】kubectl よく使うコマンド集

Posted at

よく使うkubectlコマンドのまとめ・コマンド集

自分用のメモとして、Kubernetes上のサービスの運用時によく利用するコマンドをまとめています。

コマンド一覧

secret config の取得

kubectl get secret {secret名} -o yaml

(併せて使える) base64からのdecode処理

echo "{上記コマンドの実行結果のbase64でエンコードされたデータ}" | base64 --decode

secret config の編集

kubectl edit secret {secret名}

namespaceに該当する全てのpodのリスタート

kubectl -n {namespace名} rollout restart deploy
kubectl -n default rollout restart deploy

特定のrevisionにロールバック

kubectl rollout undo deployment/{deployment名} --to-revision={revision_id}

スケールアップ/スケールダウン

kubectl scale --replicas={設定したいpod数} deployment {deployment名}

全ての”Evicted”ステータスのpodを削除

kubectl get pod | grep Evicted | awk '{print $1}' | xargs kubectl delete pod

全ての"UnkonwnStatus"ステータスのpodを削除

kubectl get pod | grep ContainerStatusUnknown | awk '{print $1}' | xargs kubectl delete pod

node poolを取得

kubectl get node

node pool全体のCPU usage等を出力

kubectl describe nodes {cluster名}

ingress更新

kubectl describe ingress {ingress名}

Docker内でコマンドを実行する

kubectl exec {pod名} -it -c {deployment名} -- /bin/sh

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