If you’ve ever played with K8S, you’ll know that there’s something called Minikube that allows you to build a single-node K8S environment on the local machine. Recently found a graphic chemical tool Rancher Desktop, better than Minikube, basic can achieve a key to build K8S environment, in Win10 with very convenient, recommend to everyone!

SpringBoot e-commerce project mall (50K + STAR) address: github.com/macrozheng/…

Rancher Desktop profile

Rancher Desktop is an open source K8S management tool currently available on Github with 2.9K+Star. It is a desktop version of K8S and container management tool, supported on Windows, macOS and Linux. If you want to build a K8S environment on Windows and use Minikube, you need to build a virtual machine, install Linux, and then install Minikube. With Rancher Desktop you just install it, and it installs the K8S environment automatically, which is really handy!

The following is a picture of Rancher Desktop user interface, support for one click to switch K8S version, very good!

WSL

Thanks to WSL (Windows Subsystem for Linux), it is much easier to install the Linux subsystem under Windows without the overhead of traditional virtual machines or dual-boot setup. The Rancher Desktop for Windows edition is based on WSL to install the K8S environment.

Install Linux distributions using WSL (default Ubuntu)
wsl --install
# list the Linux distributions you have installed
wsl --list --verbose
# List of Linux distributions available through the online store
wsl --list --online
# Close the Linux subsystem
wsl --shutdown
Copy the code

PowerShell

PowerShell is a cross-platform task automation solution consisting of a command line shell, a scripting language, and a configuration management framework. PowerShell runs on Windows, Linux, and macOS.

After the K8S environment is installed, we will use PowerShell to operate K8S. Tabby is a great tool and PowerShell support is very good.

The installation

Next we’ll install Rancher Desktop on Win10 to see if it works better than Minikube.

  • Download the Rancher Desktop installation package at github.com/rancher-san…

  • Double-click install after successful download, will let you select the K8S version and container runtime;

  • After that, Rancher Desktop will install K8S environment and WSL by itself. There is no need to download it manually. If you cannot download it, you can switch to K8S version and try itv1.21.9Version;

  • This is then available in PowerShellkubectlCommand, such as view the cluster information, so far K8S environment installed, thief simple!

use

Next we will deploy a Nginx application on K8S to see if the K8S environment installed using Rancher Desktop is the same as Minikube’s!

  • First, create a Deployment for deploying the Nginx application;
Kubectl create deployment kubernetes-nginx --image=nginx:1.10Copy the code
  • Then check whether the application is ready to deploy.
kubectl get deployments
Copy the code

  • After successful deployment we create a service to expose the Nginx application for external access;
kubectl expose deployment/kubernetes-nginx --type="NodePort" --port 80
Copy the code
  • Check that the service can get external access ports;
kubectl get services
Copy the code

  • Next, you can access the Nginx service directly from the browser.

Visual management

You can use Dashboard to manage K8S visually when using Minikube. You can also use Dashboard to manage K8S environment when using Rancher Desktop. Let’s try it out.

  • First installation in K8S environment Dashboard, use the following command, install script address: raw.githubusercontent.com/kubernetes/…
kubectl apply -f recommended.yaml
Copy the code
  • Since login tokens are required to access Dashboard, we need to create users and generate tokens first;

  • createdashboard-adminuser.yamlConfiguration file, configurationadmin-userAccount and assign the cluster administrator role.
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard
Copy the code
  • Run the following command to create oneadmin-userUsers;
kubectl apply -f dashboard-adminuser.yaml
Copy the code
  • Run the following command to generate a login Token and copy it for use when you log in to the Dashboard:
kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
Copy the code

  • usekubectl proxyRun the following command to enable external access to the Dashboard:http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

  • You can then enjoy using Dashboard to manage your K8S environment, such as viewing all the Deployments;

  • View all running pods;

  • View all services that take effect.

conclusion

Installing a K8S environment on Windows was always a hassle until using Rancher Desktop and realizing how easy it could be! Minikube is no different from Minikube. If you want to experience K8S on Windows, you can try it!

If you want to learn more about K8S, check out the series of K8S tutorials I wrote earlier.

If you want to practice the whole set of micro service projects in K8S, recommend this standard star 8.2K+ actual combat e-commerce project (with a full set of tutorials) : github.com/macrozheng/…

The resources

  • Rancher Desktop official documentation: docs.rancherdesktop. IO /
  • K8S official documentation: kubernetes. IO/useful/docs/hom…
  • WSL usage documentation: docs.microsoft.com/zh-cn/windo…