← Back to list

What is a Context in Kubernetes?

A context is a saved configuration that tells kubectl:

yuresh Gurung · 2026-06-16 08:36 · 0 claps · 0.9 min read
#k8s #kubernetes #context #users #kubernetes-cluster
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud

What is a Context in Kubernetes?

A context is a saved configuration that tells kubectl:

  1. Which cluster to connect to
  2. Which user to use
  3. Which namespace to use by default

Think of it as your Kubernetes workspace settings.

What does set-context do?

kubectl config set-context

Purpose:

Modify the settings of a context.

You can change:

  • Cluster
  • User
  • Namespace

Beginner Analogy

Imagine your computer has multiple projects:

Project A
Project B
Project C

A context is like selecting which project you are working on.

set-context means:

“Change the settings of my current project/workspace.”

Your Example

Before:

Current Context
├─ Cluster: kubernetes
├─ User: admin
└─ Namespace: default

Command:

kubectl config set-context --current --namespace=netpol-challenge

After:

Current Context
├─ Cluster: kubernetes
├─ User: admin
└─ Namespace: netpol-challenge

Only the namespace changed.

Why use it?

Without setting the namespace:

kubectl get pods -n netpol-challenge
kubectl describe pod backend-pod -n netpol-challenge

You must type -n netpol-challenge every time.

After:

kubectl config set-context --current --namespace=netpol-challenge

You can simply run:

kubectl get pods
kubectl describe pod backend-pod

Kubernetes automatically uses the netpol-challenge namespace.

Memory Trick

Context = Workspace
set-context = Change workspace settings
--current = Change the workspace I'm using now
--namespace = Set the default namespace

So:

kubectl config set-context --current --namespace=netpol-challenge

means:

“For my current Kubernetes workspace, use netpol-challenge as the default namespace." 🚀


메타데이터
post_id
49f6a5145c44
slug
what-is-a-context-in-kubernetes-49f6a5145c44
url
https://medium.com/@ygce108/what-is-a-context-in-kubernetes-49f6a5145c44
canonical_url
https://medium.com/@ygce108/what-is-a-context-in-kubernetes-49f6a5145c44
author_url
https://medium.com/@ygce108
status
ok
fetched_at
2026-06-21 07:44:09