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

Installing kubectl

PreviousPrev
Next

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

What Is kubectl?

kubectl is the primary command-line tool for talking to Kubernetes clusters. It sends requests to the API Server so you can create, inspect, update, and delete resources.

Install on macOS

brew install kubectl

Install on Linux

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Install on Windows

You can install it with Chocolatey:

choco install kubernetes-cli

Verify the Install

kubectl version --client

If you already have access to a cluster, you can also run:

kubectl version

Connecting to a Cluster with kubeconfig

kubectl reads connection settings from a kubeconfig file, usually located at ~/.kube/config.

A kubeconfig file usually contains:

  • clusters: where the API Servers live
  • users: credentials or auth methods
  • contexts: named combinations of cluster + user + default namespace

Inspect kubeconfig

kubectl config view

That command prints the active configuration so you can see which cluster and user kubectl is using.

A Simple Workflow

kubectl version --client
kubectl config view
kubectl get nodes

If kubectl get nodes works, you are connected to a cluster successfully.

Why kubeconfig Matters

Think of kubeconfig like a contacts list for clusters. Instead of memorizing server addresses and credentials, you switch between named entries safely.

Without kubeconfig, kubectl would not know where to send requests or how to authenticate.

Common Problems

Command Not Found

The binary may not be in your PATH.

Connection Refused

Your kubeconfig may point to a cluster that is not running.

Unauthorized

Your kubeconfig may have expired credentials or the wrong user context.

Exercise

kubectl Role

What is the main job of `kubectl`?

Exercise

kubeconfig Purpose

Why is the kubeconfig file important?

PreviousPrev
Next

Continue Learning

Installing Kubernetes

Compare local and managed Kubernetes options so you can choose the right environment for learning, testing, or production.

18 min·Easy

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

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?Install on macOSInstall on LinuxInstall on WindowsVerify the InstallConnecting to a Cluster with kubeconfigInspect kubeconfigA Simple WorkflowWhy kubeconfig MattersCommon ProblemsCommand Not FoundConnection RefusedUnauthorized