Hands-on k3s on WSL2: Pod, Deployment, and Service Internals
A technical guide to deploying k3s on WSL2 with Ubuntu 24.04, analyzing Deployment self-healing mechanics and Layer 4 Service traffic routing.
Curated by Vibe DevOps · approx. 554 words
Key Takeaways
- k3s provides a lightweight Kubernetes distribution capable of running both control-plane and worker nodes on a single host under WSL2.
- The default kubeconfig file requires root privileges and must be secured with 600 permissions when copied to a local user directory.
- Deployments automatically maintain the desired Pod replica count via ReplicaSets during failures.
- Layer 4 Services provide a stable virtual endpoint and load balance traffic across Pods matching label selectors.
- NodePort exposes ports in the 30000–32767 range across the node, enabling direct external access to workloads.
From Original Source
k3s Architecture and Access Management on WSL2
According to a technical post on Zenn, k3s is a lightweight Kubernetes distribution optimized for edge and resource-constrained environments. On Windows 11 running WSL2 with Ubuntu 24.04 LTS, k3s can be quickly bootstrapped as a single node handling both control-plane and workload execution duties.
After installing version v1.35.5+k3s1, the API server listens on port 6443. To run kubectl commands without persistent root access, the kubeconfig file should be copied to the user's home directory and secured with 600 permissions to protect cluster access.
From Original Source
Deployment Self-Healing and Service Traffic Routing
In Kubernetes, Pods are the smallest deployable units, but they are ephemeral and get assigned new IPs upon recreation. Defining a Deployment maintains the desired state via a ReplicaSet, automatically provisioning replacement replicas if a Pod is terminated.
To provide reliable connectivity, an L4 Service routes traffic to Pod endpoints based on label selectors. Configuring a NodePort on port 30080 allows engineers to directly validate HTTP responses from the host machine without setting up an Ingress controller.
Vibe DevOps Editorial Commentary
Recommendations for Local Test Environments
DevOps Takeaway: Running k3s locally allows engineers to rapidly validate manifests before committing them to CI/CD pipelines without incurring heavy resource overhead. Scoping resources within dedicated namespaces is a best practice that ensures clean, deterministic teardowns after testing.
However, single-node testing does not surface real-world multi-node network partitioning or inter-host latency. When promoting workloads to production, kubeconfig access management and port range planning must strictly adhere to internal security policies.
Commands & Configuration Snippets
Verbatim extract for quick lookup. Verify against your infrastructure before running.
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.35.5+k3s1" sh -Install k3s with a fixed version on a Linux environment
chmod 600 ~/.kube/configSet secure access permissions for the cluster connection configuration file
kubectl get nodesCheck the readiness status of the node in the cluster
kubectl delete namespace k3s-tutorialDelete the entire namespace to clean up resources after testing
⚠️ Operational Caveats & Limitations
- This guide uses a single-node configuration intended for learning and local testing.
- Layer 4 Services do not support advanced, path-based URL routing available with Ingress controllers.