- Docker logs tail: Troubleshoot Docker containers with real-time logging - Wed, Sep 13 2023
- dsregcmd: Troubleshoot and manage Azure Active Directory (Microsoft Entra ID) joined devices - Thu, Aug 31 2023
- Ten sed command examples - Wed, Aug 23 2023
Kubernetes is notoriously challenging to configure and run. Setting up a dedicated multinode development cluster to develop code can be overkill. Rancher Desktop is a free, open-source solution from SUSE that enables developers, enthusiasts, home labbers, and others to run containers and Kubernetes clusters on a local workstation. On macOS and Linux, it uses a VM to operate containerd or dockerd and Kubernetes. For Windows systems, it relies on the Windows Subsystem for Linux v2.
Rancher Desktop features
Rancher Desktop offers the following features:
- Container management: Rancher Desktop can build, push, and pull container images. Since it uses the same container runtime as Kubernetes, the images are ready for your Kubernetes clusters running in Rancher Desktop or as standalone containers. In addition, images are immediately available since you don't have to check them into a separate repository.
- Built-in security scanning: You can proactively scan for security vulnerabilities in container images.
- Kubernetes clusters: One of the great features of the Rancher Desktop Kubernetes cluster is that it allows developers to choose the version of Kubernetes that they want to run. In addition, it enables developers to select the same version of Kubernetes that are running in production clusters to ensure compatibility and interoperability with their code.
- Open-source components: Moby, K3s, kubectl, etc.
Rancher Desktop architecture
The underlying components of Rancher Desktop are free, open-source utilities and include:
- Nerdctl: A Docker-compatible CLI for working with containerd that allows experimenting with the latest features not present in Docker
- Kubectl: Command-line tool used to interact with Kubernetes
- Helm: Provides an APT-like or YUM-like experience installing apps in Kubernetes
- Docker CLI: The Docker command line tool
- Kubernetes K3s: A lightweight open-source Kubernetes distribution
- Containerd/dockerd: Container runtime and container engine components
Installing Rancher Desktop
You can run Rancher Desktop on the following platforms:
- Mac (Apple Silicon)
- Mac (Intel)
- Windows
- Linux
The installation process for Rancher Desktop is easy. You just have to decide whether you want to install Rancher Desktop for all users or only for yourself.
Running and using Rancher Desktop
When Rancher Desktop launches for the first time, you will notice that it begins downloading and starting K3s. This process does not take long. In the example below, Rancher downloads and starts the single-node K3s cluster in WSL2.
One thing you will want to do is switch your Kubernetes context to the Rancher Desktop context. In Kubernetes, the kubeconfig file in the user's profile directory can store configurations (contexts) for multiple clusters. Switching the context tells the kubectl command which cluster you want to work with.
Below, I have a workstation with configurations for multiple Kubernetes clusters. As you can see in the image, the current context doesn't point to the rancher-desktop cluster. We will need to switch the context to "rancher-desktop."
To view your current kubectl context, issue the following command:
kubectl config get-contexts
To switch the kubectl context to rancher-desktop, issue the command:
kubectl config use-context rancher-desktop
To verify that you are connected to the rancher-desktop cluster, use the command:
kubectl get nodes or kubectl get nodes -o wide
The "-o wide" parameter provides additional details about the cluster, including the network address information for the cluster.
Below, we are successfully connected to the Rancher Desktop single-node cluster. At this point, we can begin interacting with the cluster like any other Kubernetes cluster using kubectl.
Back on the Rancher Desktop interface, below, we can see the Port Forwarding configuration screen. Here, you can set up port forwarding to Kubernetes workloads running in Rancher Desktop. Port forwarding in Kubernetes is needed to forward traffic coming from outside the Kubernetes cluster to the proper internal address and port of the Kubernetes hosted application.
On the Images configuration screen, you can view currently installed images and add images to your cluster. Navigate to Images and then click Add Image.
One of the really nice features built into Rancher Desktop is its ability to scan images for vulnerabilities. Click the three dots next to the image and select Scan.
On the Troubleshooting screen, you can view logs, reset Kubernetes, or even perform a Factory Reset, removing all Rancher Desktop configurations.
Rancher Desktop also includes a Diagnostics screen that proactively displays any issues discovered in the environment.
If you are wondering how to configure your Kubernetes version in Rancher Desktop, this option is found under File > Preferences.
Running an application in Rancher Desktop Kubernetes
Let's run our Nginx application in Rancher Desktop. Using kubectl, we can apply a manifest file to run the Nginx image as a pod in our Rancher Desktop cluster.
Create a file with the following contents:
apiVersion: v1 kind: Pod metadata: name: rancher-pod spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 hostPort: 8176
Once you have created the file, apply it using the following command:
Kubectl apply -f <your file name>
Now, you should be able to browse to the local port configured in the manifest file (8176) and reach the Nginx application running in the Rancher Desktop pod.
Subscribe to 4sysops newsletter!
Wrapping up
Rancher Desktop provides an interesting option for developers, enthusiasts, and home labbers to easily play around and interact with Kubernetes clusters and containers without the complexity of setting up a full-blown Kubernetes cluster. The Rancher Desktop GUI interface allows easy viewing and configuring of port forwarding and images for your Kubernetes cluster. As shown, you can also perform security scanning of images.