Skip to main content

Swarm Based Deployment

To get started with setting up the DevOps Pipeline.

Pre-requisites:

  • Jenkins Server for running pipelines
  • Hashicorp Vault for storing secrets
  • Private Docker Registry
  • Ansible for deploying swarm nodes

Setting up the Pipeline

git clone https://github.com/SamagraX-RCW/devops.git
  • Run the scripts to install Docker, Ansible and Vault Cli

chmod +x ./scripts/setup.sh
./scripts/setup.sh
  • Install and Start Jenkins, Vault, Registry Services

chmod +x ./scripts/scripts/jenkins_init.sh
chmod +x ./scripts/install_jenkins_vault_registry.sh

./scripts/jenkins_init.sh
./scripts/install_jenkins_vault_registry.sh

Jenkins Init Image

  • Restart Jenkins to load the RCW jobs

systemctl restart jenkins

Jenkins restart image

Jenkins login image

jenkins plugins installing image

Jenkins dashboard image

  • Configure Jenkins Credentials for Private Registry

    • Update the Registry Credentials in Jenkins:

      Dashboard > RCW > deploy-staging > Credentials > docker-server

      Update with https://nginx-reverse-proxy:80, also create new credentials for registry username and password Jenins Registry Credentials

      Jenkins Registry Credentials 2

    • Update the job credentials for ansible deployment

      Dashboard > RCW > deploy-staging > credentials/identity/schema > configure

      Jenkins Ansible Script

    • Add Vault Server Address and Token Secret

      Dashboard > Manage Jenkins > System > System > Environment Variables

      Add VAULT_TOKEN and VAULT_ADDR

      Jenkins Vault Credentials

  • Create Swarm nodes and deploy RCW Services

ansible-playbook -i ./ansible_workspace_dir/inventory/hosts ./ansible_workspace_dir/main.yml 

ansible playbook image

ansible playbook image

  • Configure Vault

    • Run the makefile to init the vault & generate unseal tokens
    chmod +x setup_vault.sh
    ./setup_vault.sh

    Note: This will store the registry username & password (admin/admin) inside the vault

    • Run the script to get registry username and password from vault
    chmod +x ./scripts/get_secrets.sh
    ./scripts/get_secrets.sh