Caprover deployment - arashafazeli/bb-readme-tutorials GitHub Wiki

Intro

In this project we are using Caprover which is an open-source PaaS (Platform as a service) for app/database deployment and web server manager.

Participants in this group project:

  • Alva Thunberg
  • Arash Afazeli
  • Kjell Bovin
  • Ludvig Ravelin
  • Bad Luck

The assignment contains of following parts

  1. Infrastructure as Code and Configuration Management
  2. Continuous Deployment showcase

Prerequisites

  • Terraform and Ansible installed on local computer
  • Attached Terraform file
  • Attached Ansible file

Infrastructure as Code and Configuration Management

Starting up:

  1. Make sure you do not already have an initalized terraform by destroying everything with:

terraform destroy 
  1. Head over to you browser and go to your Elastx page. To the left you'll find a menu section called "Project" -> "API access", in the top right corner you'll find the "Download Openstack RC file"
  2. Source the chas-RC file
  3. Head over to the openstack.tf file and change stated keypair name to your own keypair name
  4. Check connectivity to server:

ssh -i my_keypair ubuntu@IP
  1. Head over to Elastx and copy your new assigned floating IP and paste it hosts-file in projects root directory
  2. Change path to your SSH-keys in hosts-file
  3. Make the sure that the key-file is not too open with command

chmod 400 my_keypair
  1. Initialize and start Terraform:

terraform init
terraform fmt
terraform plan
terraform apply
  1. Run ansible playbook in projects root directory:

ansible-playbook main.yml
  1. If Error occurs try following on your computer

ssh-keygen -R "hostname"

Continuous Deployment showcase

CapRover Root Domain Configurations

  1. Open caprover webpage floatinIP:3000 (default password captain42)
  2. Add your caprover.domain

Enable HTTPS on CapRover webpage

  1. Open caprover webpage http://caprover_domain:3000 (default password captain42)
  2. Click enable HTTPS button
  3. State your mailadress
  4. Click force

Create a new app

  1. Name your app
  2. Click Create new app

Add remote registry in cluster

  1. Click cluster section on the left side
  2. Click cluster
  3. Click add remote registry
  4. Add Gitlab credentials

Password:Personal accesstoken
domain registry.gitlab.com/lura00/u08_breakingbad-demo/lura00:latest
image prexix lura00
  1. Click Add remote registry

Disable Default Push

  1. Click edit
  2. Disable push
  3. Choose disable push from dropdown menu
  4. Save and update

Adding variables:

  1. In Gitlab, click Settings, CI/CD and add following variables

Key : CAPROVER_URL , Value : https://captain.root.domain.com/ [replace it with your domain]
Key : CAPROVER_PASSWORD , Value : mYpAsSwOrD [replace it with your password]
Key : CAPROVER_APP , Value : my-test-gitlab-deploy [replace it with your app name]

Activate the pipeline and add to CapRover

  1. Trigg pipline
  2. The pipeline will build and push Docker container, which will be applied to Caprover
  3. Open caprover webpage https://caprover_domain
  4. Click apps
  5. Choose app
  6. Click enable HTTPS

After pipline and app is built

tada