APIMatic Operator simplifies the configuration and lifecycle management of the APIMatic code and docs generation solution on different Kubernetes distributions and OpenShift. The Operator encapsulates key operational knowledge on how to configure and upgrade the APIMatic CodeGen application, making it easy to get up and running.
More information about the underlying APIMatic CodeGen API that is exposed by this operator can be found here.
APIMatic Operator provides the following features:
- Deploys the APIMatic CodeGen Web API service within the Kubernetes or OpenShift cluster.
- Exposes the APIMatic CodeGen API external to the cluster, using Service type as NodePort, LoadBalancer or ExternalName.
- For exposing the service through an ingress resource, create an Ingress resource in the namespace of your APIMatic CR and set owned APIMatic service created by the operator as a backed service. More information can be found here.
- Manual horizontal scaling of pods.
kubectl scale apm apimatic-sample--replicas=2
Please 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.
Further prerequisites for running the sample include:
- go v1.16.*
- git
- make
- Operator SDK
- A running Kubernetes cluster with kubectl on client. For testing purposes, you can use Minikube or kind
- For checking the service created by the APIMatic operator on-prem, you can use MetalLB
To run the sample for checking the APIMatic operator:
-
Clone the APIMatic repository into your working directory using the following command:
git clone https://github.com/apimatic/apimatic-kubernetes-operator.git
-
Run
make deployto set up the APIMatic operator resources. This will deploy the 'apimatic-system' namespace as well as the CRD and the RBAC manifests. -
Create a secret named '
apimaticimagesecret' to allow pulling the APIMatic CodeGen image using the Docker Hub username registered with APIMatic. If you have not done so, please contact support@apimatic.io for the steps required.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>
-
Create a configmap resource named '
apimaticlicense' that will serve as the volume storing the APIMatic license. An example of this is given below which will create the ConfigMap using the License.lic file located at /usr/local/apimatic/license/kubectl create configmap apimaticlicense --from-file /usr/local/apimatic/license/License.lic
-
This will deploy a ConfigMap resource with the following definition:
apiVersion: v1 data: License.lic: \"<License file contents here>\" kind: ConfigMap metadata: name: apimaticlicense namespace: default
-
Now run the sample using the following command:
kubectl apply -f config/samples/apicodegen_v1beta1_apimatic.yaml
-
You will now see a new Deployment with replica count of 3 and Service of type
NodePortcreated, both named apimatic-sample. Accessing http://localhost:32000 from your browser (or using curl from within the Minikube or Kind cluster, if using that) should now show the APIMatic Titan page. -
You can now 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.
-
Once done, you can remove the APIMatic resources using the following command:
make undeploy
The following steps can be used to utilize Operator LifeCycle Manager (OLM) to deploy the operator and run the sample. The steps are as follows:
-
If not already done so, clone the APIMatic repository into your working directory:
git clone https://github.com/apimatic/apimatic-kubernetes-operator.git
-
Run the following script to install the resources required by OLM to deploy the APIMatic operator in the Kubernetes cluster within the
apimatic-systemnamespace. Information about the different resources required can be found using the steps given here.kubectl apply -f olm/manifests.yaml
-
This should spin up the
ClusterServiceVersionof the operator in theapimatic-systemnamespace, following which the operator pod will spin up. To ensure the that the operator installed successfully, check for theClusterServiceVersionand the operator deployment in the namespace it was installed in.kubectl get csv -n apimatic-system kubectl get deployment -n apimatic-system
-
Create a secret named
apimaticimagesecretto allow pulling the APIMatic CodeGen image using the Docker Hub username registered with APIMatic. If you have not done so, please contact support@apimatic.io for the steps required.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>
-
Create a configmap resource named
apimaticlicensethat will serve as the volume storing the APIMatic license. An example of this is given below which will create the ConfigMap using the License.lic file located at /usr/local/apimatic/license/kubectl create configmap apimaticlicense --from-file /usr/local/apimatic/license/License.lic
-
This will deploy a ConfigMap resource with the following definition:
apiVersion: v1 data: License.lic: \"<License file contents here>\" kind: ConfigMap metadata: name: apimaticlicense namespace: default
-
Now run the sample using the following command:
kubectl apply -f config/samples/apicodegen_v1beta1_apimatic.yaml
-
You will now see a new Deployment with replica count of 3 and Service of type
NodePortcreated, both named apimatic-sample. Accessing http://localhost:32000 from your browser (or using curl from within the Minikube or Kind cluster, if using that) should now show the APIMatic Titan page. -
You can now 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.
-
Once done, you can remove the APIMatic operator resources using the follow script:
kubectl delete -f olm/manifests.yaml
- To request additional features in the future, or if you notice any discrepancy regarding this document, please drop an email to support@apimatic.io.
© 2021 APIMatic.io