Rancher manages lean Kubernetes workloads
Construction Guide
Installing Rancher
The Rancher developers also distribute their product as a Helm chart. As a reminder, the Helm package manager (Figure 3) for Kubernetes lets you deliver metadata and images in a standardized format. Like the distributions' normal packages, Helm charts can be obtained from different directories.
For Rancher, first add the Helm directory of the Rancher project to your K3s installation (Listing 2, line 1). Then create a namespace in K3s in which all the Rancher services will run (line 2) and update the metadata of the available Helm charts again (line 3). The command in line 4 creates a running Rancher cluster, where you need to replace <Host>
and <Email>
with the values for your use case.
Listing 2
Rancher Install
# helm repo add rancher-latest https://releases.rancher.com/server-charts/stable # kubectl create namespace cattle-system # helm repo update # helm install rancher rancher-latest/rancher --namespace cattle-system --set hostname=<I>Host<I> --set replicas=3 --set ingress.tls.source=letsEncrypt --set letsEncrypt.email=<I>E-Mail<I> --set letsEncrypt.ingress.class=nginx # kubectl -n cattle-system rollout status deploy/rancher # kubectl -n cattle-system get deploy rancher
The command in line 5 shows the progress of the install, which can take some time. The final command should show a ready-to-use deployment with three instances available. The Rancher installation is now complete.
If you now open the URL that contains the address of the load balancer, you will automatically be taken to the installation's login page. Rancher displays the user data at the command line during the deployment process, but the first time you log in to the web interface, you will need to change the credentials. Use the command
# kubectl get secret --namespace cattle-system bootstrap-secret-o go-template='{{ .data.bootstrapPassword|base64decode}}{{ "\n" }}'
if you did not make a note of the password during the installation.
Adding Nodes
Although you currently have a usable Rancher cluster, you can't roll out workloads on it yet. The nodes – the systems that run the Kubernetes clusters for the applications – are missing. In terms of preparation, the same steps apply to the nodes as to the Rancher servers, except you do not need a database; however, NTP must again be active.
Once all the requirements are met, the command
# curl -sfL https://get.k3s.io | K3S_URL=https://<Rancher-Hostname>:6443 K3S_TOKEN=<Token> sh --
is all it takes. Replace <Rancher-Hostname>
with the hostname for the load balancer. The content you need to specify for K3S_TOKEN
can be found on the servers in the /var/lib/rancher/k3s/server/node-token
files.
Using Rancher
Immediately after taking these steps, the first workloads can be rolled out to Rancher. You can also access the Rancher Marketplace from the web user interface, which is where preconfigured applications optimized for Rancher are available. They again find their way into the installation by Helm charts.
Of course, this far from exhausts Rancher's capabilities. Once the first applications are rolled out as services in Rancher, you can set up monitoring for them from the Monitoring menu item, including alerting on the basis of various parameters. If this combination of components looks familiar to you from the context of cloud-native environments, you are on the right track, because Rancher does not implement monitoring itself. Instead, it relies on a combination of Prometheus (Figure 4), the matching Alert Manager, and the Grafana GUI component (Figure 5) in the background.
Buy this article as PDF
(incl. VAT)