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, deploying to Kubernetes via Jenkins, and managing API proxies on Apinizer.Technologies and Versions
| Technology | Version |
|---|---|
| Jenkins | 2.541.1 |
| Apinizer | v2026.01.5 |
| GitHub Actions | — |
| Kubernetes | v1.31.6 |
Pipeline Flow
Architecture Overview
This integration scenario uses the following components:- GitHub Actions: Docker image building and versioning are handled on the GitHub side.
- Jenkins: Orchestration and deployment management run on your Jenkins server.
- Kubernetes: Container orchestration runs on your 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:
- Generates a new semantic version
- Builds the Docker image and pushes it to Docker Hub
- Triggers the Jenkins pipeline
Workflow File
The workflow file must be placed in your GitHub repository. Create the following file in your local development environment (IDE or text editor) and push it to your repo:.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 |
GITHUB_TOKEN is a temporary token automatically generated by GitHub Actions and does not need to be added manually to Secrets and Variables. The anothrNick/github-tag-action used in the workflow automatically uses this token to push version tags to the repository.2. Jenkins Pipeline Configuration
The Jenkins pipeline performs the following stages:- Kubernetes Deployment: 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 in the Jenkins UI. Use the following content in the Pipeline script field in the Jenkins UI.Jenkins Credentials Configuration
Add the following credential from Manage Jenkins > Credentials:| Credential ID | Kind | Description |
|---|---|---|
APINIZER_TOKEN | Secret text | Apinizer API token |
For detailed information on generating 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 usingkubectl set image and the rollout status is verified.
Stage 2: Health Check
The health endpoint is checked to verify that the API has been deployed successfully. This step is critical to ensure the API is up and running before deploying to Apinizer. TheAPI_HEALTH_ENDPOINT variable specifies the health check endpoint of the application being deployed. This address is specific to your application; for example:
API_HEALTH_ENDPOINT variable accordingly.
Stage 3: Apinizer API Proxy Sync
In this critical stage:- Proxy Check: Checks whether the relevant API Proxy already exists
- Update or Create:
- If the proxy exists: Updates the OpenAPI spec (
PUTrequest) - If the proxy doesn’t exist: Creates a new proxy (
POSTrequest)
- If the proxy exists: Updates the OpenAPI spec (
Update Proxy (PUT)
When updating an existing proxy, the OpenAPI specification is re-parsed using thereParse: true parameter:
For more details, refer to the Update API Proxy API reference.
Create New Proxy (POST)
When creating a new proxy, backend routing information is also defined:For more details, 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 more details, refer to the Deploy API Proxy API reference.
Configuration Parameters
Environment Variables
The key environment variables used in the pipeline:| Variable | Description | Example Value |
|---|---|---|
NAMESPACE | Kubernetes namespace | example-service |
DEPLOYMENT_NAME | Kubernetes deployment name | example-service |
CONTAINER_NAME | Kubernetes container name | health-api |
DOCKER_IMAGE | Docker image name (username/image) | myusername/health-api |
KUBECTL_PATH | Path to kubectl binary | /usr/local/bin/kubectl |
API_BACKEND_URL | Base URL of the deployed application | https://api.example.com |
API_HEALTH_ENDPOINT | Application health check endpoint | https://api.example.com/health |
API_SPEC_URL | OpenAPI specification URL | https://api.example.com/api/v1/openapi.json |
APINIZER_BASE_URL | Apinizer platform URL | https://qa.apinizer.com |
APINIZER_GATEWAY_URL | Apinizer gateway URL | https://apiqa.apinizer.com/apigateway |
APINIZER_PROJECT | Apinizer project name | prod-cid |
APINIZER_ENVIRONMENT | Target deployment environment | tester |
APINIZER_PROXY_NAME | API Proxy name | health-api-proxy |
APINIZER_PROXY_PATH | Relative path on the gateway | /health-api |
Apinizer API Endpoints
The 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 to Your Own Setup
This example scenario is designed for an API running on Kubernetes. To adapt it to your own infrastructure:Deployment Mechanism
If you’re using a different orchestrator or direct VM deployment instead of Kubernetes, replace the
Kubernetes Deployment stage with your own deployment method.Health Check
If your API has a different health check mechanism, update the
API_HEALTH_ENDPOINT variable with the appropriate endpoint.OpenAPI Spec
Make sure your API’s OpenAPI specification is accessible at a reachable URL. This URL must be accessible by Apinizer.
Environment
Specify the environment you want to use in Apinizer (
dev, test, prod, etc.) in the APINIZER_ENVIRONMENT variable.
