Deploying Redis Enterprise for GKE and Serverless App on Anthos Bare Metal
1 hour 30 minutes5 Credits
This lab was developed with our partner, Redis. Your personal information may be shared with Redis, the lab sponsor, if you have opted-in to receive product updates, announcements, and offers in your Account Profile.
GSP938
Overview
In this lab you will learn how to create Compute Engine VMs on Google Cloud with L2 connectivity through the use of vxlan built-in functionality in Linux. You'll be using the Compute Engine VMs to simulate Anthos on Bare Metal (BM) in high-availability mode which requires L2 connectivity. The deployment will consist of 4 VMs to deploy Anthos on BM, 1 x workstation, 1 x control plane nodes and 2 x worker nodes. Then you'll install Anthos Service Mesh and Knative on the BM cluster, followed by deploying Redis Enterprise for GKE and a Serverless application. Finally, this guide will show you how to run a simple load test on the serverless application to realize the elasticity of Knative backed by a Redis datastore.
Objectives
In this lab, you will:
Create an Anthos bare metal cluster
Install Anthos service mesh and Knative
Deploy Redis Enterprise cluster
Create a Redis Enterprise database
Create a Knative serverless service (incrementing a Redis counter)
Run a load test against the Knative serverless application
Setup and Requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
What you need
To complete this lab, you need:
Access to a standard internet browser (Chrome browser recommended).
Time to complete the lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab.
Note: If you are using a Chrome OS device, open an Incognito window to run this lab.
How to start your lab and sign in to the Google Cloud Console
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method.
On the left is a panel populated with the temporary credentials that you must use for this lab.
Copy the username, and then click Open Google Console.
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Open the tabs in separate windows, side-by-side.
In the Sign in page, paste the username that you copied from the left panel. Then copy and paste the password.
Important: You must use the credentials from the left panel. Do not use your Google Cloud Training credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).
Click through the subsequent pages:
Accept the terms and conditions.
Do not add recovery options or two-factor authentication (because this is a temporary account).
Do not sign up for free trials.
After a few moments, the Cloud Console opens in this tab.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
In the Cloud Console, in the top right toolbar, click the Activate Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
You can list the active account name with this command:
gcloud auth list
(Output)
ACTIVE: *
ACCOUNT: student-01-xxxxxxxxxxxx@qwiklabs.net
To set the active account, run:
$ gcloud config set account `ACCOUNT`
You can list the project ID with this command:
gcloud config list project
(Output)
[core]
project = <project_ID>
(Example output)
[core]
project = qwiklabs-gcp-44776a13dea667a6
Task 1. Create an Anthos bare metal cluster
In the Cloud Console, open a new Cloud Shell window.
Inside Cloud Shell, set the following environment variables for the scripts in this lab:
You should see 4 VMs have been provisioned in your Google Cloud console like the following:
Click Check my progress to verify the objective.
Create instances
Wait for SSH to be ready on all VMs:
for vm in "${VMs[@]}"
do
while ! gcloud compute ssh root@$vm --zone us-central1-a --command "echo SSH to $vm succeeded"
do
echo "Trying to SSH into $vm failed. Sleeping for 5 seconds. zzzZZzzZZ"
sleep 5
done
done
At the prompt asking if you want to continue (Y/n), type Y.
Press Enter key a few times to set an empty passphrase.
Create a vxlan with L2 connectivity between all VMs:
i=2
for vm in "${VMs[@]}"
do
gcloud compute ssh root@$vm --zone ${ZONE} << EOF
apt-get -qq update > /dev/null
apt-get -qq install -y jq > /dev/null
set -x
ip link add vxlan0 type vxlan id 42 dev ens4 dstport 0
current_ip=\$(ip --json a show dev ens4 | jq '.[0].addr_info[0].local' -r)
echo "VM IP address is: \$current_ip"
for ip in ${IPs[@]}; do
if [ "\$ip" != "\$current_ip" ]; then
bridge fdb append to 00:00:00:00:00:00 dst \$ip dev vxlan0
fi
done
ip addr add 10.200.0.$i/24 dev vxlan0
ip link set up dev vxlan0
systemctl stop apparmor.service
systemctl disable apparmor.service
EOF
i=$((i+1))
done
After you are done you now have L2 connectivity when using the 10.200.0.0/24 network. The VMs will now have the following IP addresses:
Admin Workstation: 10.200.0.2
3 x control plane: 10.200.0.3,4,5
3 x worker nodes: 10.200.0.6,7,8
Click Check my progress to verify the objective.
Add L2 connectivity
11. Prepare the workstation machine for needed software components for this lab:
Click Check my progress to verify the objective.
Install software components
12. Create SSH key for the Admin workstation machine and add corresponding public key to the rest of the VMs:
gcloud compute ssh root@$VM_WS --zone ${ZONE} << EOF
set -x
ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa
sed 's/ssh-rsa/root:ssh-rsa/' ~/.ssh/id_rsa.pub > ssh-metadata
for vm in ${VMs[@]}
do
gcloud compute instances add-metadata \$vm --zone ${ZONE} --metadata-from-file ssh-keys=ssh-metadata
done
EOF
Click Check my progress to verify the objective.
Create and add ssh keys
Navigate to the left side menu bar inside the Google Cloud Console, find Operations section, and select Monitoring > Overview, this will create a monitoring workspace which is required by the script below:
The installation might take up to 17 minutes to complete. When complete, you would see a similar output as follows:
Next you will configure RBAC policies on the Anthos bare metal cluster. Replace the <GCP login account username> with your Google Cloud login account username for your lab and run:
export user_account=<GCP login account username from your Qwiklabs session>
Run the following script to configure RBAC for your Google Cloud login account:
Go to Google Cloud Console and view the Anthos bare metal server under Compute > Kubernetes Engine > Clusters section. You should see the cluster has been authenticated and logged on using your Google Cloud login as shown in the screenshot below:
If not, follow the on-screen instructions below to log into the Anthos bare metal server:
Click on the three dots on the right side of your cluster.
Click Log in.
In the window, select Use your Google identity to log-in and click Login.
Your cluster should now be authenticated and resemble the following:
Install Anthos Service Mesh and Knative
In this section you will deploy Anthos Service Mesh on the bare metal cluster. You will:
Install Anthos Service Mesh kit
Configure certs
Create cacerts secret
Set network annotation for istio-system namespace
Configure Anthos Service Mesh Configuration File
Configure Validation Web Hook
First, run the following script to install the Anthos Service Mesh:
Now you will deploy the Redis Enterprise Operator and Redis Enterprise cluster using command line.
Run the following script to deploy a Redis Enterprise cluster. First, it will deploy Redis Enterprise Operator for Kubernetes and then followed by Redis Enterprise cluster.
The deployment will take about 3 minutes to complete. Once it is complete, you should see this line: statefulset.apps/redis-enterprise 1/1 5m after running the following script.
Remain inside the Admin workstation machine and run the following to verify the Knative service is up and running and view the status of the "redisconf" Knative service:
kubectl get ksvc redisconf
Access the Knative service via a curl command:
curl http://redisconf.default.10.200.0.51.nip.io
You should see a similar output like the following from the curl command:
Task 6. Run a load test against the Knative serverless application
In the existing Cloud Shell terminal, run the following command to view the status of redisconf Knative service:
watch kubectl get deployment
You will notice the number of pods for redisconf deployment will increase when executing the load-test in new terminal window.
Open another terminal (Cloud Shell) by clicking (+) right after the current terminal tab and get inside the Admin workstation machine by running the following commands:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated February 21, 2022
Lab Last Tested February 21, 2022
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
In this lab you will learn how to create Compute Engine VMs on Google Cloud to simulate Anthos on Bare Metal (BM) in high-availability mode, install Anthos Service Mesh and Knative on the BM cluster, deploy Redis Enterprise for GKE and a Serverless application, then run a load test.