This article builds a single-node Rancher server and two k3s cluster environments, and uses Rancher’s Continuous Delivery feature to operate both k3s clusters via GitOps.
Step 1: Deploying a Rancher Server
First, on the rancher node, run the following docker command to set up a single-node Rancher server.
|  |  | 
The Rancher server will start in about a minute. Open the Rancher node’s IP address in your browser to access the Rancher UI.
Since Rancher uses a self-signed certificate in this case, your browser will show a certificate warning. You can safely skip this warning. In some browsers, the skip button may not appear. In that case, click anywhere on the error page and type thisisunsafe. This will bypass the warning and accept the certificate.
On first access, you need to set an initial password. Follow the on-screen instructions to set it up.
Step 2: Deploy k3s Kubernetes Cluster
Next, deploy the k3s clusters. The procedure is very simple: just run the following command on both the k3s-1 and k3s-2 nodes.
Since we plan to upgrade later, we’ll intentionally deploy an older version of k3s here.
k3s-1
|  |  | 
k3s-2
|  |  | 
After deployment, check the cluster with the following command:
|  |  | 
Note: K3s assumes operations as the root user, so sudo privileges are required.
Step 3: Add k3s cluster to Rancher
Next, import the k3s clusters into Rancher. Follow these steps to register k3s-1:
- In Rancher’s Global view, click Add Clusteron the right, then selectOther Cluster.   
- Enter the cluster name k3s-1and clickCreate.
- Click the command starting with curl...and run it on the k3s-1 node. 
Register k3s-2 in the same way.
Step 4: Cluster Group
Now, let’s start using Continuous Delivery. In the Global view, select Tools -> Continuous Delivery.
First, create a Cluster Group. Go to the Cluster Group menu on the left, click Create on the right, and enter the Cluster Group creation menu. 
We’ll use k3s for this demo, so enter k3s-demo as the Name.
Next is an important step. The Cluster Group selects clusters with the specified label, so click Add Rule and set a label. For this demo, since we’re using K3s, set the Cluster Selectors label to k3s=true.

After setting, click Create to finish creating the Cluster Group.
Next, assign the two imported k3s clusters to this Cluster Group. Go to the Clusters menu on the left, click the ︙ next to k3s-1, and select Assign to. 
Click Add/Set Label, set the label k3s=true as before, and click Apply. Now this cluster is assigned to the group you just created. 
Do the same for k3s-2. On the Cluster Groups screen, you should see Clusters Ready as 2. 
Step 5: Git Repos
In this step, set up the Git Repo to reference. Go to Git Repos on the left, click Create on the right, and enter the Git Repos creation screen.  After entering a name, fork
After entering a name, fork https://github.com/rancher/fleet-examples with your Github account, and set the Repository URL (e.g. https://github.com/xibuka/fleet-examples.git ). Also, set Paths to /single-cluster/manifests where the guest-book definition files are located. Next, set where to deploy this Git Repos. From the Deploy To menu, select the Cluster Group you created earlier and click Create.

Now, the guest-book resources will be deployed to both k3s-1 and k3s-2. 
Next, add a new file nginx.yaml under deployment. After adding the following content, Continuous Delivery will detect this file and deploy it to the Cluster Group.
|  |  | 
After deployment, check the Pod and Service on the cluster.  

Similarly, if there are changes to the monitored files, those changes will be deployed to the cluster group as well. Try changing the following two lines in the YAML above:
|  |  | 
The changes are reflected.

Step 6: Deploy Application
In this step, register a Git Repo and deploy a Rancher application.
Set the Repository URL to https://github.com/xibuka/core-bundles.git, and add the following two paths with Add Path:
- /longhorn
- /longhorn-crd  
Click Create and the defined application will be deployed.
 

Step 7: Upgrade
In this step, register a Git Repo and upgrade both k3s clusters. To perform the upgrade, use the Automated Upgrades feature below.
https://rancher.com/docs/k3s/latest/en/upgrades/automated/
First, prepare the resources needed for this feature. Click and run the following commands one by one on each cluster.
|  |  | 
Next, fork https://github.com/xibuka/k3s-upgrade-plan and set up the Git repos. Set the Branch Name to Main and click Create. Since everything under / is targeted, you don’t need to add a path. 
Check that the current k3s version is 1.21.5+k3s2. 
Change the version in the Plan file in the Git Repos to 1.22.2+k3s1 and commit. After a while, both k3s clusters should be upgraded to version 1.22.2.
 

That’s it for the Fleet demo, but there are still many more features to explore, so give them a try!