Java and Web Stacks on Axion¶
Requirements¶
To deploy this demo, you need:
- A Google Cloud project.
- An account that has the
owner
role on that Google Cloud project. - To know the external IP that the client you will access the demo from appears as, you can check a site like Whatis MyIPAddress to find it out.
Prepare the environment¶
-
Open Cloud Shell.
-
Configure environment variables:
CLIENT_IP="<CLIENT_IP>" PROJECT_ID="<PROJECT_ID>" REGION="<LOCATION>" CONTAINER_IMAGE_REPOSITORY_NAME="arm-web-demo" VPC_NAME="arm-web-demo" CLOUD_ROUTER_NAME="arm-web-demos-router" NAT_GATEWAY_NAME="arm-web-demos-nat" GKE_CLUSTER_NAME="auto-multi-arch-cluster" CATALOG_CONTAINER_IMAGE_URL="${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${CONTAINER_IMAGE_REPOSITORY_NAME}/book-catalog-service:latest" UI_CONTAINER_IMAGE_URL="${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${CONTAINER_IMAGE_REPOSITORY_NAME}/book-ui-service:latest" REVIEW_CONTAINER_IMAGE_URL="${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${CONTAINER_IMAGE_REPOSITORY_NAME}/review-service:latest" K6_CONTAINER_IMAGE_URL="${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${CONTAINER_IMAGE_REPOSITORY_NAME}/custom-k6:latest" export CATALOG_CONTAINER_IMAGE_URL export UI_CONTAINER_IMAGE_URL export REVIEW_CONTAINER_IMAGE_URL export K6_CONTAINER_IMAGE_URL
Where:
<CLIENT_IP>
is the external IP of your demo client machine.<PROJECT_ID>
is the ID of your Google Cloud project.<REGION>
is the location where to provision cloud resources. Example:us-central1
-
Clone this repository:
-
Change the working directory to the directory where you cloned this repository:
-
Select the Google Cloud project where to provision resources:
Provision and configure cloud infrastructure¶
-
Enable Google Cloud APIs:
-
Create a Artifact Registry repository for container images:
-
Create a VPC network with Auto subnets:
-
Create a Cloud Router for NAT Gateway:
-
Create a NAT Gateway:
-
Create a private Google Kubernetes Engine (GKE) autopilot cluster:
gcloud container clusters create-auto "${GKE_CLUSTER_NAME}" \ --region="${REGION}" \ --release-channel=regular \ --network="${VPC_NAME}" \ --subnetwork=arm-demos \ --enable-dns-access \ --enable-private-endpoint \ --enable-private-nodes \ --enable-master-authorized-networks \ --master-ipv4-cidr=172.16.2.0/28
-
Configure the cluster connection:
Build the multi-arch container images¶
-
Build the catalog service container image for both the
arm64
andamd64
architecture, and push it to the registry:gcloud builds submit \ --config=projects/arm-reference-guides/web-demo/book-catalog-service/cloudbuild.yaml projects/arm-reference-guides/web-demo/book-catalog-service \ --project "${PROJECT_ID}" \ --region "${LOCATION}" \ --substitutions=_LOCATION="${LOCATION}",_REPOSITORY="${CONTAINER_IMAGE_REPOSITORY_NAME}" \ --machine-type=e2-highcpu-8
-
Build the review service container image for both the
arm64
andamd64
architecture, and push it to the registry:gcloud builds submit \ --config=projects/arm-reference-guides/web-demo/review-service/cloudbuild.yaml projects/arm-reference-guides/web-demo/review-service \ --project "${PROJECT_ID}" \ --region "${LOCATION}" \ --substitutions=_LOCATION="${LOCATION}",_REPOSITORY="${CONTAINER_IMAGE_REPOSITORY_NAME}" \ --machine-type=e2-highcpu-8
-
Build the ui service container image for both the
arm64
andamd64
architecture, and push it to the registry:gcloud builds submit \ --config=projects/arm-reference-guides/web-demo/book-ui-service/cloudbuild.yaml projects/arm-reference-guides/web-demo/book-ui-service \ --project "${PROJECT_ID}" \ --region "${LOCATION}" \ --substitutions=_LOCATION="${LOCATION}",_REPOSITORY="${CONTAINER_IMAGE_REPOSITORY_NAME}" \ --machine-type=e2-highcpu-8
-
Build the custom k6 container image for both the
arm64
andamd64
architecture, and push it to the registry:gcloud builds submit \ --config=projects/arm-reference-guides/web-demo/load-testing/cloudbuild.yaml projects/arm-reference-guides/web-demo/load-testing \ --project "${PROJECT_ID}" \ --region "${LOCATION}" \ --substitutions=_LOCATION="${LOCATION}",_REPOSITORY="${CONTAINER_IMAGE_REPOSITORY_NAME}" \ --machine-type=e2-highcpu-8
This k6 image can take a while to build, around 15 minutes
Deploy services¶
-
Prepare the cluster :
-
Configure Helm:
-
Install an Arm based K6:
-
Install an Arm based postgresql :
-
Install an Arm based redis :
-
Install an x64 based postgresql :
-
Install an x64 based redis :
-
Deploy the Arm based workloads :
envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-service-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-service-deployment.yaml envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-ui-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-ui-deployment.yaml envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/arm-review-service-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/arm-review-service-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-service-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-ui-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/arm-review-service-deployment.yaml
-
Deploy the x64 based workloads :
envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-service-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-service-deployment.yaml envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-ui-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-ui-deployment.yaml envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/x64-review-service-deployment.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/ax64rm-review-service-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-service-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-ui-deployment.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/x64-review-service-deployment.yaml
-
Deploy the Arm services :
envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-ui-service.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/arm-book-ui-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/arm-book-service-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/arm-review-service-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/arm-book-ui-service.yaml
-
Deploy the x64 services :
envsubst <projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-ui-service.yaml | sponge projects/arm-reference-guides/web-demo/k8s-manifests/x64-book-ui-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/x64-book-service-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/x64-review-service-service.yaml kubectl apply -f projects/arm-reference-guides/web-demo/k8s-manifests/autopilot/x64-book-ui-service.yaml
Exploring the environment¶
-
Get information about the deployments :
The output is similar to the following:
-
Get information about the stateful worklads :
The output is similar to the following:
NAME READY AGE arm-postgres-svc 1/1 3h32m arm-redis-svc-master 1/1 131m arm-redis-svc-replicas 0/0 131m x64-postgres-svc 1/1 3h32m x64-redis-svc-master 1/1 131m x64-redis-svc-replicas 0/0 131m
The replicas in the above output should be 0/0
-
Take note of the Arm stacks external Loadbalancer IP address :
-
Take note of the x64 stacks external Loadbalancer IP address :
Connect to the demo¶
Visit those two URL's from the above steps, you should be greeted with a page that displays the CPU architecture of each of the components in the stack. aarch64 for Arm, and x64 for x64.
Loading synthetic data¶
-
Run the books.py script to generate synthetic data :
Download those files to your local machine via the download option behind the three dot menu in CloudShell. In your browser navigate to the bulk upload section of each stack and upload the three files. Once complete, you can navigate through the application and see it in action.
Destroying the demo¶
To destroy the demo environment, you do the following:
-
Destroy the GKE cluster
-
Destroy the VPC network
-
Destroy the Artifact Registry repository
-
Destroy the Cloud Router
-
Destroy the NAT Gateway