Setting Up a Private CI/CD Pipeline in Azure—Part 3

Listen to this article:
0:00
0:00

Note: This article was adapted from content originally written on October 19th, 2017, titled “Setting up a Private CI/CD Solution in Azure.” It has been simplified and split into four parts for easier reading.

Part 3: Docker Swarm and Core Services Configuration

Key Takeaways

  • This part covers configuring Docker Swarm and setting up GitLab for version control within a CI/CD pipeline.
  • Docker Swarm initializes a cluster with manager and worker nodes, creating a custom overlay network for service communication.
  • GitLab is deployed as a Docker Swarm service, involving persistent storage preparation and post-installation configuration.
  • A private Docker Registry is established for storing container images, requiring SSL certificate generation and client configuration.
  • The article concludes by verifying service health and setting the stage for the next part on Jenkins configuration.

In this part, we’ll configure Docker Swarm to orchestrate our services, set up GitLab for version control and collaboration, and establish a private Docker Registry for container image management.

Docker Swarm Setup

Docker Swarm provides native clustering and orchestration capabilities for Docker. We’ll configure a highly available Swarm cluster with three manager nodes and two worker nodes.

Initialize the Swarm Cluster

Start by initializing the Swarm on the first manager node:

The initialization command will provide two important pieces of information:

  • A manager join token (for adding manager nodes)
  • A worker join token (for adding worker nodes)
Important
Save these tokens securely! You’ll need them to join additional nodes to the cluster. You can retrieve them later using:

docker swarm join-token manager or docker swarm join-token worker

Join Additional Manager Nodes

For high availability, add the remaining manager nodes:

Join Worker Nodes

Verify Swarm Status

Check that all nodes have joined successfully:

Create Overlay Network

Create a custom overlay network for service communication:

Label Nodes for Service Placement

Apply labels to control where services are deployed:

GitLab Configuration

GitLab will serve as our version control system and collaboration platform. We’ll deploy it as a Docker Swarm service for high availability.

Prepare GitLab Directories

First, create persistent storage directories on all manager nodes:

Deploy GitLab Service

Create a Docker Compose file for GitLab deployment:

Note
GitLab initial startup can take 5-10 minutes. Monitor the progress with:
sudo docker service logs gitlab_gitlab -f

Configure GitLab Post-Installation

Once GitLab is running, perform the initial configuration:

  1. Access GitLab at http://gitlab.example.com (through VPN)
  2. Login with:
    • Username: root
    • Password: ComplexPassword123! (change immediately)
  3. Navigate to Admin Area → Settings → General
  4. Configure:
    • Account and limit settings
    • Sign-up restrictions (disable public sign-ups)
    • Project creation limits
  5. Create user accounts for your team
  6. Set up groups and projects structure

Set Up SSH Access for Git

Configure SSH keys for Git operations:

Docker Registry Setup

A private Docker Registry is essential for storing and distributing container images within your organization.

Generate SSL Certificates

First, create self-signed certificates for the registry:

Deploy Docker Registry

Configure Docker Clients

Configure all nodes to trust the registry certificate:

Test Registry Access

Internal DNS Configuration

Set up Bind9 for internal DNS resolution to make services easily accessible:

Configure VMs to Use Internal DNS

Portainer for Management

Deploy Portainer for visual management of the Docker Swarm cluster:

Service Health Verification

Verify all services are running correctly:

Next Steps

We’ve successfully configured Docker Swarm, deployed GitLab for version control, and set up a private Docker Registry. The foundation of our CI/CD infrastructure is now in place.

Continue to Part 4: Jenkins Configuration and Complete Workflow, where we’ll set up Jenkins with Blue Ocean, configure the CI/CD pipeline, and demonstrate the complete development workflow from code commit to deployment.


This is Part 3 of a 4-part series on setting up a private CI/CD solution in Azure.

Table of Contents
Scroll to Top