0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【簡単Kubernetes】【kubectl】kubectl get コマンド完全ガイド ~ Pod や Deployment の取得方法まとめ ~

Posted at

Kubernetes クラスタのリソースを確認する際に、最も頻繁に使用されるコマンドの一つが kubectl get です。本記事では、kubectl get コマンドの基本から応用まで、よく使うオプションや書き方の違いをまとめます。


🔹 基本構文

kubectl get <リソースタイプ> <リソース名> [オプション]

例:

kubectl get pod pod1

pod1 という名前の Pod を取得する。


🔹 Pod の取得(いろいろな書き方)

kubectl get pod pod1
kubectl get pods pod1
kubectl get po pod1
コマンド 説明 備考
kubectl get pod pod1 Pod の正式な書き方 ✅ 標準・推奨
kubectl get pods pod1 複数形(pods)でもOK ✅ よく使われる
kubectl get po pod1 pod の省略形(alias) ✅ CLI 操作で便利

🔹 Deployment の取得

kubectl get deployments
kubectl get deploy
kubectl get deploy -n kube-system
kubectl get deploy --all-namespaces
コマンド 説明
kubectl get deployments 現在の Namespace に存在する Deployment 一覧を取得
kubectl get deploy deployments の省略形
kubectl get deploy -n kube-system kube-system Namespace の Deployment を取得
kubectl get deploy --all-namespaces すべての Namespace の Deployment を取得

💡 -A--all-namespaces の省略形です。


🔹 Namespace の指定

Kubernetes では、リソースは Namespace ごとに管理されています。
Namespace を指定しない場合、現在のコンテキストで設定されている Namespace のみが対象になります。

kubectl get pods -n default
kubectl get pods -n kube-system

🔹 まとめ

  • kubectl get はリソース確認の基本コマンド。
  • リソースタイプには省略形(例:po, deploy)も使える。
  • --all-namespaces でクラスタ全体の状態を確認可能。
  • Namespace の指定は -n <namespace>

📌 よく使うチートシート

kubectl get po                         # 現在の Namespace の Pod 一覧
kubectl get po -A                      # 全 Namespace の Pod 一覧
kubectl get deploy -n kube-system     # kube-system の Deployment
kubectl get svc                        # Service 一覧
kubectl get nodes                     # Node 一覧

ご参考になれば幸いです 🙌
Kubernetes 初心者から中級者へのステップアップにぜひお役立てください。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?