A Kubernetes bastion host is a hardened machine that sits between you and a cluster whose API server has no public address. You SSH into it, or tunnel through it, and every kubectl request reaches the control plane over the private network. It works, but each cluster behind a bastion adds tunnels, proxy settings and kubeconfig edits to your day. Kubezilla Desktop, our native app, opens SSH tunnels to remote clusters and keeps your kubeconfigs in secure local storage, so the bastion stays in the architecture while the manual plumbing leaves your terminal.
This guide covers what a bastion is, the connection patterns that work, the permissions each cloud needs, the risks, and where a desktop client fits.
TL;DR
- A bastion host is a single, hardened entry point into a private network. In Kubernetes it lets you reach an API server that has no public IP.
- You connect in one of three ways: SSH in and run kubectl on the bastion, forward a local port to the API server, or run a SOCKS5 proxy with
ssh -D. - The bastion itself becomes a target. Keep its network locked down, give every person their own account, and avoid shared admin kubeconfigs.
- Each extra cluster means another tunnel and another kubeconfig entry to maintain by hand.
- Kubezilla Desktop handles SSH tunnels and stores kubeconfigs locally, with no cloud sync or telemetry.
Table of Contents
- What a Kubernetes bastion host is
- Three ways to connect through a bastion
- Deploying the bastion: VM or pod
- Permissions each cloud expects
- Securing the bastion
- Where the manual routine breaks down
- Doing it from a desktop client
- Get Kubezilla Desktop
- Our perspective
- FAQ
- Sources
What a Kubernetes bastion host is
Google's GKE documentation defines a bastion host as a special-purpose host machine designed to withstand attack. The kOps project describes it as an external-facing point of entry into a network of private instances, which gives you one place to fortify and audit. It can be started or stopped to switch inbound SSH from the internet on or off.
That is the whole idea. Instead of exposing the control plane and every node, you expose one machine, then decide who may use it. You will also hear it called a jump box or jump server.
A bastion is not a firewall. A firewall filters traffic by rule. A bastion is a host that people log in to, or tunnel through, and the firewall rules around it decide what it can reach.
Why private clusters need one
Managed Kubernetes services let you turn off the public endpoint of the API server. Microsoft's AKS documentation notes that in a private cluster the API server endpoint has no public IP address, so management requires a VM or container with access to the cluster's virtual network. The bastion is that machine.
The security gain is real: Google frames the bastion-plus-IAP pattern as a way to keep the control plane fully off the internet, with Identity-Aware Proxy providing an identity-checked path to the bastion instead of an exposed cluster endpoint.
Three ways to connect through a bastion
All three patterns end the same way: kubectl talks to an API server it could not otherwise reach. They differ in where kubectl runs and what you configure locally.
Pattern 1: SSH in and run kubectl on the bastion
The simplest model. You SSH to the bastion, which has kubectl and credentials installed, and run commands there. Hostman's documentation describes this minimal setup: a cloud server with a public IP in the same private network as the cluster, with API requests traveling over the private network.
It needs no local configuration, but your tooling lives on a shared server. Anything graphical, such as a log viewer or a YAML editor, is out of reach. The same documentation warns that the kubeconfig grants admin rights, so shared clusters call for separate user accounts on the bastion.
Pattern 2: Forward a local port to the API server
Here kubectl runs on your laptop. You open an SSH tunnel that maps a local port to the API server's port 6443 through the bastion, then point kubectl at the local port. The pattern, as written up in an Oracle Cloud reference architecture, forwards local ports to each cluster's internal port 6443, uses a separate tunnel per cluster, and has kubectl connect to 127.0.0.1.
A typical tunnel looks like this:
ssh -fNT -L 16443:api.internal.example:6443 you@bastion.example.com
Then the kubeconfig server entry becomes https://127.0.0.1:16443. That is where the first real trouble starts: the API server certificate was issued for its real name, not for 127.0.0.1, so kubectl rejects it with a TLS error. You either add 127.0.0.1 as a Subject Alternative Name on the API server certificate or set a TLS server name in the kubeconfig. Our guide to fixing certificate errors on SSH tunnels walks through both, and the related unknown authority error has its own page.

Pattern 3: SOCKS5 proxy with ssh -D
The official Kubernetes documentation describes using a SOCKS5 proxy to access the API. You run ssh -D 1080 user@bastion, which turns your SSH client into a SOCKS5 proxy. Then you either export HTTPS_PROXY=socks5://localhost:1080 or, to make it permanent for one cluster, add a proxy-url attribute to that cluster's entry in ~/.kube/config.
The advantage over a port forward is that kubectl keeps the real API server address, so certificates keep validating. The cost is that the proxy must be running whenever you use that context.
GKE's tutorial uses a variant: the bastion runs Tinyproxy on port 8888, you reach it with gcloud compute ssh --tunnel-through-iap and -L8888:localhost:8888, then set HTTPS_PROXY=localhost:8888 before running kubectl.
Which pattern fits
| Pattern | kubectl runs on | Local setup | Best for |
|---|---|---|---|
| SSH and run on bastion | The bastion | None | One cluster, occasional access |
| Local port forward | Your machine | Tunnel plus kubeconfig edit, certificate SAN | Few clusters, scripted access |
| SOCKS5 via ssh -D | Your machine | Tunnel plus proxy-url per cluster | Several clusters, real API hostnames |
Deploying the bastion: VM or pod
Most bastions are small virtual machines. The EKS version, as Microsoft's migration guide describes it, launches an EC2 instance in a public subnet of the cluster VPC and allows port 443 from the bastion in the control-plane security group. You then configure kubectl with AWS credentials mapped to cluster RBAC, or add the bastion's IAM principal to RBAC before you disable the public endpoint.
A second option is a pod. One practitioner write-up runs an OpenSSH server in a pod with public keys baked into the image, exposes it through a load balancer, and uses SSH local forwarding to reach private services such as a database. That suits reaching services inside the cluster network. It does not help when the API server itself is unreachable, because a pod needs a working cluster to start. For a private control plane, a VM or a cloud-provided bastion service is the dependable choice.
| VM bastion | Pod bastion | |
|---|---|---|
| Works when the API server is unreachable | Yes | No |
| Reaches in-cluster services | Yes, with routing | Yes, directly |
| Needs a public IP or load balancer | Yes | Yes, for external SSH |
| Patching | OS and SSH daemon | Image rebuilds |
Permissions each cloud expects
The bastion needs three things: a network path, an identity and a Kubernetes role.
Network. Oracle's documentation says that when the API endpoint is in a private subnet, you create a private subnet in the same VCN as the cluster and add a TCP/6443 egress rule from the bastion subnet to the API endpoint subnet. On AWS it is the security group rule on port 443 described above.
Identity. Oracle also separates roles: VCN administrators manage networks and security rules, cluster administrators create bastions and worker-node sessions, and cluster users create API-endpoint sessions. Splitting duties like this keeps the person who opens a tunnel from also being the person who writes the firewall rules.
Kubernetes RBAC. Reaching the API server is not authorization. On EKS the IAM principal must be mapped to a role, and the mapping should be in place before the public endpoint is disabled, or you lock yourself out.
AKS adds more options for the network path: a VM in a peered network, a private endpoint, ExpressRoute or VPN, Azure Cloud Shell, and the command invoke feature. Microsoft notes that ExpressRoute and VPNs add cost and networking complexity, and that VNet peering needs non-overlapping CIDR planning.

Securing the bastion
A bastion concentrates risk in one machine, so it deserves the most careful hardening in the environment.
- Keep its own network locked down. The AKS best-practices guidance advises putting the bastion in a separate management network, peered to the cluster network and secured with a VPN gateway or ExpressRoute and network security groups. A bastion in an open management network only moves the exposure.
- One account per person. Shared logins make audit trails useless and revocation painful.
- Prefer short-lived or identity-based access. Static SSH keys spread to the bastion and downstream nodes, and revoking them is a manual, distributed job. On AWS, EC2 Instance Connect Endpoint and SSM Session Manager remove the need for a publicly reachable port 22 on the bastion.
- Treat the kubeconfig as a secret. An admin kubeconfig on a shared bastion is a master key. Keep personal kubeconfigs on your own machine, in local storage you control, and scope their RBAC to what each person needs.
- Mind the kubelet path. The Kubernetes documentation explains that the API server's connection to the kubelet, used for logs, attach and port-forwarding, does not verify the kubelet's serving certificate by default, which makes it unsafe on untrusted networks unless you set
--kubelet-certificate-authorityor use SSH tunneling.
For the wider picture of what to harden around the API server, see our Kubernetes API access security guide. If your organization uses single sign-on, kubeconfig OIDC authentication pairs naturally with a bastion.
Where the manual routine breaks down
One cluster behind one bastion is manageable. The friction shows up when you have several.
- Each cluster needs its own tunnel, local port and kubeconfig entry. A tunnel that dies leaves kubectl timing out with an error that looks like a cluster problem.
- Idle connections get dropped. kOps notes that its bastion load balancer has an idle timeout of 5 minutes by default, so a quiet session disappears.
- Certificate and proxy settings differ per cluster and per pattern, and they are easy to get subtly wrong.
- Logs, metrics and YAML edits need extra terminals or browser tabs on top of the tunnel.
When something fails, the cause could be the tunnel, DNS, the certificate or RBAC. Our layer-by-layer connectivity troubleshooting guide gives an order to check them in.
Doing it from a desktop client
Kubezilla Desktop is a native app for Linux, macOS and Windows that gives you one interface for clusters and resources. For bastion-fronted clusters, it opens SSH tunnels itself and supports direct remote cluster management, so you connect to several clusters without hand-written port forwards and without a VPN client or a session on the bastion. Your kubeconfigs stay in secure local storage, and the app has no cloud sync or telemetry.
Once a cluster is connected, live log streaming, metrics, pod terminals, YAML editing and workload scaling sit in the same window. Helm and ArgoCD operations are there too, as in our walkthrough on installing Argo CD with Kubezilla Desktop and Helm. If you manage clusters across several providers, multi-cloud Kubernetes management shows how this removes console hops.
Get Kubezilla Desktop
Kubezilla Desktop costs €5 per month and installs as a native app. It is built in Rust for low RAM use and fast startup, and it keeps SSH tunnels, kubeconfigs and day-to-day cluster operations in one place. See the Kubezilla Desktop page for the download and licensing.

If your clusters sit behind bastions today, connect one and compare it with your current tunnel routine. A Kubernetes client built for multi-cluster work is the quickest way to see the difference.
Our perspective
We built Kubezilla Desktop because the bastion is the right security decision and a poor daily experience. Closing the API server to the internet is sound. Asking every engineer to maintain a pile of tunnel commands, proxy variables and kubeconfig edits for every cluster is where the time goes.
Our view is that the access path should be secured once, by the team that owns the network, and then be invisible to the person doing the work. That is why the app keeps kubeconfigs in local secure storage, with no cloud sync and no telemetry: credentials stay on the machine of the engineer who uses them. It is also why SSH tunneling is a built-in feature and not a script you maintain.
A lightweight Rust app also matters more than it sounds. When you have a dozen clusters open and logs streaming, you want the tool to stay out of the way of your RAM and your attention.
Margus
FAQ
What is the difference between a firewall and a bastion host?
A firewall filters network traffic by rules, deciding what may pass between networks. A bastion host is a hardened server that people log in to, or tunnel through, to reach a private network. The two work together: firewall rules decide which hosts and ports the bastion can reach.
Do I need a bastion host if my cluster has a VPN?
Not necessarily. A VPN gives you network-level access to the private network, so kubectl can reach the API server directly. A bastion gives you a single audited entry point instead. Many teams use one or the other depending on how much network access they want to hand out, and AKS documents both as options for private clusters.
Can kubectl work over an SSH tunnel?
Yes. Forward a local port to the API server's port 6443 and point the kubeconfig at 127.0.0.1, making sure the API server certificate covers that address. Alternatively, use ssh -D for a SOCKS5 proxy and set proxy-url in the cluster entry, which keeps the real API address and avoids certificate changes.
Can a bastion host run as a pod inside Kubernetes?
Yes, an SSH server can run in a pod and be exposed through a load balancer, which is useful for reaching in-cluster services. It cannot be your way into a cluster whose API server is unreachable, since the pod has to be scheduled first. For private control planes, use a VM or a cloud bastion service.
Where should the kubeconfig for a bastion-fronted cluster live?
On your own machine, in storage only you can read, with RBAC scoped to your role. Avoid leaving a shared admin kubeconfig on the bastion. Kubezilla Desktop keeps kubeconfigs in secure local storage for exactly this reason.
Sources
- Remotely access a private cluster using a bastion host (Google Cloud)
- Bastion setup (kOps)
- Establish network connectivity to a private AKS cluster (Microsoft)
- Connect to a cluster through a bastion host (Hostman)
- Cluster access reference architecture (LogScale)
- Use a SOCKS5 proxy to access the Kubernetes API
- Enhance network access security to Kubernetes (Microsoft)
- Run an OpenSSH server as a bastion on a Kubernetes pod
- Setting up a bastion for cluster access (Oracle Cloud)
- AKS best practices
- Connect kubectl to a private cluster in EKS and AKS
- Communication between nodes and the control plane (Kubernetes)
