Mulesoft RTF in GKE
Introduction
This article is an extension of my previous article. In that, I showed how to install RTF in a local k8s installation e.g Minikube. In this article, I am going to do the same in GKE. It's precisely the same way, however, I will cover the Ingress part too. It will be fun. So, let's get started!
Cluster Creation
I will not enter into too many details of the cluster creation. I will touch only on the essential details.
VPC creation
I will launch my k8s cluster in a VPC. So, it's essential to define a VPC. I have defined the below VPC with an appropriate CIDR as shown below.
Also, inside the subnet, I have declared the below secondary ranges for my pods and services.
Below is the overall network architecture:
Cluster creation
I am creating a Standard Cluster for the set-up.
You can fill in all these necessary values in the form as shown below.
An important point is to configure the Networking part under the CLUSTER section in the above picture. Check below:
That's it. Click Create Cluster button and after some minutes your cluster will be ready.
RTF Installation
Please check my article on RTF installation. It's the same irrespective of Cloud k8s or on-prem k8s cluster.
Ingress Installation
This is the most important part. There are some complications when using the Default Ingress of GKE as described in the official MuleSoft Support Center.
So, to make it work properly, I will install the Nginx Ingress controller. Let's check this out.
Anypoint Platform
Just before proceeding, let's check my RTF configuration in the Anypoint Platform. You can see that there are no Inbound Traffic endpoints. It's because:
There is no ingress configured for the RTF.
Nginx Ingress controller installation in GKE
This is very simple. Just connect to your cluster from the Cloud Shell or from your own machine and execute the following:
$ kubectl create ns nginx$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx$ helm repo update
You must have helm installed on the machine from where you will be executing the commands.
After that, execute the below command:
$ helm install nginx-ingress ingress-nginx/ingress-nginx --namespace nginx
After some time check the services in the nginx namespace.
You can see a brand new service with the type LoadBalancer with an External IP created. This is what we need.
Cool! Our ingress controller is installed. Now, we are here.
Configure Ingress for RTF
This is quite simple. We need to make an Ingress template. You can follow the official documentation for it but I will only explain the most important steps.
Repeat with me:
You MUST create the ingress template in the rtf namespace
Important points:
1. The namespace MUST be rtf
2. spec.ingressClassName must have prefix rtf-
3. The host must have a placeholder app-name
4. You can leave the service name & port as it is as the RTF will replace them as per your Mule app.
Now copy the above template to the Cloud Shell and execute the below command:
$ kubectl apply -f ingress.yaml
Now check the Ingress created in the rtf namespace:
$ kubectl get ing -n rtf
Okay. This beauty is created. Now, let's check our RTF in the Anypoint Platform.
Cool, now the Ingress is ready to receive inbound traffic.
Application Deployment
Let's deploy a mock application to the RTF.
Can you see the relationship? The ingress template deployed in the rtf namespace has been used to create a new ingress for the hello application.
The host name of the application is taken from the Mule app's name i.e hello.
We can also check the ingress created for the hello application.
$ kubectl get ing -n 62e5548c-f7a8-4b41-a058-0883e83a1d99
Note: 62e5548c-f7a8–4b41-a058–0883e83a1d99 namespace is created when you deploy the hello application. It's the environment id to which the application was deployed.
How cool!!!. We have a public IP to invoke the service i.e 34.135.218.155.
Testing the application
Now you have to register the domain *.anupamgogoi.com with the IP 34.135.218.155 in some DNS server. We are not going to do it. Instead, we can execute the below:
$ curl http://hello.anupamgogoi.com/api/v1/hello --resolve hello.anupamgogoi.com:80:34.135.218.155
How cool it is!!!
This is how RTF works. No secrets.
Conclusion
In this short article, I have explained how to configure RTF in GKE along with an Ingress. There is no secret. It's very simple.
Thanks for reading.