How to Install Kubernetes on Ubuntu 26.04 and 24.04

Share

To install Kubernetes on Ubuntu 26.04 or 24.04, use MicroK8s to create a single-node cluster. Kubernetes runs and manages applications packaged in containers.

This guide installs the cluster, checks a test workload and explains networking and removal. If you need help, leave a comment or contact us.

Before you begin
  • Ubuntu 26.04 LTS or 24.04 LTS, internet access and an account with sudo privileges.
  • Canonical recommends at least 4 GB RAM and 20 GB disk space for workloads. More may be needed for your applications.
  • Use a dedicated test machine or VM. This is a single-node lab, not a highly available production cluster.
  • Back up important data. Check for existing Kubernetes services, occupied ports and network ranges before installing on a shared host.

Canonical maintains MicroK8s as a simpler way to run Kubernetes on Ubuntu. This guide creates a single-node environment for learning and development. The kubeadm tool takes a more hands-on approach to assembling a cluster; use a dedicated kubeadm guide if that is what you need.

Install MicroK8s on Ubuntu

1Check Ubuntu and Snap

Open a terminal and check your Ubuntu release and whether snapd responds:

Terminal
lsb_release -a
snap version

If snap is missing, install it from Ubuntu repositories, then reconnect or restart as needed:

Terminal
sudo apt update
sudo apt install snapd
2Install the stable channel

This uses Canonical’s 1.36 stable channel. Classic confinement gives the snap broad access to the system. A versioned channel receives automatic patch updates within that minor release without automatically moving to the next minor release. Plan upgrades and backups for important workloads.

Terminal
sudo snap install microk8s --classic --channel=1.36/stable

MicroK8s includes its own containerd runtime and Kubernetes components. You do not need to install Docker or a separate kubeadm runtime for this method.

3Wait for the cluster

Use sudo for the commands in this guide. Startup and image downloads can take several minutes.

Terminal
sudo microk8s status --wait-ready
sudo microk8s kubectl get nodes -o wide

The node should report Ready. If startup does not finish, stop waiting with Ctrl+C and use the troubleshooting section.

Networking, Swap and Security

MicroK8s supplies its own Pod networking. Pods communicate through this network; it is separate from the host network and must not overlap networks you need to reach. Check your VPN and local network before using an existing machine. This example does not expose a service to the internet.

Check swap with swapon --show. Canonical’s MicroK8s quick start does not instruct users to disable swap. Do not copy kubeadm swap or runtime configuration into this installation without checking the requirements for your chosen Kubernetes setup.

Terminal
swapon --show
sudo ufw status verbose

Treat the Kubernetes API and cluster credentials as administrative access. Restrict access to trusted users and networks; do not expose cluster ports publicly. The microk8s group grants powerful cluster access, so this guide uses sudo instead of adding users to that group.

If UFW or a cloud firewall is active, Pod traffic may need carefully scoped forwarding and interface rules. Do not disable the firewall or accept all forwarded traffic blindly on a shared host. Review Canonical troubleshooting and the ports reference for your network. Before changing remote firewall rules, confirm the actual SSH port is allowed, keep your session open and have a recovery console available.

Run and Remove a Test Workload

1Create a test deployment

Choose a name that is not already in use. This downloads the Nginx image and creates a deployment in the default namespace. It does not create a public service.

Terminal
sudo microk8s kubectl get deployments
sudo microk8s kubectl create deployment uf-k8s-test --image=nginx

If the name already exists or the create command fails, stop. Choose a different name consistently in all commands below; never delete a deployment you did not create.

2Check the result

Wait for the deployment and inspect its Pod. A successful rollout reports that it completed; the Pod should show Running. Image downloads depend on network access.

Terminal
sudo microk8s kubectl rollout status deployment/uf-k8s-test --timeout=180s
sudo microk8s kubectl get pods -l app=uf-k8s-test -o wide
3Open the test application

On the Ubuntu machine, check whether port 8080 is already in use. If a listener is shown, choose another unused port in the following commands.

Terminal
sudo ss -ltn '( sport = :8080 )'

In the first terminal, forward the local port to the test deployment. Keep this terminal open. The explicit 127.0.0.1 address accepts connections only from this Ubuntu machine.

Terminal
sudo microk8s kubectl port-forward --address 127.0.0.1 deployment/uf-k8s-test 8080:80

When forwarding is ready, open a second terminal on the same Ubuntu machine and run:

Terminal
curl http://127.0.0.1:8080/

If curl is missing, install it with sudo apt update followed by sudo apt install curl, then repeat the test. The response should contain the Nginx welcome page. On a desktop, you can instead open http://127.0.0.1:8080/ in a browser on that machine. A browser on your own computer cannot reach this loopback address on a remote server without an SSH tunnel. Return to the first terminal and press Ctrl+C to stop forwarding.

4Remove the test

Delete only the deployment you successfully created in this tutorial:

Terminal
sudo microk8s kubectl delete deployment uf-k8s-test

Enable Cluster DNS

DNS lets Pods find Kubernetes services by name. Enable it if your workloads need service discovery:

Terminal
sudo microk8s enable dns
sudo microk8s kubectl get pods -n kube-system

Wait for the CoreDNS Pod to become Running and Ready. Then run a lookup from a temporary Pod. Keep the same terminal open for all three commands; it stores the generated Pod name for cleanup. The image comes from the Kubernetes project registry.

Terminal
DNS_POD=$(printf '%s\n' '{"apiVersion":"v1","kind":"Pod","metadata":{"generateName":"uf-dns-test-"},"spec":{"restartPolicy":"Never","containers":[{"name":"dns","image":"registry.k8s.io/busybox:1.27.2","command":["sleep","3600"]}]}}' | sudo microk8s kubectl create -f - -o name)
printf '%s\n' "$DNS_POD"

A successful create prints a generated name such as pod/uf-dns-test-abcde. If no name appears or creation fails, stop; do not run the following commands until creation succeeds.

Terminal
sudo microk8s kubectl wait --for=condition=Ready "$DNS_POD" --timeout=180s
sudo microk8s kubectl exec "$DNS_POD" -- nslookup kubernetes.default.svc.cluster.local

A successful lookup returns an address for the Kubernetes service. A failed lookup can indicate a CoreDNS, service or Pod networking problem. A timeout before the lookup can also mean the image could not be pulled. Check the Pod events and the troubleshooting section before changing firewall settings.

Remove only the generated Pod recorded in this terminal:

Terminal
case "$DNS_POD" in
  pod/uf-dns-test-*) sudo microk8s kubectl delete "$DNS_POD" ;;
  *) printf "%s\n" "No test Pod recorded; nothing deleted." ;;
esac
unset DNS_POD

Troubleshoot MicroK8s

Cluster not ready: Check free space, memory, network access and the diagnostic report. The archive can contain sensitive configuration and logs; inspect it before sharing.

Terminal
sudo microk8s status
sudo microk8s inspect

Pod stuck pending or pulling an image: Read the events for the named Pod, check capacity and verify access to the image registry. Replace the placeholder with the actual Pod name.

Terminal
sudo microk8s kubectl describe pod POD_NAME

Pods cannot communicate: Check network overlap, forwarding and firewall rules. Use the Canonical troubleshooting and ports pages above before making changes. Changing a firewall over SSH can disconnect you.

Remove MicroK8s

Removing the snap stops the cluster and can remove workloads and cluster data. Back up anything you need first. Inspect persistent storage and any snap snapshots separately; this command does not promise to erase every host file or backup.

Terminal
sudo snap remove microk8s

If you enabled firewall rules or created external resources separately, review them individually. Do not remove shared firewall rules or directories without checking what uses them.

Helpful Resources

Read the Canonical MicroK8s guide and the Kubernetes concepts documentation.

Frequently Asked Questions

Is MicroK8s Kubernetes?

Yes. MicroK8s is a Kubernetes distribution packaged by Canonical.

Do I need Docker for this guide?

No. MicroK8s includes its own containerd runtime.

Is this cluster highly available?

No. A single node is a useful lab but cannot keep running if that node fails.

Will the test application be public?

No public Service is created in the example. Other network and host configurations still need review.

Can I add more nodes later?

MicroK8s supports clustering, but node networking, firewall rules, storage and availability require additional planning.

Related guides: Install Docker on Ubuntu | Install Ubuntu Server.