Getting started with Runtime Fabric on Google Kubernetes Engine (GKE)

runtime fabric
mulesoft logo
MuleSoft
Developer Relations
35 min read
Overview

This cookbook will walk you through the process of installing Anypoint Runtime Fabric (RTF) on Google Kubernetes Engine (GKE). You will create a Google Kubernetes Cluster (GKE) and install RTF. Once completed you will deploy a sample MuleSoft application to verify everything is working.

Please note that this tutorial only applies to Runtime Fabric version 1.9.

If this is your first time using MuleSoft, click the signup button below to get started.

Step 1: Create a Google VPC

From any browser, go to the URL to access Google Cloud Console:

Click on the upper left navigation bar. Select VPC networks

VPC

Click CREATE VPC NETWORK

Enter the following information:

  • Name: rtf-vpc
  • Subnet Name: rtf-subnet
  • Subnet Region: us-west1
  • Subnet IP address range: 10.0.0.0/16
image 20

Leave all defaults and click Create. Wait for the network to be created.

defaults

If you prefer using the command line you can execute the following commands:

gcloud compute networks create rtf-vpc --project=infra-ratio-309301 --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional

gcloud compute networks subnets create rtf-subnet --project=infra-ratio-309301 --range=10.0.0.0/16 --network=rtf-vpc --region=us-west1

 

Step 2: Create Kubernetes Cluster

Click on the upper left navigation bar. Select Kubernetes Engine -> Clusters

Kubernetes

Click Create and then click CONFIGURE for Standard cluster. As of today RTF is not supported on Autopilot.

Enter the following:

  • Name: rtf-cluster
  • Location type: regional
  • Region: us-west1
regional

Under NODE POOLS click default-pool. Set the Size to 1 node per zone. Since us-west1 has 3 zones this will create 3 nodes.

default pool

Next, click Networking and select the rtf-vpc network.

rtf

Click CREATE and wait for the cluster to be created.

rtf

Google command line:

gcloud beta container --project "infra-ratio-309301" clusters create "rtf-cluster" --region "us-west1" --no-enable-basic-auth --cluster-version "1.18.16-gke.302" --release-channel "regular" --machine-type "e2-medium" --image-type "COS" --disk-type "pd-standard" --disk-size "100" --metadata disable-legacy-endpoints=true --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --num-nodes "1" --enable-stackdriver-kubernetes --enable-ip-alias --network "projects/infra-ratio-309301/global/networks/rtf-vpc" --subnetwork "projects/infra-ratio-309301/regions/us-west1/subnetworks/rtf-subnet" --default-max-pods-per-node "110" --no-enable-master-authorized-networks --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver --enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0 --enable-shielded-nodes

 

Step 3: Verify Cluster and Connect

Click rtf-cluster link to view details of the newly provisioned GKE cluster. From this page click CONNECT.

connect

From the pop-up screen click RUN IN CLOUD SHELL. For this cookbook we will be using Google Cloud Shell to keep the configuration simple. If you want to run from your laptop you will need the gcloud command-line tool. Press return once Cloud Shell has been started.

clusterterminal

On the right side of the Cloud Shell click Open in new window. This will allow us to have the Cloud Shell in it's own tab from the Google Cloud Console.

open editor

Next run the following command to verify that you cluster is running.

kubectl get namespaces

 

cloudshell
Step 4: Download rtfctl

rtfctl is supported on Windows, MacOS (Darwin), and Linux. Download this utility using the URL below for the Linux distribution:

curl -L https://anypoint.mulesoft.com/runtimefabric/api/download/rtfctl/latest -o rtfctl

 

Next, change the file permissions for the rtfctl command

chmod +x rtfctl

 

cloudshell

From the main page click Runtime Manager or use the left navigation bar to navigate to Runtime Manager.

runtime manager

On left hand menu, click Runtime Fabrics then click Create Runtime Fabric. Enter name rtf-on-gke and select Google Kubernetes Engine. Then, click Next.

gke

Click Accept on Support responsibility pop-up. We are now ready to install RTF. Click the Copy icon to copy the activation code to your clipboard.

ccopy
Step 6: Install RTF

Switch back to the Google Cloud Shell. Using the activation code that you copied run the following command:

./rtfctl validate {activation_data}

 

The validate option verifies that: The Kubernetes environment is running. All required components exist. All required services are available. The rtfctl command outputs any incompatibilities with the Kubernetes environment.

validation

If the validation is successful we are now ready to install RTF. Using the activation code run the following command to install RTF:

./rtfctl install {activation_data}

 

activation

If everything went well, you will see Runtime Fabric is ready, and the installation exits without errors. At this point, validate the installation with these steps. Verify that rtf namespace has been created and all pods are running. Run the following command:

kubectl get pods -n rtf

 

kub
Step 7: Configure RTF

Switch back to Anypoint Platform. First, make sure the status is Green and everything is healthy.

healthy

Next, click Associated Environments and select your environment. In our example we are selecting Sandbox. Click Apply Allocations.

allow allocations

Switch back to Cloud Shell. Now we need to update RTF with a valid MuleSoft license key. From the Cloud Shell three-dotted more menu, select Upload file and upload your MuleSoft provided license file. In our example it is named license.lic.

upload file

We will need to convert the MuleSoft provided license file to Base64 encoded. Use the following command:

base64 -w0 license.lic

 

Update RTF with the MuleSoft license key using the following command:

./rtfctl apply mule-license {BASE64_ENCODED_LICENSE}

 

To verify the MuleSoft license key has been applied correctly, run:

./rtfctl get mule-license

 

Step 8: Create Ingress Controller (Using Nginx)

One of the most popular Ingress controllers being used is Nginx. However, customers might be using a different solutions. High level architecture diagram looks like this:

ingres architecture

Run the following command will create all necessary resources for the ingress controller:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.40.2/deploy/static/provider/cloud/deploy.yaml

 

cloud shell

Now run the below command to get the URL/IP address of your load balancer

kubectl get services -n ingress-nginx

 

external ip

Once you have an external IP, switch over to Google Console you view the created GCP Load balancer. In the Search bar enter Load balancing:

target pool

If you click on the auto-generated name you can view the details including the external IP:

load balancer
Step 9: Enable Inbound Traffic

Switch over to Anypoint Platform. Click Inbound Traffic. Update Runtime Fabric with a domain that you own or want your application/apis to use. Remember to include protocol while adding the domain(s). By default, application will accept all domains if no domain is defined. For our example we will be using rtf-on-gke.mulesoftdemo.com. Click +Add endpoints. Enter http://*.rtf-on-gke.mulesoftdemo.com and click Add Endpoints. Once you have you endpoints added click Save and Deploy.

rtf on gke
Step 10: Deploy Test Application

A hello world app is provided as an example for you the get started quickly. In Anypoint Platform click Applications on the Runtime Manger left-hand menu.

applications

Click Deploy application, then for thr Application Name enter hello-world. Select rtf-on-gke from Deployment Target.

hello world

Click Example. In the search bar enter Hello World. Select the Hello World example and click select.

select from hello world

Keep all default settings and click Deploy Application. Once the status changes to Running click the application name hello-world. You should see the Application URL for your application that is running RTF.

rtf running
Step 11: Access Your Application

To access your application endpoint we need to either set up a domain address or use a localhost file. To keep things simple we will use the resolve flag so that we can pass the hostname IP mapping on the command line. Return to you Google Cloud Shell. If you need to get your external IP to execute the following command:

kubectl get services -n ingress-nginx

 

Copy the EXTERNAL-IP for the ingress-nginx-controller service. Issue the following command to hit you application

curl -vv http://hello-world.rtf-on-gke.mulesoftdemo.com/helloWorld --resolve hello-world.rtf-on-gke.mulesoftdemo.com:80:{IP address of ingress controller}

 

kub cloud shell

If you see Hello World! returned congratulations! you have successfully installed RTF on GKE.

Try Anypoint Platform for free

Start free trial

Already have an account? Sign in.

Related tutorials