Skip to main content
You can install the ngrok Kubernetes Operator in a locally running Kubernetes cluster rather than paying for one from a cloud provider. This is useful for:
  • Quickly getting started trying out the ngrok Operator
  • Local development & testing
  • Connecting containerized workloads on your local machine to your ngrok infrastructure
  • Faster iteration cycles without cloud latency
Running Kubernetes inside containers has the benefits of being quick and simple to setup compared to a bare-metal installation and keeps the Kubernetes environment more isolated from the dependencies and other applications on your computer. This is not a recommendation for how you should productionize your Kubernetes setup, but rather a guide on getting an easy to use local environment setup for development and testing. The following sections outline various options for running Kubernetes inside Docker containers on your local machine, but you can run the ngrok Kubernetes Operator in any Kubernetes cluster you like.

Choosing a container runtime

Before setting up a local Kubernetes cluster, you need a container runtime. The container runtime is responsible for running containers, managing their lifecycle, and handling networking. If you don’t already have a container runtime such as Docker installed, choose one from the options below.

Choosing a cluster provider

Select one of the following options for running Kubernetes inside containers on your local machine.

Basic commands

Create a k3d cluster

When creating a k3d cluster, the config is automatically added to your Kubeconfig file so you are ready to go immediately.

List running clusters

Delete a k3d cluster

Managing Kubernetes contexts

When working with multiple Kubernetes clusters (for example, Minikube, k3d, kind, MicroK8s, cloud clusters), it is important to manage kubeconfig contexts efficiently. A context in Kubernetes determines:
  • Which cluster kubectl is communicating with.
  • Which user credentials to use for authentication.
  • Which namespace is the default for commands.
Kubernetes stores this information in the kubeconfig file (default location: ~/.kube/config). The $KUBECONFIG environment variable is used by kubectl to know where your configuration file is. If you would like to store it somewhere else, or use different files for different clusters, you can modify the $KUBECONFIG variable.

Viewing the current context

To check which Kubernetes cluster you are currently using:
This returns the active context, which tells kubectl which cluster and credentials are being used.

Listing all contexts

To see all available Kubernetes contexts in your kubeconfig:
This will display a list of available contexts, including:
  • Cluster Name (for example, minikube, kind-my-cluster, k3d-my-cluster).
  • User Credentials.
  • Current Context (marked with *).

Switching between contexts

To switch from one Kubernetes cluster to another:

Setting a default namespace for a context

By default, kubectl uses the default namespace. You can change the default namespace for a specific context:
Or, specify a namespace when switching to a different context:

Deleting a context

If you no longer need a specific context, you can remove it from your kubeconfig:
This does not delete the cluster itself, only its entry from your kubeconfig.

Merging multiple kubeconfig files

If you have multiple kubeconfig files (for example, from cloud providers and local clusters), you can merge them:
This consolidates multiple different cluster credentials into a single kubeconfig file.