Skip to main content

Command Palette

Search for a command to run...

switch between contexts to work on different clusters

Published
switch between contexts to work on different clusters
R

I'm Rudraksh Laddha — a DevOps engineer and emerging full-stack developer, passionate about building scalable, reliable systems that solve real-world problems.

With a solid foundation in cloud infrastructure automation using tools like Kubernetes, Docker, Terraform, and AWS, I thrive in environments where efficiency, resilience, and automation are key.

But my journey doesn't stop at infrastructure. I'm actively expanding into full-stack development, building dynamic applications using React, Node.js, and MongoDB. Whether it's designing cloud-native CI/CD pipelines or developing intuitive user interfaces, I enjoy creating end-to-end solutions — from server to screen.

Right now, I'm: 🧩 Building full-stack applications that merge DevOps reliability with engaging frontend experiences šŸ› ļø Contributing to open-source projects, learning through collaboration and real-world scenarios šŸš€ Growing Virendana Ui, my own UI library focused on expressive, clean design systems šŸš€ Growing Learn Virendana, where I share my personalized learning journey — from beginner to experienced šŸŽ® Developing side projects like 2048 Rush, blending product thinking with scalable infrastructure My long-term goal? To bridge DevOps and development — building products that are not just functional and fast, but also resilient, beautiful, and ready for scale.

Kubectl Context Alias

If you regularly switch between contexts to work on different clusters, you can create an alias to list and set the context.

Here is the alias to list the contexts.

alias klist='kubectl config get-contexts -o=name'

You can add the following line to your .bashrc or .zshrc file, depending on the shell you use:

Create the following alias to set the context with a custom namespace.

kset() {
    local context="$1"
    local namespace="$2"
    kubectl config use-context "$context" --namespace "$namespace"
}

Here is how the aliases look in your bashrc or zshrc file.

alias k=kubectl

alias klist='kubectl config get-contexts -o=name'

kset() {
    local context="$1"
    local namespace="$2"
    kubectl config use-context "$context" --namespace "$namespace"
}

kdel() {
    kubectl config delete-context "$1"
}

Here is how you can use these aliases

  1. List the contexts with klist command.

  2. Set the context and namespace using the kset command