Rancher Installation
This is a follow up to "RKE2 Ansible Installation" and assumes you're working on an RKE2 cluster similar to the one set up in that document.
Example commands and configs are for 3 masters, 3 workers and an additional jump node all running Ubuntu.
Example topology:
Name | IP |
---|---|
Master-01 | 10.40.140.4 |
Master-02 | 10.40.140.5 |
Master-03 | 10.40.140.6 |
Worker-01 | 10.40.140.7 |
Worker-02 | 10.40.140.8 |
Worker-03 | 10.40.140.9 |
Jump | 10.40.140.10 |
-
ssh into the jump machine
Enter the ssh password when prompted
-
Install kubectl if it's not already installed
-
Make sure we're using the correct kubeconfig
-
Confirm that our nodes and pods are correct and health
Install Rancher on the RKE2 cluster
-
Install Helm
-
Add Helm chart repository (used latest here, can be latest, stable or alpha)
-
Create a namespace for Rancher
Using Rancher-Generated TLS Cert
-
Install cert-manager (needed if using Rancher-generated TLS cert or Let’s Encrypt)
-
Verify that cert-manager is deployed correctly
-
Install Rancher with Helm
helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=10.40.140.8.nip.io \ --set bootstrapPassword=admin \ --set global.cattle.psp.enabled=false
-
hostname should be the DNS name you pointed at your load balancer for the worker nodes, .nip.io can be added to the ip if there’s no DNS name
-
global.cattle.psp.enabled
is set tofalse
due to the rancher helm chart requiring the deprecatedpodsecuritypolicy
Save the
--set
options used here, you will need to use the same options when you upgrade Rancher to new versions with Helm. -
-
Wait for Rancher to be rolled out
-
In a web browser navigate to the DNS name that points to your load balancer (ex:
10.40.140.8:nip.io
), you should see the login page
Using your own Certs
Formatting Certs
It can cause complications while editing files on a machine running some form of Windows and uploading them to a Linux server. Windows-based text editors put special characters at the end of lines to denote a line return or newline. There is a simple way to correct this problem.
-
Install
dos2unix
and execute the command to convert line endings from DOS to Unix -
Windows servers use .pfx files which contain the public and private key. However, this can also be converted to .pem files to be used on Linux server
Validating Certs
Before you set up your certificates, it's a good idea to test them to ensure that they are correct and will work together.
-
Check to see if the private key and main certificate are in PEM format.
openssl
must be installed -
Verify that the private key and main certificate match
-
Verify that the public keys contained in the private key file and the main certificate are the same
-
Check the validty of certificate chain
-
Check if
Subject Alternative Names
containsCommon Name
Subject Alternative Name must contains the same value of the CN. If it does not, the certificate is not valid because the industry moves away from CN
openssl x509 -noout -subject -in tls.crt
# subject= /CN=<example.domain.com>
openssl x509 -noout -in tls.crt -text | grep DNS
# DNS:<example.domain.com>
Create Secrets and Install
-
Create tls-ca secret with your private CA's root certificate
-
Create cert and key secrets
-
Install Rancher with Helm
helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=10.40.140.8.nip.io \ --set bootstrapPassword=admin \ --set global.cattle.psp.enabled=false \ --set ingress.tls.source=secret \ --set privateCA=true
-
hostname should be the DNS name you pointed at your load balancer for the worker nodes, .nip.io can be added to the ip if there’s no DNS name
-
global.cattle.psp.enabled
is set tofalse
due to the rancher helm chart requiring the deprecatedpodsecuritypolicy
Save the
--set
options used here, you will need to use the same options when you upgrade Rancher to new versions with Helm. -
Cleanup
-
ssh into the Jump machine
-
Make sure we're using the correct kubeconfig
-
Remove Rancher using helm
-
Remove Helm repositories
Change
rancher-latest
with the version you used while installing (ex:stable
,alpha
) -
Remove Helm