Microservices Migration
Before you get started, make sure you have the following prerequisites:• A Google Cloud Platform account with billing enabled.
• The Google Cloud SDK installed on your local machine.
• Terraform CLI installed on your local machine.
• A domain name registered and accessible via DNS.
Steps
-Create a new Google Cloud project
-Create a new project in the Google Cloud Console, and enable the Kubernetes Engine API. This will allow you to deploy a Kubernetes cluster using Terraform.
-Create a service account for Terraform
-Create a new service account with the necessary permissions to manage your GCP resources. For example, you can grant the Kubernetes Engine Admin role to this service account. Download the JSON key file for this service account, as you will need it to authenticate with the GCP API.
Add your credentials (project ID, region and .JSON keyy file) to the provider.tf and variables.tf files.In a terminal running in the directory that contains the .tf files, run:
terraform init
After Terraform has initialized, run:
terraform plan
to see the infrastructure to be created. This particular config will create a GKE cluster with 2 node pools.
Next you run:
terraform apply
to build the cluster.
Clone the Sock Shop repository into the cluster and access the cloned repo by running the following code in the Google Cloud Console:git clone https://github.com/microservices-demo/microservices-demo.git
cd microservices-demo
cd deploy/kubernetes
kubectl create namespace sock-shop
kubectl apply -f complete-demo.yaml
Expose the Sock Shop service to get the external IP
kubectl expose service front-end --name=front-end-lb --port=80 --target-port=8079 --type=LoadBalancer --namespace=sock-shop
The ExternalIP is then revealed, and you can use this to view the Sock Shop app.