Quick start Kubernetes
The quickest and easiest way to get started with Kubernetes is by setting it up in a Docker Desktop. Docker Desktop currently provides a feature to quick start a single node Kubernetes cluster without going through the difficulties of manually setting up one.
Installing Docker Desktop
Docker Desktop is currently supported across multiple platforms. Visit https://www.docker.com/products/docker-desktop/ to install for your operating system.
Once installed, you will have to enable Kubernetes within the Docker Desktop. If you are using WSL2 in Windows, please enable Docker Desktop - WSL2 integration as well.
Enabling WSL2 support in Docker Desktop (Optional)
If you are using Docker Desktop on Windows, it is highly recommended you use it along with WSL2. You may follow the instructions at https://docs.docker.com/desktop/windows/wsl/ to enable Docker Desktop - WSL2 integration.
Enabling Kubernetes in Docker Desktop
Docker Desktop comes bundled with a ready to use, single node Kubernetes cluster. To enable, follow the instructions at https://docs.docker.com/desktop/kubernetes/. Once installed you will have to ensure access to the kubectl
command as described in https://docs.docker.com/desktop/kubernetes/#use-the-kubectl-command.
For WSL2 users, if you do not find
docker
command orkubectl
command working on WSL2 terminal (Windows Terminal with WSL support), ensure you have completed Step 7 in https://docs.docker.com/desktop/windows/wsl/#install.
Setting up Rancher
Rancher, owned by SUSE Linux, is a GUI based Kubernetes Manager. Previously, Rancher had its own orchestration platform called Cattle, which was similar to Kubernetes, but much lighter. From Rancher 2.x, all other orchestration platform support has been deprecated, and Rancher works exclusively with Kubernetes. However, there’d be references to term Cattle, which can be ignored.
You can use Kubernetes without Rancher. However, for beginners, it’d be difficult to understand the various configurations and file structures required to get Kubernetes to work. Rancher should be considered as a starting point, and should eventually be used for management needs only.
Follow the guides at https://rancher.com/docs/rancher/v2.6/en/installation/install-rancher-on-k8s/ to set up Rancher
Prerequisites
Prior to installing Rancher, ensure you have access to the kubectl
command. Further to it, you will need Helm installed as well. Helm is a kind of package manager for Kubernetes configurations. Generally, for deploying an application in Kubernetes, you’d have to end up writing multiple configuration files. Helm makes it easy to combine those configuration into bundles called Helm Charts.
Installing Helm
Follow the instructions at https://helm.sh/ to install Helm on your operating system. Ensure to choose the right package according to your platform.
Installing Cert-manager
Cert-Manager is a certificate manager for Kubernetes, which facilitates in generating certificate signing requests (CSR), issuing self signed certificates, liaising with issuers like https://letsencrypt.org/ (free) etc. It is a mandatory prerequisite if you are planning to use self signed or letsencrypt certificates for Rancher (else you’d need to bring your own certificates).
Follow the steps at https://cert-manager.io/docs/installation/helm/#4-install-cert-manager or https://rancher.com/docs/rancher/v2.6/en/installation/install-rancher-on-k8s/#cli-tools
Installing NGINX Ingress
Kubernetes is a closed system with its own network (example: Overlay network or CNIs). If you want to interact with your pod externally, like access applications over a URL from your browser, you need an ingress. NGINX is a preferred ingress and would suit most use cases (except TCP ingress needs, though NGINX has TCP proxy mode).
To install, follow the instructions at https://kubernetes.github.io/ingress-nginx/deploy/#quick-start. Once installed, you can check if NGINX is running by performing a netstat check. E.g. netstat -ntlp
and checking for ports 80 and/or 443 being open on Linux based operating systems, or netstat -aon | findstr “:80 :443”
on Windows.
Installing Rancher
Once you have the cert-manager and NGINX ingress installed, Rancher can be installed. You have to follow the installation steps at https://rancher.com/docs/rancher/v2.6/en/installation/install-rancher-on-k8s/#1-add-the-helm-chart-repository.
If you are not installing Rancher on an internet accessible (inbound) Static IP system with open ports (if you are reading this article, that would most likely the case), you have to choose the Rancher-Generated Certificates in the Step 5 of installation. You may also skip Step 3 (but read for understanding).
If you have installed cert-manager as described above, ensure to skip Step 4 of the installation steps.
Once installed, Rancher should be accessible over https://localhost
or https://127.0.0.1
. You’d see a security warning since it uses self-signed certificates. Ignoring the warning and proceeding is safe since you know the website you are visiting.
Updating ingressClassName in ingress config
On Kubernetes versions above v1.22, you’d be presented with a 404 error page on visiting the above URLs. This is due to some breaking changes introduced by Kubernetes.
If interested, you may read about it at https://kubernetes.github.io/ingress-nginx/#faq-migration-to-apiversion-networkingk8siov1.
You are expected to include ingressClassName
at .spec.ingressClassName
for the nginx ingress controller to include your ingress resource.
$ kubectl edit ingress rancher -n cattle-system
In the Ingress resource under the spec object add the ingressClassName
field
spec:
ingressClassName: nginx // line to be added
Use the editor save command (ESC :wq
) to save the ingress resource.
Visiting https://localhost
or https://127.0.0.1
would now load the Rancher application.