Skip to content

Milestone 3

Sudip Padhye edited this page Apr 28, 2021 · 24 revisions

TASKS:

  • Dockerized all Microservices
  • Established CI/CD pipeline using Jenkins
  • Deployed containerized microservices using Kubernetes
  • Automation Scripts for management of VMs and Deployment of Kubernetes
  • Deployed entire system on vanilla Jetstream VMs

Our first step was to create dockerized versions of each micro-service. After that, we integrated all microservices to be continuously deployed using Jenkins Thus, Jenkins provided continuous deployment by pushing every new git commit into docker hub ( docker registry) Continuous deployment was achieved via ssh-ing into our kubectl pod through the Jenkins pipeline. Each new build inside the docker hub deploys the image into the Kubernetes cluster.



Flow

  • Push commit on Github repo on specific microservice branch
  • This will trigger a Jenkins build for a new docker image
  • Jenkins will also check on the test cases written for that image before pushing the image on Docker Hub
  • Once a new image is created, Jenkins will SSH to Kubernetes Server and deploy the new microservice image. This will also remove the previous version of that microservice

Website Deployed:


Getting Started

  1. To create a network, router, security groups, floating IPs, key-pairs, and instances
  2. Starting Instances
  3. Setup Kubernetes in each Instance
  4. Connecting Worker to Master
  5. Deploying Ping Intelligence app on Kubernetes Cluster

Note: In order to create another set of instances and deploying Kubernetes, you will need to deallocate previously allocated resources using Step-6 and then start afresh from Step-1.

Prerequisite: You need to modify several kubespray files for configuring IU/TACC cloud details.

  1. cluster.tfvars
  • Modify Master Node IP. Put you Master Node Floating IP.
  • Modify External Net as required
  • Modify availability zones based on deploying on IU/TACC
  1. k8s-cluster.yml
  • Modify Supplementary address in SSL keys. Put you Master Node Floating IP.
  1. Automation Script
  • Modify IP and put Master Node's Floating IP.

1. Download openrc.sh file to the Atmosphere instance/local system/VM (requirement: Linux based OS)

2. Run the following command:

  source TG-CCR180043-openrc.sh

provide IU Jetstream password

3. Create SSH Key (press enter for options)

  ssh-keygen 

4. Copy paste the below command

  git clone https://github.com/airavata-courses/PingIntelligence.git && cd PingIntelligence && git checkout automation-script &&
  git clone https://github.com/zonca/jetstream_kubespray &&
  cd jetstream_kubespray &&
  git checkout -b branch_v2.15.0 origin/branch_v2.15.0 &&
  cd .. &&
  bash pingintelligence-automation-script.sh

The above set of commands will take around 15-20 minutes to complete the execution.

5. Enter the cluster, Setup Kubernetes Cluster and deploy app using the following command:

  sudo su
  git clone https://github.com/airavata-courses/PingIntelligence.git &&
  cd PingIntelligence &&
  git checkout kubernetes_files &&
  kubectl apply -f ../PingIntelligence/ &&
  sleep 100 &&
  kubectl get pods -o wide 

at the end of this process, you will be able to see all the running pods on the Cluster

6. Ngrokking Step (for Social Media Login)

  cd ..
  sudo apt install zip unzip
  curl -o ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
  unzip ngrok.zip
  rm -rf ngrok.zip
  ./ngrok authtoken <ENTER-YOUR-TOKEN-HERE>
  vi .ngrok2/ngrok.yml

  <<ENTER BELOW CONTENTS INTO THE FILE>>
  authtoken: <VERIFY-THIS-TOKEN-IS-SAME-ENTERED-EARLIER>
  tunnels:
    default:
      proto: http
      addr:  http://149.165.156.145:30030
  <ESC> + :wq

  nohup ./ngrok http http://149.165.156.145:30030 -log=stdout > ngrok.log &
  cat ngrok.log

Your will the ngrokked version of your URL. You can further update Firebase "Authorized Domain" section with this new URL and subsequently start using it.

7. To destroy the Kubernetes cluster and deallocate resources use the below commands. Before, running the following commands, you need to exit the Kubernetes cluster - Master node by entering "exit" command. This will get back to the original Linux instance (mentioned in Step-1). Now run the below commands:

  source TG-CCR180043-openrc.sh
  cd ~/PingIntelligence/
  bash ./jetstream_kubespray/inventory/kubejetstream/terraform_destroy.sh

Jenkins

We have deployed our Jenkins server at http://149.165.168.194:8080/

Username & Password in the submitted file on canvas. Branches monitored by the Jenkins server are as follows:

  1. dockerized_upload_management
  2. dockerized_upload_google
  3. dockerized_user_management
  4. dockerized_ui
  5. dockerized_metadata_search
  6. dockerized_gateway
  7. dockerized_consumer_queue1
  8. dockerized_consumer_queue

If instances are created using the above method then it will have a different SSH key and the same needs to be updated in the Jenkins Credentials Section.