This guide covers deploying Rancher for comprehensive cluster management and Longhorn for cloud-native distributed storage in your K3s cluster.
Deploying Rancher
Add Rancher Helm Repository and Create Namespace
helm repo add rancher-latest https://releases.rancher.com/server-charts/stablekubectl create namespace cattle-systemSince Traefik is already deployed, Rancher will utilize it for ingress. Deploy Rancher with Helm:
helm install rancher rancher-stable/rancher \ --namespace cattle-system \ --set hostname=rancher.k3s.your.domain \ --set tls=external \ --set replicas=3Create Ingress for Rancher
Create an ingress.yml file with the following configuration:
apiVersion: traefik.io/v1alpha1kind: IngressRoutemetadata: name: rancher namespace: cattle-systemspec: entryPoints: - websecure routes: - match: Host(`rancher.k3s.your.domain`) kind: Rule services: - name: rancher port: 443 middlewares: - name: default-headers tls: secretName: k3s-your-domain-tlsApply the ingress configuration:
kubectl apply -f ingress.ymlNow, you should be able to manage your cluster from https://rancher.k3s.your.domain.

Deploying Longhorn
If you want to use cloud-ready drive shared storage, follow these steps:
Install Required Packages
Only on the VMs you want to deploy longhorn:
sudo apt update && sudo apt install -y open-iscsi nfs-commonEnable iSCSI
sudo systemctl enable iscsidsudo systemctl start iscsidAdd Longhorn Label on Nodes
A minimum of three nodes are required for High Availability. In this setup, we will use three worker nodes:
kubectl label node k3s-worker-1 storage.longhorn.io/node=truekubectl label node k3s-worker-2 storage.longhorn.io/node=truekubectl label node k3s-worker-3 storage.longhorn.io/node=trueDeploy Longhorn
Modified to use storage.longhorn.io/node=true label:
kubectl apply -f https://raw.githubusercontent.com/meroxdotdev/merox.docs/refs/heads/master/K3S/cluster-deployment/longhorn.yamlVerify Deployment
kubectl get pods --namespace longhorn-system --watchPrint Confirmation
kubectl get nodeskubectl get svc -n longhorn-systemExposing Longhorn with Traefik
Create Middleware Configuration
Create a middleware.yml file:
apiVersion: traefik.io/v1alpha1kind: Middlewaremetadata: name: longhorn-headers namespace: longhorn-systemspec: headers: customRequestHeaders: X-Forwarded-Proto: "https"Setup Ingress
Create an ingress.yml file:
apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: longhorn-ingress namespace: longhorn-system annotations: traefik.ingress.kubernetes.io/router.entrypoints: websecure traefik.ingress.kubernetes.io/router.tls: "true" traefik.ingress.kubernetes.io/router.middlewares: longhorn-system-longhorn-headers@kubernetescrdspec: rules: - host: storage.k3s.your.domain http: paths: - path: / pathType: Prefix backend: service: name: longhorn-frontend port: number: 80 tls: - hosts: - storage.k3s.your.domain secretName: k3s-your-domain-tls
Next Steps
Explore the Advanced Resources guide for additional tools including NFS storage, monitoring solutions, ArgoCD for GitOps, and cluster upgrade procedures.