This tutorial was updated in January 2022 and is based on Runtime Fabric v1.10 release.
In this tutorial, we’ll walk you through deploying a hello world Mule app to a Google Kubernetes Engine (GKE) cluster using Runtime Fabric. You’ll learn how to:
kubectlto create an ingress controller
To get started as simply and quickly as possible, this tutorial includes steps to create a GKE cluster, nodes and a Runtime Fabric instance with default settings. Before creating a cluster, nodes and a Runtime Fabric instance for production use, we recommend that you familiarize yourself with all settings and deploy settings that meet your requirements. For more information, see the Google Kubernetes How-to Guides. For detailed Runtime Fabric documentation see Anypoint Runtime Fabric Overview.
Anypoint Platform- We’ll need an Anypoint Platform account to create our Runtime Fabric service. You can sign up for a free trial account here.
gcloud- A command line tool for working with Google Cloud resources, including GKE clusters. See installing Cloud SDK.
kubectl- A command line tool for working with Kubernetes clusters. This tutorial requires that you use version 1.21 or later. For more information, see installing kubectl.
rtfctl- A command line tool to locally manage Runtime Fabrics. This tutorial requires that you use version 0.3.135 or later. See installing rtfctl.
curl- A command line tool for transferring data using various network protocols. See installing curl.
In order to successfully deploy Mule applications to Runtime Fabric you also need:
1 - Initialise gcloud
1 gcloud init
When prompted - login to your Google Cloud instance and choose (or create) a project that has billing enabled. For reference we created a google project with the name
2 - Enable google services
1 gcloud services enable container.googleapis.com
1 Operation "operations/<unique-id>" finished successfully.
3 - Create a regional cluster with a multi-zone node pool. Replace example values with your own.
The following instructions show you how to create a regional cluster with a multi-zone node pool, which is the default set up. The cluster’s control plane and nodes are replicated across multiple zones in the specified region. By default the cluster will use the default VPC for the region you specified. This operation will take several minutes to complete.
1 2 3 4 5 6 gcloud container clusters create my-mule-gke \ --region australia-southeast1 \ --cluster-version 1.20 \ --num-nodes 1 \ --enable-ip-alias \ --image-type "COS_CONTAINERD"
You’ll see several lines of output as the cluster and nodes are created. Cluster and node creation takes several minutes. The last lines of output are similar to the following example line.
1 2 3 4 5 Creating cluster my-mule-gke in australia-southeast1...done. ... kubeconfig entry generated for my-mule-gke. NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS my-mule-gke australia-southeast1 1.20.10-gke.301 22.214.171.124 e2-medium 1.20.10-gke.301 3 RUNNING
4 - Check kubectl context by running the following command.
1 kubectl config current-context
When you create a cluster using gcloud container clusters create, an entry is automatically added to the kubeconfig in your environment, and the current context changes to that cluster. By checking the current context we should get an output that lists our project, region and cluster name.
1 - To view your newly configured cluster nodes you can use the following command.
1 kubectl get namespaces
1 2 3 4 5 NAME STATUS AGE default Active 8m17s kube-node-lease Active 8m21s kube-public Active 8m21s kube-system Active 8m21s
1 - Navigate to Anypoint Platform and login.
2 - From the home page navigate to Runtime manager.
3 - Clicking Runtime Fabrics then Create Runtime Fabric.
4 - Create a deployment target for Mule apps you want to deploy. In this case we’re using the name rtf-demo. Select Google Kubernetes Engine and click Next.
5 - Review the Support responsibility disclaimer, then if you agree click Accept
6 - This page displays the activation data used to install Runtime Fabric on a Kubernetes service. Copy the activation code to your clipboard for use later on in this tutorial.
1 - Validate MuleSoft setup by running the following command. You will need to replace
1 ./rtfctl validate <activation-code>
The validate option verifies that:
1 2 3 4 5 6 7 Clearing validate operation resources. Waiting for rtf-validate namespace to be removed... Checking Authorization .. ... All validations successful. Proceed with installation ✔ Clearing validate operation resources. Waiting for rtf-validate namespace to be removed...
2 - Continue to install Runtime Fabric. You will need to replace
1 ./rtfctl install <activation-code>
The first lines and last lines of output are similar to the following example line.
1 2 3 4 5 6 7 Installing Runtime Fabric components Upserting Namespace/rtf... Upserting PodSecurityPolicy/rtf-install... … 61s: Waiting for Runtime Fabric to become ready: [mule-clusterip-service] 66s: Waiting for Runtime Fabric to become ready: [mule-clusterip-service] Runtime Fabric is ready.
3 - Verify the status of the Runtime Fabric installation.
1 ./rtfctl status
The first lines and last lines of output are similar to the following example lines.
1 2 3 4 5 6 7 8 9 10 11 12 Upserting Job/rtfctl-cluster-status... Kubernetes Version: 1.20.10-gke.1600 … Runtime Fabric Information: COMPONENTS HEALTHY REASON agent true mule-clusterip-service true resource-cache true … CERTIFICATE HEALTHY REASON client-cert true client certificate expires at 2022-03-12 02:08:28 +0000 UTC
1 - In Anypoint Platform verify that all systems are operational by checking the status and health of your Runtime Fabric. The status attribute should show as active and all systems should be operational.
2 - Associate environments to be used with the Runtime Fabric by navigating to the Associated Environments tab - clicking Sandbox and then Apply Allocations.
3 - Update Runtime Fabric with a valid MuleSoft licence key. Replace the path and licence name where necessary.
1 ./rtfctl apply mule-license <licence-key-information>
1 Updating rtf namespace... OK
For the purposes of this tutorial we will be using an NGINX controller. Other options are available.
1 - Create a NGINX ingress controller. For full complete installation instructions review the NGINX Installation Guide.
1 kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml
1 2 3 4 5 namespace/ingress-nginx created serviceaccount/ingress-nginx created … job.batch/ingress-nginx-admission-create created job.batch/ingress-nginx-admission-patch created
Anypoint Runtime Fabric on Self-Managed Kubernetes enables you to specify custom Ingress configurations using an ingress resource template. In a template, similar to a Kubernetes ingress spec, you can specify annotations, ingress class name, and HTTP and HTTPS rules. If you do not apply an ingress resource template for an application, you can’t add ingress endpoints when you deploy it. For complete details please refer to the documentation.
We want to use path-based routing where the application name is part of the path. On NGINX, we add the configuration-snippet annotation to remove this part of the path before forwarding it on to the Mule application.
1 - Create a custom Ingress configuration by creating a file from the markdown below and name it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: nginx.ingress.kubernetes.io/configuration-snippet: | rewrite ^/app-name(/|$)(.*) /$2 break; name: rtf-ingress-template namespace: rtf spec: ingressClassName: rtf-nginx rules: - host: rtf.example.com http: paths: - path: /app-name pathType: ImplementationSpecific backend: service: name: service port: number: 80
2 - Apply the configuration to the rtf namespace using the following command. Update the path and name where appropriate.
1 kubectl apply -f path\ingress-template.yaml
1 ingress.networking.k8s.io/rtf-ingress-template created
3 - Navigate back to Anypoint Runtime Manager and verify that your ingress template has been applied by checking the Inbound Traffic tab in Runtime Fabrics.
1 - Deploy the sample Hello World application. In Anypoint Platform click Applications then Deploy Application.
2 - Enter a unique name hello-world-2921 as the Application Name, select the rtf-demo as our Deployment Target then click Import File from Exchange to select the Application File.
3 - Select Type - Example then enter hello-world into the Search assets by name input box. Then select Hello World from the available matches and click Select.
4 - Clicking Deploy Application will deploy the hello-world Mule application to your Runtime Fabric environment.
5 - Once the status of the deployed application changes to Running you can navigate to the application detail page to see the application url.
6 - Get external IP address of the nginx server.
1 kubectl get services -n ingress-nginx
Note that you may have to run the command more than once since the external IP may not be available immediately.
The IP address of your NGINX server will appear in the EXTERNAL-IP column in the output.
1 2 3 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx-controller LoadBalancer 10.120.0.105 126.96.36.199 80:30976/TCP,443:32166/TCP 49s ingress-nginx-controller-admission ClusterIP 10.120.0.151 <none> 443/TCP 49s
7 - Call the hello-world endpoint. Using the output above to replace the ingress controller IP address. Replace
To access the endpoint for the hello-world we need to resolve the domain name rtf.example.com. For this tutorial we will not create a domain address or use a local file - instead we’ll use the resolve switch to pass the hostname IP mapping on the command line pointing to the external IP address of the nginx ingress controller above.
1 curl http://rtf.example.com/hello-world-2921/helloWorld --resolve rtf.example.com:80:188.8.131.52
1 Hello World!
The deployed application should return the string ‘Hello World!’ proving that the application received and processed your request.
In this tutorial, we walked you through deploying a hello world Mule app to a Google Kubernetes Engine (GKE) cluster using Runtime Fabric. You learned how to:
kubectlto create an ingress controller
Click on the Next button below to continue to the next tutorial in this series that configures TLS and last-mile security.
Runtime Fabric also runs as a service on Azure Kubernetes Service (AKS), Red Hat OpenShift and Amazon Elastic Kubernetes Service (Amazon EKS). Check out their tutorials below.