Kubectl: Delete Context | Cluster | User

A context in Kubernetes is basically a combination of an information about clusters and users, stored in a kubeconfig file.

Every time you execute the kubectl command, you reference a context inside kubeconfig.

The kubectl config command is used to manage Kubernetes configurations, primarily by editing the kubeconfig file.

In this short note I will show how to delete a Kubernetes context, cluster or user from kubeconfig using the kubectl config command. (more…)

K8s: Spread Pods Evenly on Nodes in Different Zones/Regions

Kubernetes automatically spreads Pods for workload resources (such as Deployment, StatefulSet, etc.) across different Nodes to reduce the impact of failures.

In a multi-zone (multi-region) Kubernetes cluster it is required to ensure that Kubernetes will place the replicas of a Pod on the Nodes in different zones, to reduce the impact of zone failures.

In this note I will show how to distribute Kubernetes Pod replicas evenly on Nodes in different zones using topologySpreadConstraints. (more…)

Kubectl: Add Label to Kubernetes Node

Labels in Kubernetes are used for attaching meta tags to different resources, including nodes.

This helps to organize the nodes and allows to select specific subsets of nodes.

By adding labels to Kubernetes nodes, we can have more control over the resources that we create.

For example, we can make Kubernetes to schedule specific deployments onto nodes with the specific labels only.

In this post I will show how to get, add, overwrite and delete labels from Kubernetes nodes using the kubectl command. (more…)

Kubectl: Port-Forward to Service – Kubernetes

kubectl port-forward is a Kubernetes command that allows to access internal cluster resources from outside the cluster.

It tunnels a traffic from a specified port on a localhost to the specified port on the specified Pod.

The kubectl port-forward command is useful for troubleshooting issues, setting up services locally without exposing them, and debugging applications within the cluster.

This post shows the examples of how to use the kubectl port-forward command to access the internal cluster resources from the locathost. (more…)

Install Kubectx & Kubens on Windows

kubectx and kubens are two command-line tools that can help to manage Kubernetes clusters and namespaces more efficiently.

kubectx is used for switching between Kubernetes contexts (clusters) faster, while kubens is used for switching between Kubernetes namespaces more easily.

This post shows how to install kubectx and kubens on Windows so they can be used from PowerShell or Command Prompt (CMD). (more…)

Kubectl Autocomplete in PowerShell

A kubectl autocomplete is a feature that helps to complete kubectl commands or filenames automatically by pressing the ↹ Tab key.

This feature can be enabled in Windows PowerShell by invoking a simple kubectl completion powershell command.

Though this way it will be enabled temporary for the current session only.

To enable the kubectl autocomplete feature permanently it is required to add some commands to your Powershell $PROFILE file and this post shows how to do this. (more…)

[SOLVED] Node had taints, that the pod didn’t tolerate

Kubernetes (K8s) has a feature, that allows to mark (taint) a Node, so that no Pods can be scheduled on it, unless a Pod explicitly tolerates the taint.

If you try to deploy the Pod that doesn’t tolerate any of the K8s Nodes’ taints, you will get an error as follows:

0/5 nodes are available: 1 node(s) had taint {node-role.node-role.kubernetes.io/master: }, that the pod didn’t tolerate, 2 node(s) had taint {dedicated: agents}, that the pod didn’t tolerate, 2 node(s) had taint {dedicated: controllers}, that the pod didn’t tolerate.

To tolerate the K8s Nodes’ taints, it is required to specify a toleration for the Pod in the PodSpec, and below I will show the examples of how to do this. (more…)

Install Kubectl on Windows

A kubectl is the official Kubernetes command-line tool, used to run commands on Kubernetes clusters.

As the kubectl is distributed as a standalone binary it can be easily downloaded from official sources and installed on Windows.

In this post I will show how to download and install the latest stable version of the kubectl on Windows through a graphical user interface (GUI), or using a command-line prompt (CMD) or PowerShell. (more…)