Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setting up AWS and GCP environemnt

Execute the commands below to prepare the AWS and GCP environment

chmod +x *.sh
mkdir -p ~/.aws/
touch ~/.aws/credentials_multiclouddeploy

Creating the Access Key for the terraform-en-1 user using the IAM service and rename it as key.csv and upload it to GCP

./aws_set_credentials.sh key.csv
GOOGLE_CLOUD_PROJECT_ID=$(gcloud config get-value project)
gcloud config set project $GOOGLE_CLOUD_PROJECT_ID
mkdir -p ~/.aws/
touch ~/.aws/credentials_multiclouddeploy
./aws_set_credentials.sh key.csv
GOOGLE_CLOUD_PROJECT_ID=$(gcloud config get-value project)

Setting up the GC Shell

Execute the command below to set the project in the Google Cloud Shell

gcloud config set project $GOOGLE_CLOUD_PROJECT_ID
./gcp_set_project.sh

Setting up the GC APIs

Execute the commands to enable the Kubernetes, Container Registry, and Cloud SQL APIs

gcloud services enable containerregistry.googleapis.com
gcloud services enable container.googleapis.com
gcloud services enable sqladmin.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.com
gcloud services enable serviceusage.googleapis.com
gcloud services enable compute.googleapis.com
gcloud services enable servicenetworking.googleapis.com --project=$GOOGLE_CLOUD_PROJECT_ID

Running Terraform to provision MultiCloud infrastructure in AWS and Google Cloud

Execute the following commands to provision infrastructure resources

cd ~/mission1/en/terraform/
terraform init
terraform plan
terraform apply

Connect to MySQL DB running on Cloud SQL

mysql --host=**<replace_with_public_ip_cloudsql>** --port=3306 -u app -p

Once you're connected to the database instance, create the products table for testing purposes

use dbcovidtesting;
source ~/application/db/create_table.sql
show tables;
exit;

Enable Cloud Build API via Cloud Shell.

GOOGLE_CLOUD_PROJECT_ID=$(gcloud config get-value project)
cd application/app
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT_ID/luxxy-covid-testing-system-app-en

Build the Docker image and push it to Google Container Registry

GOOGLE_CLOUD_PROJECT_ID=$(gcloud config get-value project)
cd application/app
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT_ID/luxxy-covid-testing-system-app-en

Deploy application on GKE (Google Kubernetes Engine) cluster

Open the Cloud Editor and edit the Kubernetes deployment file (*.yaml) and update the variables with your

  • <PROJECT_ID> on the Google Container Registry path
  • AWS Bucket name, AWS Keys (open file access key cvs file and use Access key ID and Secret access key)
  • Cloud SQL Database Private IP.
cd application/kubernetes/
luxxy-covid-testing-system.yaml

				image: gcr.io/<PROJECT_ID>/luxxy-covid-testing-system-app-en:latest

				- name: AWS_BUCKET
          value: "luxxy-covid-testing-system-pdf-en-xxxx"
        - name: S3_ACCESS_KEY
          value: "xxxxxxxxxxxxxxxxxxxxx"
        - name: S3_SECRET_ACCESS_KEY
          value: "xxxxxxxxxxxxxxxxxxxx"
        - name: DB_HOST_NAME
          value: "xxxxxxxx"

Connect to the GKE (Google Kubernetes Engine) cluster via Console

Deploy the application Luxxy in the Cluster

cd application/kubernetes
kubectl apply -f *.yaml

Database Migration

  • Connect to Google Cloud Shell
  • Download the dump using wget
  • Connect to MySQL DB running on Cloud SQL
mysql --host=**<replace_with_public_ip_cloudsql>** --port=3306 -u app -p

Import the dump on Cloud SQL

use dbcovidtesting;
source dump/db/db_dump.sql

Check if the data got imported correctly

select * from records;
exit;

Sync PDF Files with your AWS S3

Connect to the AWS Cloud Shell and sync your data with s3 bucket

aws s3 sync . s3://**link to s3 bucket**

Destroying the environment permanently

  • Destroy the deployment
kubectl delete deployment luxxy-covid-testing-system
  • Destroy the cluster
kubectl delete service luxxy-covid-testing-system

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages