0Pricing
Docker & Kubernetes for Developers · Lesson

Working with kubectl: Your Cluster Control Tool

Get hands-on with kubectl, the command-line tool to inspect, create, and manage every resource in a Kubernetes cluster.

Working with kubectl: Your Cluster Control Tool is a free Docker & Kubernetes for Developers lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & Kubernetes for Developers learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Listing 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 -A

Inspecting with describe

kubectl describe shows detailed, human-readable status plus an events section that is invaluable for debugging.

kubectl describe pod my-pod

Creating 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.yaml

Imperative Quick Creates

For quick experiments you can create resources imperatively.

kubectl create deployment web --image=nginx
kubectl run tmp --image=busybox --restart=Never -- sleep 3600

Viewing 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 --previous

Executing Into a Pod

Open a shell inside a running container to debug interactively.

kubectl exec -it my-pod -- /bin/sh

Editing 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-pod

Namespaces 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=dev

Output 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.

Frequently asked questions

Is the “Working with kubectl: Your Cluster Control Tool” lesson free?

Yes — the full text of “Working with kubectl: Your Cluster Control Tool” is free to read here on the web, and the Docker & Kubernetes for Developers course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & Kubernetes for Developers course, upgrade to CoddyKit PRO.

What will I learn in “Working with kubectl: Your Cluster Control Tool”?

Get hands-on with kubectl, the command-line tool to inspect, create, and manage every resource in a Kubernetes cluster. You practise Docker & Kubernetes for Developers with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Docker & Kubernetes for Developers?

No prior experience is required. Docker & Kubernetes for Developers on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Working with kubectl: Your Cluster Control Tool” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Docker & Kubernetes for Developers lesson?

Yes. Every Docker & Kubernetes for Developers lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to Kubernetes & Why It Matters
  2. Kubernetes Architecture & Components
  3. Deploying Your First Pod
  4. Working with kubectl: Your Cluster Control Tool
← Back to Docker & Kubernetes for Developers