Working in an on-premise production environment containing containerized applications for the APIs requires maintaining and managing all the solutions within it amid strict security and availability requirements. This is the reason why setting up containerized images causes a lot of nuisance. Hence, to enable users to run applications on diverse sets of infrastructures on-premises: the Kubernetes Operator comes to the rescue!
APIMatic Kubernetes Operator, available as a containerized application and solution, makes on-premise deployment a whole lot easier, ensures that APIMatic’s developer experience platform gets simple for the API users, and cuts down the setup process to minutes, allowing users to instantly get up and running with APIMatic on their own infrastructure.
The APIMatic Kubernetes Operator offers the following features:
- Deploying APIMatic CodeGen Web API service within the Kubernetes or OpenShift cluster.
- Exposing the APIMatic CodeGen API external to the cluster.
- Exposing the service through an ingress resource.
- Manual horizontal scaling of pods.
Running the APIMatic Kubernetes Operator
For running the APIMatic Kubernetes operator, you need to go through some steps and requirements. First of all, contact APIMatic at support@apimatic.io to register with the APIMatic CodeGen Docker Hub registry and acquire a valid license to run the APIMatic CodeGen API. Moreover, you need to install:
- Go language version v1.16.*
- Git
- GNU Make Tool
- Operator SDK
- A running Kubernetes cluster with kubectl on the client.
- Minikube or kind, for testing purposes.
- MetalLB, for checking the service created by the APIMatic operator on-premises.
How to Deploy the Kubernetes Operator?
Once the initial requirements are complete, you can proceed to deploy the APIMatic Kubernetes operator via the methods:
- Direct Deployment of Operator
- OLM Deployment of Operator (will be covered in our next blog soon...)
Direct Deployment of Operator
Direct deployment is an instant deployment to those instances that are externally accessible. To run the operator via direct deployment, start off by cloning the APIMatic repository into your working directory using the git clone command.
git clone https://github.com/apimatic/apimatic-kubernetes-operator.git
Next, run the make deploy command to set up the APIMatic operator resources. This will deploy the apimatic-system namespace as well as the CRD and the RBAC manifests. Following this, create a secret, named apimaticimagesecret, with kubectl create secret command which allows pulling the APIMatic CodeGen image using the Docker Hub username registered with APIMatic.
kubectl create secret docker-registry apimaticimagesecret --docker-server=https://index.docker.io/v1/ --
docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
Now, create a configmap resource named apimaticlicense, with the kubectl create configmap command, that will serve as the volume storing the APIMatic license. For example,the following command creates a ConfigMap and deploys it using the License.lic file located at /usr/local/apimatic/license/.
kubectl create configmap apimaticlicense --from-file /usr/local/apimatic/license/License.lic
After running the operator using the following kubectl apply command, you will see a newly created Deployment with a replica count of 3 and Service of type NodePort, both named apimatic-sample. Accessing http://localhost:32000 from your browser (or using curl from within the Minikube or Kind cluster) will show the APIMatic Titan page.
kubectl apply -f config/samples/apicodegen_v1beta1_apimatic.yaml
Once done with all the above, you can use the exposed APIMatic CodeGen API to generate API SDKs and Docs using curl, Postman, or your own custom Web application that consumes the APIMatic CodeGen API service. You can also remove the APIMatic resources using the make undeploy command.
For detailed information, please visit our Direct Deployment APIMatic Docs.
Conclusion
Setting up a containerized application may not be difficult for API users but is definitely a workout. This is largely because containerization, the principle approach that Kubernetes is built upon, is still not nearly as ubiquitous as the classical approach to API design and resource management. Therefore, APIMatic Kubernetes Operator has been introduced as yet another option amongst our developing toolset so that you can get up and running with APIMatic on your own infrastructure.