BCS601 Lab Manual
BCS601 Lab Manual
Experiment-01
Creating a Virtual Machine: Configure and deploy a virtual machine with specific CPU
and memory requirements in Google Cloud.
1. Name the VM
Page 4
BCS601 Cloud Computing Lab Manual
▪ Example:
Page 5
BCS601 Cloud Computing Lab Manual
• Run:
Page 6
BCS601 Cloud Computing Lab Manual
Output
Page 7
BCS601 Cloud Computing Lab Manual
Page 8
BCS601 Cloud Computing Lab Manual
Experiment-02
Getting Started with Cloud Shell and gcloud: Discover the use of gcloud
commands to manage Google Cloud resources from Cloud Shell.
2. Click the Cloud Shell icon (● Terminal icon) in the top-right corner.
gcloud init
Page 9
BCS601 Cloud Computing Lab Manual
Run the following command to view all projects associated with your Google
account:
Page 10
BCS601 Cloud Computing Lab Manual
Page 11
BCS601 Cloud Computing Lab Manual
Output
Page 12
BCS601 Cloud Computing Lab Manual
Experiment-03
nano main.py
import functions_framework
Page 13
BCS601 Cloud Computing Lab Manual
@functions_framework.cloud_event
def gcs_trigger(cloud_event):
data = cloud_event.data
bucket = data["bucket"]
file_name = data["name"]
nano requirements.txt
functions-framework
Page 14
BCS601 Cloud Computing Lab Manual
--gen2 \
--runtime=python311 \
--region=us-central1 \
--source=. \
--entry-point=gcs_trigger \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket=BUCKET_NAME" \
--allow-unauthenticated
Page 15
BCS601 Cloud Computing Lab Manual
Output
Page 16
BCS601 Cloud Computing Lab Manual
Experiment-04
Page 17
BCS601 Cloud Computing Lab Manual
nano main.py
@app.route('/')
def home():
app.run(host='0.0.0.0', port=8080)
Page 18
BCS601 Cloud Computing Lab Manual
nano requirements.txt
Flask
gunicorn
nano app.yaml
runtime: python311
automatic_scaling:
min_instances: 1
max_instances: 5
target_cpu_utilization: 0.65
target_throughput_utilization: 0.75
Page 19
BCS601 Cloud Computing Lab Manual
Page 20
BCS601 Cloud Computing Lab Manual
Output
Page 21
BCS601 Cloud Computing Lab Manual
Experiment-05
1. In the Google Cloud Console, click the Navigation Menu (☰) on the top
left.
Page 22
BCS601 Cloud Computing Lab Manual
2. Click Create.
7. Click Create.
Page 23
BCS601 Cloud Computing Lab Manual
allUsers
Page 24
BCS601 Cloud Computing Lab Manual
6. Click Save.
https://storage.googleapis.com/your-unique-bucket-name/your-file-name
Output
Page 25
BCS601 Cloud Computing Lab Manual
Page 26
BCS601 Cloud Computing Lab Manual
Experiment-06
Cloud SQL for MySQL: Discover how Google Cloud SQL for MySQL
provide automated management and high availability for MySQL
databases?
Automated Management
Page 27
BCS601 Cloud Computing Lab Manual
Page 28
BCS601 Cloud Computing Lab Manual
3. Set:
or
Page 29
BCS601 Cloud Computing Lab Manual
■ Using Django/Flask
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'your-db-name',
'USER': 'root',
'PASSWORD': 'your-password',
'HOST': '/cloudsql/your-project-id:your-region:your-instance',
'PORT': '3306',
3. Save changes.
Page 30
BCS601 Cloud Computing Lab Manual
3. Click Create.
Output
Page 31
BCS601 Cloud Computing Lab Manual
Experiment-07
◎
●’´Why Use Cloud Pub/Sub?
"
Page 32
BCS601 Cloud Computing Lab Manual
4. Click Create.
Page 33
BCS601 Cloud Computing Lab Manual
4. Click Create.
Page 34
BCS601 Cloud Computing Lab Manual
project_id = "your-project-id"
topic_id = "my-topic"
publisher = pubsub_v1.PublisherClient()
project_id = "your-project-id"
subscription_id = "my-subscription"
subscriber = pubsub_v1.SubscriberClient()
def callback(message):
print(f"Received: {message.data.decode('utf-8')}")
Page 35
BCS601 Cloud Computing Lab Manual
message.ack()
subscriber.subscribe(subscription_path, callback=callback)
import time
while True:
time.sleep(10)
Output
Page 36
BCS601 Cloud Computing Lab Manual
Page 37
BCS601 Cloud Computing Lab Manual
Experiment-08
Google Cloud, Virtual Private Cloud (VPC) allows you to define and control
networking environments for your resources. You can have multiple VPC
networks, each isolated from one another or interconnected for specific use
cases. Managing multiple VPCs helps you scale, secure, and organize resources
efficiently.
◎
´
●’"
Benefits of Using Multiple VPC Networks
• Private Connectivity – Each VPC can have private IPs that do not
communicate with other VPCs unless explicitly allowed, keeping
sensitive data isolated.
• Granular Firewall Rules – Define specific firewall rules for each VPC,
limiting access to resources within a VPC or between multiple VPCs.
Page 38
BCS601 Cloud Computing Lab Manual
• Custom Subnetting – Each VPC can have its own subnet structure
tailored to the needs of specific projects or services.
Traffic Control
• VPC Peering – You can allow traffic between two or more VPCs by
creating VPC peering connections. This gives you flexibility in managing
traffic flow while maintaining network isolation.
• Private Google Access – For certain services, you can configure access
to Google Cloud services without using public IPs, enhancing security.
Scaling Flexibility
Page 39
BCS601 Cloud Computing Lab Manual
Multi-Tier Applications
You can deploy multi-tier architectures where each tier (e.g., web, app,
database) resides in separate VPC networks, enabling better isolation and
security between tiers.
Cross-Region Architecture
You can deploy resources in multiple regions for disaster recovery or to meet
local compliance requirements while maintaining network isolation between
regions. For instance, a production VPC in one region and a disaster recovery
VPC in another.
You might have managed services (like Cloud SQL or BigQuery) in one VPC
while using compute instances or other resources in another, optimizing
resource placement.
Page 40
BCS601 Cloud Computing Lab Manual
2. Specify the name, region, and subnet configuration for your VPC.
3. Click Create.
2. Choose Custom subnet mode to define your own subnets or Auto mode
for auto-assigned subnets.
3. Define the network and routes that can be shared across the VPCs.
4. Click Create.
2. Define the source and destination VPCs, and configure the firewall to
allow or deny traffic between the VPCs.
Page 41
BCS601 Cloud Computing Lab Manual
Output
Page 42
BCS601 Cloud Computing Lab Manual
Experiment-09
◎
●’"´
Key Features of Google Cloud Monitoring
Performance Tracking
• Custom Metrics – You can define your own custom metrics for specific
applications to monitor application-level health or performance.
Health Monitoring
Page 43
BCS601 Cloud Computing Lab Manual
Page 44
BCS601 Cloud Computing Lab Manual
1. Open the Google Cloud Console → Navigation Menu (☰) → APIs &
Services → Library.
3. Select Metrics from the dropdown and choose the service you want to
monitor (e.g., Compute Engine, Cloud Storage, Cloud Functions).
4. Add the required metrics to your dashboard and adjust visualizations like
line charts, heat maps, or bar charts.
Page 45
BCS601 Cloud Computing Lab Manual
4. Select the notification channels (e.g., email, Slack, SMS) where the alert
should be sent.
3. Use Log Explorer to search for specific logs, such as error messages or
performance warnings, and correlate them with metrics in Cloud
Monitoring.
2. Enable trace collection in your services (e.g., by using the Cloud Trace
SDK for your app).
Page 46
BCS601 Cloud Computing Lab Manual
Output
Page 47
BCS601 Cloud Computing Lab Manual
Experiment-10
2. Install kubectl
kubectl is the Kubernetes command-line tool used to manage Kubernetes
clusters. The Cloud SDK includes kubectl, so if you have the SDK
installed, you already have kubectl.
1. Create a new Google Cloud project (if you don't already have one):
Replace my-cluster with your desired cluster name and adjust the zone if
necessary.
2. Get the credentials for your cluster: This command configures kubectl
to use the cluster you just created.
Dockerfile:
Page 49
BCS601 Cloud Computing Lab Manual
dockerfile
CopyEdit
FROM node:14
WORKDIR /usr/src/app
COPY . .
EXPOSE 8080
deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
Page 50
BCS601 Cloud Computing Lab Manual
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: gcr.io/PROJECT_ID/my-app:v1
ports:
- containerPort: 8080
Page 51
BCS601 Cloud Computing Lab Manual
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
3. Get the external IP address: It may take a few moments for the
LoadBalancer to be provisioned.
Page 52
BCS601 Cloud Computing Lab Manual
The EXTERNAL-IP column will show the public IP once the LoadBalancer is
provisioned.
2. You can also use kubectl to get the status of your pods and services:
Output
Page 53
BCS601 Cloud Computing Lab Manual
Page 54