Gravitee.io APIM 3.x on GKE

David Brassely
graviteeio
Published in
4 min readJul 29, 2020

Nowadays, there are more and more deployments on Kubernetes to operate cloud-native applications regardless of the environment and underlying infrastructure.

Obviously, Gravitee.io can also be deployed on a Kubernetes cluster to very quickly provision a new environment and allow you to expose your APIs and services publicly, in a secure way.

This post will be the first in a series of about Kubernetes deployment. This first post will explain how to deploy Gravitee.io API Management 3.x to the Google Kubernetes Engine.

Setup your cluster

Note: you can do the same actions using the gcloud CLI. We are doing it from the gcloud console for the sake of simplicity.

Go to https://console.cloud.google.com/and click on the Kubernetes Engine menu item from the left menu.

Then, click on Create cluster, and use default options (I’ve only changed the zone to europe-west1-b and named the cluster demo-apim).

Create a cluster

Once done, you have to wait for the cluster to be ready (in can take few minutes).

Cool, we are ready to go!

Deploy Gravitee.io API Management

Now that our GKE cluster is ready, we can focus on deploying Gravitee.io APIM. For the purpose of this blog post, we are not deploying MongoDB nor Elasticsearch. If you need to run them (you don’t have existing installation), you can have a look to MongoDB Atlas and Elastic Cloud.

First, we have to get credentials for kubectl CLI:

$ gcloud container clusters get-credentials $PROJECT_ID — zone=$ZONE_ID

As we will deploy using the Gravitee.io Helm Charts, we have to prepare the cluster for Helm:

$ helm init
$ kubectl create serviceaccount --namespace kube-system tiller
$ kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
$ kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
$ helm init --service-account tiller --upgrade

Then, we create a dedicated namespace for Gravitee.io

$ kubectl create namespace graviteeio

The last step is about deploying an Ingress Controller to expose the Gravitee.io services. The default chart is based on Nginx, so we have to install the Nginx Ingress Controller:

$ helm install --name nginx-ingress --namespace graviteeio stable/nginx-ingress --set rbac.create=true --set controller.publishService.enabled=true

Finally, declare the Gravitee.io Helm Charts repository:

$ helm repo add graviteeio https://helm.gravitee.io

Everything is ready to deploy Gravitee.io APIM now, so let’s do it:

$ helm install --name graviteeio-apim3 --namespace graviteeio \
--set mongo.uri="mongodb+srv://xxxxxxx@clusterx-xxxxx.mongodb.net/test?retryWrites=true&w=majority" \
--set api.replicaCount=1 \
--set gateway.replicaCount=1 \
--set ui.replicaCount=1 \
--set es.endpoints={https://xxx-es.services.xxxxxx.com/} \
--set es.security.enabled=true \
--set es.security.username=username \
--set es.security.password=password \
graviteeio/apim3

Check that everything is working well from the GCloud console:

Running pods
Running services and ingresses

You can see that the nginx-ingress-controller is bound to an external load balancer listening on 35.190.199.121.

Let’s edit the /etc/hosts file to declare this IP with the apim.example.com host.

$ sudo vi /etc/hosts// Add this line to the file
35.190.199.121 apim.example.com

Here we are !

Enjoy Gravitee.io API Management

Now that everything is done, we can play with Gravitee.io API Management from the apim.example.com host:

Go to https://apim.example.com to access the API Portal

Portal homepage

Go to https://apim.example.com/console/ to access the Publisher Console

Login form to access the console

And finally, the gateway can be accessed from https://apim.example.com/gateway:

$ curl -k -X GET https://apim.example.com/gateway
No context-path matches the request URI.

So, we have successfully installed Gravitee.io API Management within a Google Kubernetes cluster (GKE). There are a lot more of options to customize the deployment. You can have a look at the documentation to see them.

Next post will be dedicated to deploy Gravitee.io API Management 3.x within Azure Kubernetes Service. Stay tuned !

--

--