Deploying and Managing Workloads Using Rancher Manager - Part II
Registries Secrets, Self-Signed Certificates, and Insecure Registries
As a reminder, this is what we did in the previous section:
- We created a private registry on the
workspacemachine. - The registry is protected by a username and password.
- We pushed the
todo-appimage to the private registry usingharbor.$WORKSPACE_PUBLIC_IP.sslip.io/todo-app/todo-app:latest, where$WORKSPACE_PUBLIC_IPis the IP address of theworkspacemachine.
To pull the todo-app image, we need to create a secret in the Kubernetes cluster. This secret will contain the username and password of the private registry. These are the steps to create the secret:
- Navigate to the Rancher UI and select
Cluster Management. - Click on the
Explorebutton next to therke2-clustercluster. - Click on
Storageand thenSecrets. - Click on the
Createbutton to create a new secret. - Choose
Registryas the type of secret. - Select
todo-app-namespaceas the namespace. - Choose a name for the secret, for example,
todo-app-registry. - Choose
Customsince our registry is not one of the predefined ones (DockerHub, Quay, Artifactory, etc.). - Fill the
Registry Domain Namewithharbor.$WORKSPACE_PUBLIC_IP.sslip.ioand make sure to replace$WORKSPACE_PUBLIC_IPwith the actual IP address of theworkspacemachine.
Example:
harbor.157.230.120.237.sslip.io
- Given the fact that the registry is protected by a username and password, we need to provide the credentials. Fill in the
UsernameandPasswordfields with the username and password of the private registry (adminandp@sswordin our case).
Since our registry is self-signed, we need to add the CA certificate to the cluster nodes.
- If you plan to run workloads on all nodes (control plane and worker nodes), you should add the CA certificate to all nodes.
- If you plan to run workloads only on the worker nodes, you can add the CA certificate to these nodes only.
By default, our control plane accepts workloads since we don't have any taints on it (rke2-controlplane-01). Therefore, at this stage, we will add the CA certificate to all nodes.
To do this, we will run the following commands from the RKE2 master node (control plane node):
# SSH into the control plane node
ssh root@$WORKLOAD_CONTROLPLANE_01_PUBLIC_IP
# Define the Harbor host
HARBOR_HOST="harbor.${WORKSPACE_PUBLIC_IP}.sslip.io"
# Define the certificate path
CERT_PATH="/usr/local/share/ca-certificates/$HARBOR_HOST"
Create a function to add the certificate and restart the service on all nodes:
# Function to add certificate and restart service
add_certificate() {
local node=End-to-End Kubernetes with Rancher, RKE2, K3s, Fleet, Longhorn, and NeuVector
The full journey from nothing to productionEnroll now to unlock all content and receive all future updates for free.
