Published November 2, 2026 6 min read

Lesson from k3s Kubernetes: You Don't Have to Follow Outlines

Joshua

Joshua Uzuegbu

Software Engineer

I just finished my k3s Kubernetes course and the lesson was from a broken part.

I'm a backend engineer, starting my DevOps journey and I wanted to understand how real apps get deployed and kept running on a VM. To be honest, also to increase my chances for employment. The course setup used two virtual machines, a server node and an agent node.

The Problem

The two machines couldn't talk to each other on the provider. No connection meant the agent could never join clusters, so there was nothing to deploy to. The kind of blocker that stifles momentum.

The Solution

So I changed the setup. I ran the agent node as a container inside the server VM, using nerdctl instead of Docker since k3s works with containers by default. Then I wrote a YAML file to deploy my app and copied the app image into the agent node so it could run pods there. Traefik, the ingress that comes with K3s, handles the traffic.

The Server Node Creation

curl -sfL https://get.k3s.io | sh

sudo k3s kubectl get nodes

// Also we need to get the node token
sudo cat /var/lib/rancher/k3s/server/node-token

// To get IP address of our server node which the agent node will use
ip -4 route get 1.1.1.1 | grep -oP 'src \K\S+'

The Agent Node Creation

What the course recommended on another VM:

curl -sfL https://get.k3s.io | K3S_URL=https://:6443 \
  K3S_TOKEN='' sh

What we are doing instead — running the agent as a container:

sudo nerdctl run -d --restart=always --name k3s-agent --hostname k3s-agent \
  --privileged --tmpfs /run --tmpfs /var/run \
  -v /lib/modules:/lib/modules:ro \
  -e K3S_URL=https://172.16.0.2:6443 \
  -e K3S_TOKEN='' \
  rancher/k3s:v1.36.5-k3s1 agent

So the container also survives a crash and restarts.

Importing the Container Image

After that you run this to import the container image:

sudo nerdctl --address /run/k3s/containerd/containerd.sock --namespace k8s.io save name:latest | sudo nerdctl exec -i k3s-agent ctr --address /run/k3s/containerd/containerd.sock --namespace k8s.io images import -

The Edge Case

Then came the edge case. Whenever the machine restarted, the link that connects my app to the internet dropped and the page went down. I fixed it with a small background service that notices when the link is gone and reconnects it within seconds. Now even after a restart, the app comes back on its own.

What we used to mitigate the dropped connection after every restart (we were on free tier):

Create the Service

sudo tee /etc/systemd/system/traefik-forward.service > /dev/null <<'EOF'
[Unit]
Description=Port-forward Traefik to 8081 for Instabox
After=k3s.service
Wants=k3s.service

[Service]
Environment=KUBECONFIG=/etc/rancher/k3s/k3s.yaml
ExecStart=/usr/local/bin/kubectl port-forward --address 0.0.0.0 -n kube-system service/traefik 8081:80
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

Turn It On

sudo systemctl daemon-reload
sudo systemctl enable --now traefik-forward
sudo systemctl status traefik-forward
curl --max-time 5 localhost:8081

What I Took Away

What I took away is that real learning in DevOps happens when what is outlined doesn't work and you have to work your way around it.

URL of the hosted project: https://8081-agqxqoosjyb4ycuqhj2djmt7vq.instabox.tech/

VM Provider: http://instabox.sh

Kubernetes DevOps k3s Containers
Joshua

Joshua Uzuegbu

Backend Engineer with a statistics background. Statistics trained me to ask what could go wrong, and I carry that into how I design systems. On an event ticketing platform with Paystack, I assumed the payment webhook would eventually fail. So I built two paths: a fast one (the webhook) and a slow one (an API reconciliation check). No payment gets missed.