KUBERNETES67 cmd
Kubernetes (kubectl) チート集
Pod / Deployment / Service / ConfigMap / Namespace / Node / デバッグ / context 切替の kubectl 操作。
- 更新日
- 2026-05-12
- 参照範囲
- 公式ドキュメント / man page / 主要ベンダーCLI
- 対象実装
- 主要 Linux / BSD / ネットワーク機器 CLI の一般的な実装
- 免責
- OS とバージョン差分は実環境で確認してください。
67 / 67
| Command | Description | Example | Copy |
|---|---|---|---|
kubectl get pods | Pod一覧を表示 | kubectl get pods | |
kubectl get pods -A | 全Namespaceのpodを表示 | kubectl get pods -A | |
kubectl get pods -o wide | Pod一覧を詳細情報付きで表示 | kubectl get pods -o wide | |
kubectl get pods -w | Pod一覧をリアルタイム監視 | kubectl get pods -w | |
kubectl describe pod | Podの詳細情報を表示 | kubectl describe pod my-pod | |
kubectl run | Podを作成して実行 | kubectl run nginx --image=nginx --port=80 | |
kubectl delete pod | Podを削除 | kubectl delete pod my-pod | |
kubectl delete pod --force | Podを強制削除 | kubectl delete pod my-pod --force --grace-period=0 | |
kubectl get pods -l | ラベルでPodをフィルタリング | kubectl get pods -l app=nginx | |
kubectl get pod -o yaml | PodのYAML定義を表示 | kubectl get pod my-pod -o yaml | |
kubectl get deployments | Deployment一覧を表示 | kubectl get deployments | |
kubectl create deployment | Deploymentを作成 | kubectl create deployment nginx --image=nginx --replicas=3 | |
kubectl apply -f | マニフェストファイルを適用 | kubectl apply -f deployment.yaml | |
kubectl delete -f | マニフェストファイルで定義されたリソースを削除 | kubectl delete -f deployment.yaml | |
kubectl scale | Deploymentのレプリカ数を変更 | kubectl scale deployment nginx --replicas=5 | |
kubectl rollout status | ロールアウトの状態を確認 | kubectl rollout status deployment/nginx | |
kubectl rollout history | ロールアウト履歴を表示 | kubectl rollout history deployment/nginx | |
kubectl rollout undo | ロールバックを実行 | kubectl rollout undo deployment/nginx | |
kubectl rollout restart | Deploymentを再起動 | kubectl rollout restart deployment/nginx | |
kubectl set image | コンテナイメージを更新 | kubectl set image deployment/nginx nginx=nginx:1.25 | |
kubectl autoscale | Horizontal Pod Autoscalerを設定 | kubectl autoscale deployment nginx --min=2 --max=10 --cpu-percent=80 | |
kubectl get svc | Service一覧を表示 | kubectl get svc | |
kubectl expose | リソースをServiceとして公開 | kubectl expose deployment nginx --port=80 --type=LoadBalancer | |
kubectl get ingress | Ingress一覧を表示 | kubectl get ingress | |
kubectl describe svc | Serviceの詳細情報を表示 | kubectl describe svc my-service | |
kubectl delete svc | Serviceを削除 | kubectl delete svc my-service | |
kubectl get endpoints | Endpointsを表示 | kubectl get endpoints my-service | |
kubectl port-forward svc | Serviceへポートフォワード | kubectl port-forward svc/my-service 8080:80 | |
kubectl get configmaps | ConfigMap一覧を表示 | kubectl get configmaps | |
kubectl create configmap | ConfigMapを作成 | kubectl create configmap my-config --from-file=config.properties | |
kubectl get secrets | Secret一覧を表示 | kubectl get secrets | |
kubectl create secret generic | Secretを作成 | kubectl create secret generic my-secret --from-literal=password=mysecret | |
kubectl create secret tls | TLS Secretを作成 | kubectl create secret tls my-tls --cert=cert.pem --key=key.pem | |
kubectl describe configmap | ConfigMapの詳細を表示 | kubectl describe configmap my-config | |
kubectl get secret -o jsonpath | Secretの値をデコードして表示 | kubectl get secret my-secret -o jsonpath='{.data.password}' | base64 -d | |
kubectl edit configmap | ConfigMapを編集 | kubectl edit configmap my-config | |
kubectl get namespaces | Namespace一覧を表示 | kubectl get namespaces | |
kubectl create namespace | Namespaceを作成 | kubectl create namespace staging | |
kubectl delete namespace | Namespaceを削除 | kubectl delete namespace staging | |
kubectl config set-context --namespace | デフォルトNamespaceを設定 | kubectl config set-context --current --namespace=staging | |
kubectl get all -n | 指定Namespaceの全リソースを表示 | kubectl get all -n kube-system | |
kubectl apply -n | 指定Namespaceにマニフェストを適用 | kubectl apply -f app.yaml -n production | |
kubectl get nodes | Node一覧を表示 | kubectl get nodes | |
kubectl describe node | Nodeの詳細情報を表示 | kubectl describe node worker-1 | |
kubectl top nodes | Nodeのリソース使用量を表示 | kubectl top nodes | |
kubectl top pods | Podのリソース使用量を表示 | kubectl top pods --sort-by=memory | |
kubectl cordon | Nodeをスケジュール不可に設定 | kubectl cordon worker-1 | |
kubectl uncordon | Nodeをスケジュール可能に戻す | kubectl uncordon worker-1 | |
kubectl drain | Nodeからワークロードを退避 | kubectl drain worker-1 --ignore-daemonsets --delete-emptydir-data | |
kubectl taint nodes | NodeにTaintを設定 | kubectl taint nodes worker-1 key=value:NoSchedule | |
kubectl logs | Podのログを表示 | kubectl logs my-pod | |
kubectl logs -f | Podのログをリアルタイム表示 | kubectl logs -f my-pod | |
kubectl logs --previous | 前回のコンテナのログを表示 | kubectl logs my-pod --previous | |
kubectl logs -c | 特定のコンテナのログを表示 | kubectl logs my-pod -c sidecar | |
kubectl exec -it | Pod内で対話的にコマンドを実行 | kubectl exec -it my-pod -- /bin/bash | |
kubectl port-forward | Podへポートフォワード | kubectl port-forward my-pod 8080:80 | |
kubectl get events | クラスターイベントを表示 | kubectl get events --sort-by='.lastTimestamp' | |
kubectl debug | デバッグ用のエフェメラルコンテナを追加 | kubectl debug my-pod -it --image=busybox | |
kubectl explain | リソースのフィールドを説明 | kubectl explain pod.spec.containers | |
kubectl api-resources | 利用可能なAPIリソースを表示 | kubectl api-resources | |
kubectl config get-contexts | コンテキスト一覧を表示 | kubectl config get-contexts | |
kubectl config current-context | 現在のコンテキストを表示 | kubectl config current-context | |
kubectl config use-context | コンテキストを切り替え | kubectl config use-context production | |
kubectl config set-context | コンテキストを設定 | kubectl config set-context my-ctx --cluster=my-cluster --user=admin | |
kubectl cluster-info | クラスター情報を表示 | kubectl cluster-info | |
kubectl config view | kubeconfig設定を表示 | kubectl config view --minify | |
kubectl version | クライアントとサーバーのバージョンを表示 | kubectl version --short |