kubectlを使う:クラスター操作のためのツール
Kubernetesクラスター内のあらゆるリソースを調査、作成、管理できるコマンドラインツールkubectlを実際に使って学びます。
「kubectlを使う:クラスター操作のためのツール」はCoddyKit上の無料Docker & Kubernetes for Developersレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはDocker & Kubernetes for Developers学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Docker & Kubernetes for Developersコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
What Is kubectl
kubectl is the official CLI that talks to the Kubernetes API server. Nearly every cluster operation, creating, reading, updating, deleting resources, goes through it.
Configuring Cluster Access
kubectl reads a kubeconfig file (default ~/.kube/config) that holds cluster endpoints, users, and credentials grouped into contexts.
kubectl config get-contexts
kubectl config use-context my-clusterListing Resources with get
kubectl get lists resources. Add -o wide for more columns or -A for all namespaces.
kubectl get pods
kubectl get pods -o wide
kubectl get nodes -AInspecting with describe
kubectl describe shows detailed, human-readable status plus an events section that is invaluable for debugging.
kubectl describe pod my-podCreating Resources
Apply a manifest file with kubectl apply -f. This is declarative: you describe the desired state and Kubernetes reconciles to it.
kubectl apply -f deployment.yamlImperative Quick Creates
For quick experiments you can create resources imperatively.
kubectl create deployment web --image=nginx
kubectl run tmp --image=busybox --restart=Never -- sleep 3600Viewing Logs
Stream container output with kubectl logs. Use -f to follow and --previous to see a crashed container.
kubectl logs my-pod -f
kubectl logs my-pod --previousExecuting Into a Pod
Open a shell inside a running container to debug interactively.
kubectl exec -it my-pod -- /bin/shEditing and Deleting
Edit live resources or remove them. Prefer editing manifests in git over edit for production.
kubectl edit deployment web
kubectl delete pod my-podNamespaces and Scoping
Most commands accept -n namespace. Set a default namespace to avoid repeating it.
kubectl get pods -n kube-system
kubectl config set-context --current --namespace=devOutput Formats
Use -o yaml or -o json to see the full object, and -o jsonpath to extract a single field.
kubectl get pod my-pod -o yaml
kubectl get pod my-pod -o jsonpath="{.status.phase}"Quick Check
Test what you have learned.
Recap
You practiced the core kubectl verbs: get, describe, apply, logs, exec, delete, plus contexts, namespaces, and output formats to control and debug your cluster.
よくある質問
「kubectlを使う:クラスター操作のためのツール」レッスンは無料ですか?
はい。「kubectlを使う:クラスター操作のためのツール」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Docker & Kubernetes for Developersコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Docker & Kubernetes for Developersコースには全4レッスンが含まれています。
「kubectlを使う:クラスター操作のためのツール」で何を学びますか?
Kubernetesクラスター内のあらゆるリソースを調査、作成、管理できるコマンドラインツールkubectlを実際に使って学びます。 ブラウザで直接実行するハンズオンコードでDocker & Kubernetes for Developersを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Docker & Kubernetes for Developersを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのDocker & Kubernetes for Developersは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「kubectlを使う:クラスター操作のためのツール」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このDocker & Kubernetes for Developersレッスンでコードを書いて実行できますか?
はい。すべてのDocker & Kubernetes for Developersレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Kubernetes入門と重要性
- Kubernetesのアーキテクチャとコンポーネント
- 初めてのPodをデプロイする
- kubectlを使う:クラスター操作のためのツール