You dont have javascript enabled! Please enable it!

How To Setup And Configure A Cloud Environment In Google Cloud? Learn Here!

5 Min. Read

Cloud computing provides services like storing data, networking, and much more over the internet. Not every business can build its cloud infrastructure, so they opt for cloud computing. One such cloud computing service is Google Cloud.

In this article, we will learn about the Google Cloud Platform (GCP), and how to setup and configure a cloud environment in Google Cloud for your business.

Let’s begin!

What Is Google Cloud Platform?

The Google Cloud Platform (GCP) is a cloud computing service provided by Google. Although Google Cloud Platform has fewer services than AWS or Azure, its design and documentation are unmatched.

It provides an impressive catalog of services, such as:

  • Computation services – Google App Engine, Compute Engine, and Kubernetes Engine.
  • Storage services – Cloud Storage, Cloud SQL, and Cloud Bigtable.
  • Big Data services – Cloud datastore, Cloud Dataproc, BigQuery
  • Management services – Google Stackdriver and GCP Console app.
  • Networking services – Virtual Private Cloud (VPC), Content Delivery Network, and Cloud Load Balancing.
  • Cloud AI – Machine LearningEngine and Cloud AutoML.
  • Security and Identity – Data Loss Prevention API and Cloud Identity and Access Management.

How To Setup Your Environment?

If you are new to the Google Cloud Platform, you will get a 12-month free trial period and $300 worth of credits to learn about the GCP services and experiment with workloads.

This is how you can set up your cloud environment:

1) Create an account on Google Cloud.

2) Go to Project Selector, create a new Google Cloud project, or select an existing one.

3) Enable billing for the new cloud project.

4) Authorize the Cloud Run Admin API.

5) Using this guide, install and initialize the gcloud CLI.

6) Update the gcloud components by running the following command:

gcloud components update

7) Using the following command, you can set your default region. Replace the ‘REGION‘ text with the region you want from this list:

gcloud config set run/region REGION

8) You can install Docker (optional) to create Docker containers. To add the Docker credential helper, use the following gcloud commands:

gcloud auth configure-docker
gcloud components install docker-credential-gcr

Step-by-Step to Setup and Configure a Cloud Environment in Google Cloud

Setting up and configuring a cloud environment in Google Cloud is a quest in the Google Challenge lab.

Completing this will earn you a skill badge issued by Google, recognizing your knowledge of Google Cloud Products.

High Performance Computing journey with new Google Cloud HPC Toolkit
[ Image Credit – Google Cloud HPC Toolkit Features ]
We will set us-east1 as the region and us-east1-b as the zone.

The following steps are how you can complete this activity:

1) Start the lab and open Google Console in an incognito window.

2) Log into the account using the credentials provided to you on the quest page.

3) Activate Cloud Shell.

4) Once activated, enter the code export USER_NAME2= and copy-paste the username 2 credential on the quest page.

Task 1- Create Development VPC Manually

A VPC network (Google Virtual Private Cloud network) is very similar to a physical network, except that it is virtualized within the Google Cloud Platform (GCP).

Create a VPC called ‘griffin-dev-vpc‘. Enter the following commands:

gcloud compute networks create griffin-dev-vpc --subnet-mode custom

gcloud compute networks subnets create griffin-dev-wp --network=griffin-dev-vpc --region us-east1 --range=192.168.16.0/20

gcloud compute networks subnets create griffin-dev-mgmt --network=griffin-dev-vpc --region us-east1 --range=192.168.32.0/20

Authorize Cloud Shell when prompted.

Task 2- Create Production VPC Using Deployment Manager

The next task is to create production VPC using Deployment Manager.

Using cloud shell, let the code run after authorization, and enter the next command:

gsutil cp -r gs://cloud-training/gsp321/dm ~/

cd dm

sed -i s/SET_REGION/us-east1/g prod-network.yaml

gcloud deployment-manager deployments create prod-network \
--config=prod-network.yaml

cd ..

When the task is completed successfully, move on to the next one.

Task 3- Create Bastion Host

To securely connect to VM instances on Google Cloud, you need to create a Bastion Host.

In the cloud shell, enter the following commands:

gcloud compute instances create bastion --network-interface=network=griffin-dev-vpc,subnet=griffin-dev-mgmt --network-interface=network=griffin-prod-vpc,subnet=griffin-prod-mgmt --tags=ssh --zone=us-east1-b

gcloud compute firewall-rules create fw-ssh-dev --source-ranges=0.0.0.0/0 --target-tags ssh --allow=tcp:22 --network=griffin-dev-vpc

gcloud compute firewall-rules create fw-ssh-prod --source-ranges=0.0.0.0/0 --target-tags ssh --allow=tcp:22 --network=griffin-prod-vpc

Task 4- Create And Configure Cloud SQL Instance

The next task is to create and configure the Cloud SQL Instance.

Create and configure Google Cloud SQL Instance
Create and configure Google Cloud SQL Instance

To setup SQL, enter the following command:

gcloud sql instances create griffin-dev-db --root-password password --region=us-east1 --database-version=MYSQL_5_7

SQL will take 5 minutes to set up. Enter the next command:

gcloud sql connect griffin-dev-db

This will take 2 minutes to process. When it’s done, you will be asked to enter a password. Remember that your password is “password.” Type it carefully and hit enter. Copy the following text after that:

CREATE DATABASE WordPress;
GRANT ALL PRIVILEGES ON WordPress.* TO "wp_user"@"%" IDENTIFIED BY "stormwind_rules";
FLUSH PRIVILEGES;

Then type

"exit"

Task 5- Create Kubernetes Cluster

Next, we move on to create a Kubernetes cluster.

In the Cloud Shell, use the following command to copy the files for Kubernetes:

gsutil cp -r gs://cloud-training/gsp321/wp-k8s ~/

Then create the cluster:

gcloud container clusters create griffin-dev \
--network griffin-dev-vpc \
--subnetwork griffin-dev-wp \
--machine-type n1-standard-4 \
--num-nodes 2 \
--zone us-east1-b

gcloud container clusters get-credentials griffin-dev --zone us-east1-b

cd ~/

It will take 5 minutes for Kubernetes to create clusters. Proceed to the next task when the operation is completed.

Task 6- Prepare The Kubernetes Cluster

To prepare the Kubernetes cluster, enter the following commands:

sed -i "s/username_goes_here/wp_user/g" wp-k8s/wp-env.yaml
sed -i "s/username_goes_here/stormwind_rules/g" wp-k8s/wp-env.yaml

Then, use the command below to create the key:

cd wp-k8s

kubectl create -f wp-env.yaml

gcloud iam service-accounts keys create key.json \
--iam-account=cloud-sql-proxy@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com
kubectl create secret generic cloudsql-instance-credentials \
--from-file key.json

If there is an error and the command failed, enter the code above again.

Check progress again, and it should be successful this time.

Task 7- Create A WordPress Deployment

You can create a WordPress deployment through Google Cloud Marketplace.

Google Cloud Marketplace
Google Cloud Marketplace

Let’s continue creating the WordPress deployment through the Cloud Shell, enter the command below:

sed -i "s/YOUR_SQL_INSTANCE/griffin-dev-db/g" wp-deployment.yaml

Then, enter the next command:

kubectl create -f wp-deployment.yaml
kubectl create -f wp-service.yaml

Task 8- Enable Monitoring

Now to enable monitoring, carefully type:

"kubectl get svc"

If the WordPress external-IP shows <pending>, type:

"kubectl get svc -w"

Copy the External IP of WordPress. This is the endpoint’s address.

You can also copy the endpoint’s address in the following way:

  • Navigation Menu -> Kubernetes Engine -> Services and Ingress -> Copy Endpoint’s address

Then, follow these steps:

  • Navigation Menu -> Monitoring -> Uptime Checks -> + CREATE UPTIME CHECK
  • Title: WordPress Uptime
  • Next -> Target
  • Hostname : {Endpoint’s address}
  • Path: /
  • Next -> Next -> Create

Proceed when the uptime check and alert are saved.

Task 9- Provide Access For An Additional Engineer

Lastly, you can provide access for an additional engineer.

Enter the following command to provide editor access to a second engineer:

gcloud projects add-iam-policy-binding $DEVSHELL_PROJECT_ID --member=user:$USER_NAME2 --role=roles/editor

Congratulations! You have completed the Google Cloud challenge lab.

Summary

In this guide, we showed you how to set up and configure a cloud environment in Google Cloud Platform (GCP), and provided several tasks to complete as part of the Google quest Challenge lab.

After every task, “Check the Progress” on the challenge page. You can only move forward once you have completed the previous objective.

> Learn more on how to pass and prepare for the Google Cloud Certified – Associate Cloud Engineer (ACE) certification exam.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Photo of author
Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect, Swiss Certified ICT Security Expert, Certified Cloud Security Professional (CCSP), Certified Information Security Manager (CISM), Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT). He has over 20 years of broad IT experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems with extensive practical knowledge of complex systems build, network design, business continuity, and cloud security.

Related Posts

Previous

How To Delete Microsoft Sentinel Analytics Rule Templates

Protect Backup Data In Azure Blob Using Vembu BDRSuite

Next

Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!