Continental Innovates with Rancher and Kubernetes
In this section, you’ll learn how to install Rancher using Google Kubernetes Engine.
If you already have a GKE Kubernetes cluster, skip to the step about installing an ingress. Then install the Rancher Helm chart following the instructions on this page.
Take the following steps to enable the Kubernetes Engine API:
Cloud Shell is a shell environment for managing resources hosted on Google Cloud. Cloud Shell comes preinstalled with the gcloud command-line tool and kubectl command-line tool. The gcloud tool provides the primary command-line interface for Google Cloud, and kubectl provides the primary command-line interface for running commands against Kubernetes clusters.
The following sections describe how to launch the cloud shell from the Google Cloud Console or from your local workstation.
To launch the shell from the Google Cloud Console, go to the upper-right corner of the console and click the terminal button. When hovering over the button, it is labeled Activate Cloud Shell.
To install gcloud and kubectl, perform the following steps:
After installing Cloud SDK, install the kubectl command-line tool by running the following command:
gcloud components install kubectl
In a later step, kubectl will be configured to use the new GKE cluster.
Install Helm 3 if it is not already installed.
Enable Helm experimental support for OCI images with the HELM_EXPERIMENTAL_OCI variable. Add the following line to ~/.bashrc (or ~/.bash_profile in macOS, or wherever your shell stores environment variables):
Run the following command to load your updated .bashrc file:
If you are running macOS, use this command:
Set up default gcloud settings using one of the following methods:
Run gcloud init and follow the directions:
If you are using SSH on a remote server, use the –console-only flag to prevent the command from launching a browser:
gcloud init --console-only
Follow the instructions to authorize gcloud to use your Google Cloud account and select the new project that you created.
gcloud config list
The output should resemble the following:
region = us-west1 # Your chosen region
zone = us-west1-b # Your chosen zone
account = <Your email>
disable_usage_reporting = True
project = <Your project ID>
Your active configuration is: [default]
The following command creates a three-node cluster.
Replace cluster-name with the name of your new cluster.
gcloud container clusters create cluster-name --num-nodes=3
After creating your cluster, you need to get authentication credentials to interact with the cluster:
gcloud container clusters get-credentials cluster-name
This command configures kubectl to use the cluster you created.
The cluster needs an Ingress so that Rancher can be accessed from outside the cluster.
The following command installs an nginx-ingress-controller with a LoadBalancer service:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm upgrade --install \
ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx \
--set controller.service.type=LoadBalancer \
--version 3.12.0 \
To get the address of the load balancer, run:
kubectl get service ingress-nginx-controller --namespace=ingress-nginx
The result should look similar to the following:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.3.244.156 126.96.36.199 80:31876/TCP,443:32497/TCP 81s
Save the EXTERNAL-IP.
External traffic to the Rancher server will need to be directed at the load balancer you created.
Set up a DNS to point at the external IP that you saved. This DNS will be used as the Rancher server URL.
There are many valid ways to set up the DNS. For help, refer to the Google Cloud documentation about managing DNS records.
Next, install the Rancher Helm chart by following the instructions on this page. The Helm instructions are the same for installing Rancher on any Kubernetes distribution.
Use the DNS name from the previous step as the Rancher server URL when you install Rancher. It can be passed in as a Helm option. For example, if the DNS name is rancher.my.org, you could run the Helm installation command with the option --set hostname=rancher.my.org.