DevOpsLesson
DevOpsLesson

Free, comprehensive DevOps tutorials and learning roadmaps. Master Docker, Kubernetes, CI/CD, and more.

Stay Updated

Get notified about new tutorials and features.

Tutorials

  • What is DevOps?
  • Docker Tutorial
  • Terraform Tutorial
  • CI/CD Pipeline
  • All Tutorials

Roadmaps

  • DevOps Engineer
  • Cloud Engineer
  • SRE Path
  • All Roadmaps

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 DevOpsLesson. All rights reserved.

DOCKERKUBERNETESTERRAFORMAWSCI/CDLINUXGITDEVOPS ROADMAPCLOUD ROADMAPSRE ROADMAPGIT CHEATSHEETDOCKER CHEATSHEETK8S CHEATSHEETTF CHEATSHEETLINUX CHEATSHEETDOCKERFILE LINTERYAML VALIDATORCRON PARSERREGEX TESTER

Kubernetes Tutorial

Introduction to Kubernetes
Kubernetes Architecture
Installing Kubernetes
kubectl Basics
Kubernetes Pods
Kubernetes Deployments
Kubernetes Services
ConfigMaps and Secrets
Kubernetes Storage
Kubernetes Namespaces
Kubernetes Resource Management
Helm for Kubernetes
Kubernetes Monitoring

kubectl Basics

PreviousPrev
Next

Learn how kubectl fits into Kubernetes workflows and when to use imperative commands versus declarative manifests.

What Is kubectl?

kubectl is your daily control surface for Kubernetes. It can inspect the cluster, create resources, apply manifests, stream logs, exec into containers, and switch contexts.

How kubectl Talks to the Cluster

Request flow: kubectl → running pod

kubectl apply

Your command

API Server

Validates & persists to etcd

etcd

Stores desired state

Scheduler

Picks the best node

kubelet

Receives pod spec

Container Runtime

Pulls image & starts container

Pod Running

✓ Desired state achieved

kubectl apply

Your command

API Server

Validates & persists to etcd

etcd

Stores desired state

Scheduler

Picks the best node

kubelet

Receives pod spec

Container Runtime

Pulls image & starts container

Pod Running

✓ Desired state achieved

The important idea is that kubectl usually does not talk directly to pods or nodes first. It talks to the API Server.

Imperative vs Declarative

Imperative

With the imperative style, you tell Kubernetes exactly what command to perform right now.

Examples:

kubectl create deployment web --image=nginx
kubectl scale deployment web --replicas=3

Declarative

With the declarative style, you describe the desired end state in YAML and apply it.

kubectl apply -f deployment.yaml

Declarative workflows are better for version control, reviews, repeatability, and production change tracking.

When to Use Each Style

StyleBest for
ImperativeQuick experiments, demos, and one-off tasks
DeclarativeTeam workflows, GitOps, repeatable environments, production changes

Sub-pages in This Section

Sub-topicWhat you will learn
Get and DescribeInspect resources and read detailed object information
Apply and DeleteCreate, update, diff, and remove resources
Exec and LogsDebug running workloads and stream logs
Contexts and NamespacesSwitch clusters and scope commands safely

Why kubectl Matters So Much

kubectl is more than a command list. It is how you observe the cluster, express desired state, and debug behavior. Learning it well gives you leverage across nearly every Kubernetes workflow.

Exercise

Preferred Production Style

Which approach is usually better for production changes that should be reviewed and repeated safely?

Exercise

kubectl Path

In a typical workflow, what component does kubectl contact first?

PreviousPrev
Next

Continue Learning

Installing Kubernetes with Minikube

Set up Minikube on macOS, Linux, or Windows and learn the core commands for starting, inspecting, and stopping your local cluster.

20 min·Easy

Installing Kubernetes with kind

Use kind to spin up single-node and multi-node Kubernetes clusters inside Docker for fast testing and learning.

20 min·Easy

Installing kubectl

Install kubectl on macOS, Linux, or Windows, verify it works, and understand how kubeconfig connects the CLI to a cluster.

18 min·Easy

Explore Related Topics

Do

Docker Tutorials

Build the containers Kubernetes orchestrates

Te

Terraform Tutorials

Provision Kubernetes clusters as code

Try the Tool

YAML Validator

Validate Kubernetes manifests and any YAML files instantly.

On This Page

What Is kubectl?How kubectl Talks to the ClusterImperative vs DeclarativeImperativeDeclarativeWhen to Use Each StyleSub-pages in This SectionWhy kubectl Matters So Much