Install Your First Cluster with k3s
k3s is a lightweight, certified Kubernetes distribution built for resource-constrained environments. It packages the entire control plane into a single binary under 100 MB — making it the fastest way to get a real cluster running for use with CodePier.
Who is this for?
This guide is for developers who don't have an existing Kubernetes cluster and want to set one up quickly. If your team already has a cluster, you can skip ahead to Connect to CodePier.
Prerequisites
You need a Linux machine — this can be a local VM, a cloud VPS (DigitalOcean, Hetzner, AWS EC2, etc.), or bare-metal hardware.
| Requirement | Minimum |
|---|---|
| OS | Linux (Ubuntu 20.04+, Debian 11+, RHEL 8+, or similar) |
| CPU | 1 core |
| RAM | 512 MB (1 GB+ recommended) |
| Disk | 2 GB free |
You also need curl and root access. Before starting, make sure you're logged in as root or switch to root:
sudo suInstall k3s
SSH into your machine and run the official install script. This installs the k3s server, kubectl, and starts the cluster in under a minute.
curl -sfL https://get.k3s.io | sh -That's it. k3s is now running as a systemd service. You can check the service status with:
systemctl status k3sVerify the Cluster
k3s ships with its own kubectl. Confirm the node is ready and system pods are running:
k3s kubectl get nodesYou should see your node with status Ready. Then check that all system pods are running:
k3s kubectl get pods -AAll pods in the kube-system namespace should be Running or Completed within a minute or two.
Configure kubeconfig
k3s writes its kubeconfig to /etc/rancher/k3s/k3s.yaml. Copy it to your local machine so CodePier and kubectl can use it.
On the server — make the config readable
cat /etc/rancher/k3s/k3s.yamlOn your local machine — save the config
Copy the output from above and save it to a file on your local machine. Replace 127.0.0.1 with your server's IP address or hostname:
# Save the kubeconfig (paste the contents from the server)
mkdir -p ~/.kube
nano ~/.kube/k3s.yaml
# Replace the server address — change 127.0.0.1 to your server's IP
# Before: server: https://127.0.0.1:6443
# After: server: https://YOUR_SERVER_IP:6443
# Set the KUBECONFIG environment variable
export KUBECONFIG=~/.kube/k3s.yaml
# Verify connectivity from your local machine
kubectl get nodesFirewall note
Make sure port 6443 (the Kubernetes API) is open on your server's firewall. If you're using a cloud provider, check the security group or firewall rules.
Connect to CodePier
Open the CodePier desktop app and add your new cluster:
- Go to Clusters in the sidebar
- Click Add Cluster
- Select your kubeconfig file (
~/.kube/k3s.yaml) - CodePier will detect the cluster and show it as connected
Deploy Your First App
Now that your cluster is connected, let's deploy a simple Node.js app. We'll use our node-getting-started sample repo to walk through the full flow.
Create a project
- Open the CodePier app and click New Project
- Enter a Project Name — for this guide, use
hello-world - Choose a Namespace — this defaults to your project name. Keep it as
hello-world
Add your resources
Inside your project, you'll create three resources — a Deployment, a Service, and an Ingress. For each one:
- Click Add Resource
- Pick the resource type (Deployment, Service, or Ingress)
- CodePier opens the manifest editor with a starter template — edit it to match your app
Here's what the manifests should look like for the sample app:
Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
namespace: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: ghcr.io/codepier/node-getting-started:latest
ports:
- containerPort: 3000Service
apiVersion: v1
kind: Service
metadata:
name: hello-world
namespace: hello-world
spec:
selector:
app: hello-world
ports:
- port: 3000
targetPort: 3000Ingress
k3s ships with Traefik as its default ingress controller. Use a .local hostname so the app is immediately reachable from any device on your network — CodePier publishes it via mDNS / Bonjour, no /etc/hosts editing required. (On Linux, install avahi-utils first.)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world
namespace: hello-world
spec:
rules:
- host: hello-world.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-world
port:
number: 3000Ship it
Once your manifests are ready, click Apply in the editor to deploy each resource to your cluster. CodePier shows a diff of what's changing so you can review before applying.
When all three resources are applied, open https://hello-world.local in your browser — you should see "Hello World!".
Start Developing
Your app is live in the cluster. Now clone the sample repo and hot-swap the running container with your local code.
git clone https://github.com/codepier/node-getting-started.git
cd node-getting-startedThe repo includes a codepier.yaml that configures the dev environment:
deployment: hello-world
namespaces: [hello-world]
image: node:24-slim
workdir: /opt/hello-world
sync:
- ".:/opt/hello-world"
ignore:
- "node_modules"
- ".git"
cache:
- npm:~/.npmStart the hot-swap:
codepier upCodePier replaces the running container with a node:24-slim dev container, syncs your local files in real-time, and caches your npm packages between sessions. It drops you into an SSH session inside the pod. From there, install dependencies and start the dev server:
npm install
npm run devAny changes you make locally are reflected instantly in the cluster — and the Ingress keeps serving traffic at https://hello-world.local. Try editing index.js and watch it reload.
When you're done, exit the SSH session and CodePier automatically restores the original deployment.