Cloud Native 10 min read

How to Deploy Microservices with Zadig: Direct Host and Jumpbox Strategies

This guide explains how to use Zadig’s cloud‑native continuous delivery platform to deploy a sample vm‑microservice‑demo project, covering two connection methods—direct host deployment and jump‑box (bastion) deployment—including host configuration, project and service setup, build and deployment scripts, and workflow automation.

Ops Development Stories
Ops Development Stories
Ops Development Stories
How to Deploy Microservices with Zadig: Direct Host and Jumpbox Strategies

Zadig provides a cloud‑native continuous delivery solution for container runtime environments and large‑scale microservices, widely adopted by enterprises, but some services cannot be accessed, causing inconvenience for unified operations management.

Common inaccessible scenarios include services that are not ready to migrate to containers or that remain on VM/host deployment, as well as infrastructure consisting of network‑connected devices such as IoT autonomous‑vehicle hosts or factory‑connected equipment. This scenario is already mature in Xpeng autonomous driving and Li Auto cloud platforms.

Below we use the vm‑microservice‑demo project's backend service and infrastructure as an example to illustrate how to achieve continuous delivery in Zadig. Two common access methods are introduced:

Method One: Target host and Zadig are connected, directly deploy the service to the target host.

Method Two: Connect to Zadig via a bastion (jump) host, then deploy the service to the target host from the bastion.

Project Basic Configuration

Configure Host

System Settings → Host Management → New; fill in host information and save. The host resource can be a target deployment host or a bastion host.

Create Project and Service

Using the vm‑microservice‑demo project, which includes a Vue.js frontend service and a Golang backend service, with dev and qa environments. Source code is located at koderover/zadig/microservice-demo.

<code>zadig/examples/microservice-demo
├── backend # 后端服务源码
├── frontend # 前端服务源码
└── vm # 部署相关配置
    ├── ansible # 使用 ansible 工具部署的相关配置
    │   ├── ansible.Dockerfile # 包含 ansible 工具的镜像 Dockerfile
    │   └── hosts-dev # 部署 dev 环境的主机信息,端口 22 已开放,可使用 ansible 批量操作
    │   └── hosts-qa # 部署 qa 环境的主机信息,端口 22 已开放,可使用 ansible 批量操作
    └── restart.sh # backend 服务部署脚本</code>

System administrator creates the host project vm‑microservice‑demo.

In the project initialization wizard, click the + button to add a service named backend .

Backend Service Build and Deployment

Method One: Direct Deployment to Target Host

Applicable when the target host and Zadig are connected, using automation tools to quickly perform deployment operations.

Deployment Architecture

Preparation Work

Zadig supports deployment tools; using Ansible as an example. The Dockerfile is located at

vm/ansible/ansible.Dockerfile

. Add a custom image

ansible:amd64

as described in the “Build Image” documentation.

Build Configuration

Operating System:

ansible:amd64

Dependency packages:

go 1.12.9

Code source:

koderover/zadig

Binary package storage path:

$WORKSPACE/backend/$PKG_FILE

Generic build script:

<code>#!/bin/bash
set -ex

if [ -e $WORKSPACE/backend ]; then
    rm -rf $WORKSPACE/backend
fi
cp -r $WORKSPACE/zadig/examples/microservice-demo/backend $WORKSPACE/backend
cp -rf $WORKSPACE/zadig/examples/microservice-demo/vm/ansible $WORKSPACE/backend
cp $WORKSPACE/zadig/examples/microservice-demo/vm/restart.sh $WORKSPACE/backend/restart.sh
cd $WORKSPACE/backend
chmod +x restart.sh
make build-backend
tar cvf $PKG_FILE backend restart.sh</code>

Deployment Configuration

Select local direct deployment; the deployment script is:

<code>#!/bin/bash
set -ex

cd $WORKSPACE/backend
ansible-playbook main.yaml --extra-vars PKG_FILE=$ARTIFACT -i hosts-${ENV_NAME} -v</code>

Method Two: Deploy via Bastion Host

Applicable when higher security audit is required (e.g., host is in a private network). Use a bastion host that connects to Zadig, then deploy the service to the target host from the bastion.

Deployment Architecture

Deployment Configuration

Use SSH Agent to copy the build artifact to the bastion host and run the Ansible playbook.

<code>#!/bin/bash
set -ex

# Copy build artifact to bastion
scp -P $kr_jumpbox_server_PORT -i $kr_jumpbox_server_PK $ARTIFACT $kr_jumpbox_server_USERNAME@$kr_jumpbox_server_IP:/home/ubuntu/microservice-demo/$ARTIFACT

# SSH into bastion and execute deployment
if [ $ENV_NAME = "dev" ]; then
    ssh -i $kr_jumpbox_server_PK $kr_jumpbox_server_USERNAME@$kr_jumpbox_server_IP 'cd ~/ansible; ansible-playbook main.yml -i hosts/evm/hosts-dev'
elif [ $ENV_NAME = "qa" ]; then
    ssh -i $kr_jumpbox_server_PK $kr_jumpbox_server_USERNAME@$kr_jumpbox_server_IP 'cd ~/ansible; ansible-playbook main.yml -i hosts/evm/hosts-qa'
fi</code>

Using the Workflows

After configuration, the system automatically creates two environments and three workflows; you can execute a workflow to deploy the service.

Edit a workflow to add a Webhook trigger; when the event occurs, the workflow automatically deploys the service.

More Best Practices

For more complex service build configurations, refer to the “Build Image” documentation to place required tools into a custom image and reduce build time.

Refer to the “Build Cache” documentation to configure build cache, improve build efficiency, and accelerate service updates.

Reference Links

https://github.com/koderover/zadig/tree/main/examples/microservice-demo

https://docs.koderover.com/zadig/v1.13.0/settings/custom-image/

https://docs.koderover.com/zadig/v1.13.0/workflow/cache/

microservicesDevOpsContinuous DeliveryAnsibleBastion HostZadig
Ops Development Stories
Written by

Ops Development Stories

Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.