Overview
This guide shows you how to automatically deploy your APIs to Apinizer using a modern CI/CD pipeline. The example scenario covers building Docker images with GitHub Actions, Kubernetes deployment with Jenkins, and API proxy management on Apinizer.Technologies and Versions Used
| Technology | Version |
|---|---|
| Jenkins | jenkins/jenkins:lts |
| Apinizer | v2026.01.5 |
| GitHub Actions | — |
| Kubernetes | Depends on your environment |
Pipeline Flow
Architecture Overview
This integration scenario uses the following components:- GitHub Actions: Docker image build and versioning operations are handled on the GitHub side.
- Jenkins: Orchestration and deployment management runs on your Jenkins server.
- Kubernetes: Runs on your container orchestration cluster.
- Apinizer: API Gateway and API proxy management is handled through your Apinizer instance.
1. GitHub Actions Workflow
On every push to themain branch, GitHub Actions automatically:
- Creates a new semantic version
- Builds a Docker image and pushes it to Docker Hub
- Triggers the Jenkins pipeline
Workflow File
The workflow file must be located in your project’s GitHub repository. Create the following file path in your local development environment (IDE or text editor) and push it to your repository:.github/workflows/docker-build-push.yml
GitHub Secrets Configuration
Add the following secrets from Repository Settings > Secrets and Variables > Actions:| Secret | Description |
|---|---|
DOCKERHUB_USERNAME | Your Docker Hub username |
DOCKERHUB_TOKEN | Docker Hub access token |
JENKINS_URL | Your Jenkins instance URL |
JENKINS_JOB_NAME | Jenkins job name |
JENKINS_USER | Jenkins username |
JENKINS_TOKEN | Jenkins API token |
2. Jenkins Pipeline Configuration
The Jenkins pipeline performs the following stages:- K8s Deploy: Deploys the new Docker image to Kubernetes
- Health Check: Verifies the API is running correctly
- Sync Apinizer API Proxy: Updates or creates the API Proxy
- Deploy to Apinizer: Deploys the proxy to the specified environment
Jenkinsfile
The Jenkins pipeline can be defined by creating a new Pipeline job through the Jenkins UI. You can use the following content in the Pipeline script field in the Jenkins UI.Jenkinsfile
Jenkins Credentials Configuration
Add the following credential from Manage Jenkins > Credentials:| Credential ID | Type | Description |
|---|---|---|
APINIZER_TOKEN | Secret text | Apinizer API token |
For detailed information on creating an Apinizer API token, refer to the Token Retrieval Methods documentation.
3. Pipeline Stage Details
Stage 1: Kubernetes Deployment
This stage runs on the Jenkins server. The Docker image built by GitHub Actions is deployed to the Kubernetes cluster. The deployment is updated using thekubectl set image command and the rollout status is monitored.
Stage 2: Health Check
The health endpoint is checked to verify that the API was deployed successfully. This step is critical to ensure the API is running before deploying to Apinizer. TheAPI_HEALTH_ENDPOINT variable specifies the health check endpoint of the application you are deploying. This address is specific to your application, for example:
API_HEALTH_ENDPOINT variable accordingly.
Stage 3: Apinizer API Proxy Synchronization
In this critical stage:- Proxy Check: Verifies whether the relevant API Proxy exists
- Update or Create:
- If proxy exists: Updates the OpenAPI spec (
PUTrequest) - If proxy doesn’t exist: Creates a new proxy (
POSTrequest)
- If proxy exists: Updates the OpenAPI spec (
Updating a Proxy (PUT)
When updating an existing proxy, the OpenAPI specification is re-parsed using thereParse: true parameter:
For detailed information, refer to the Update API Proxy API reference.
Creating a New Proxy (POST)
When creating a new proxy, backend routing information is also defined:For detailed information, refer to the Create API Proxy from URL API reference.
Stage 4: Deploy to Apinizer Environment
In the final stage, the updated or newly created proxy is deployed to the specified environment using Apinizer’s deployment API:For detailed information, refer to the Deploy API Proxy API reference.
Configuration Parameters
Environment Variables
Key environment variables used in the pipeline:| Variable | Description | Example Value |
|---|---|---|
APINIZER_BASE_URL | Apinizer platform URL | YOUR_APINIZER_URL |
APINIZER_PROJECT | Apinizer project name | YOUR_PROJECT_NAME |
APINIZER_ENVIRONMENT | Target deployment environment | YOUR_ENVIRONMENT_NAME |
APINIZER_PROXY_NAME | API Proxy name | YOUR_PROXY_NAME |
APINIZER_PROXY_PATH | Relative path on the gateway | YOUR_PROXY_RELATIVE_PATH |
API_SPEC_URL | OpenAPI specification URL | YOUR_BACKEND_URL/openapi.json |
Apinizer API Endpoints
Apinizer API endpoints used in this pipeline:| Operation | Endpoint |
|---|---|
| Proxy Check | GET /apiops/projects/{project}/apiProxies/{proxyName}/ |
| Update Proxy | PUT /apiops/projects/{project}/apiProxies/url/ |
| Create Proxy | POST /apiops/projects/{project}/apiProxies/url/ |
| Environment Deploy | POST /apiops/projects/{project}/apiProxies/{proxyName}/environments/{env}/ |
For detailed information about the Apinizer Management API, refer to the API Overview documentation.
Adapting the Pipeline for Your Own Use
This example scenario is designed for an API running on Kubernetes. To adapt it to your own infrastructure:Deployment Mechanism
If you use a different orchestrator instead of Kubernetes or direct VM deployment, replace the
K8s Deploy stage with your own deployment method.Health Check
If your API uses a different health check mechanism, update the
API_HEALTH_ENDPOINT variable with the relevant endpoint.OpenAPI Spec
Make sure your API’s OpenAPI specification is available at an accessible URL. This URL must be reachable by Apinizer.
Environment
Specify the environment you want to use in Apinizer (
dev, test, prod, etc.) in the APINIZER_ENVIRONMENT variable.
