GCP
GCP
GCP
create vm
-----
login gcp -compute engine - vm instances-compute engine api-enable
create instance-
name-web1
regin-mumbai
zone-asia-south-1a
machine configuration
-----
general purpose -select
series-n1
machine type-n1 standard-a
availability policies-stanadard
display device-enable display device (not req)
boot disk --change-
operating server-window server
version-2022
boot disk type-balanced persistent disk
size-50
advance
---
delete boot disk
google manage encrypted
select
create
exit exit
gcloud compute images list
with image you can create the vm
---
gcloud compute instances create vvm2 --image-family fedora-coreos-testing --image-
project fedora-coreos-cloud --zone us-west4-a
create
sudo -i
lsblk
gcloud compute disks resize instance-1 --zone us-west-4b --size 30
lsblk
parted /dev/sda
resizepart
fix
1
yes
100%
quit
lsblk
check sda1
custom image
------
1st create a instance
name-instance-1
http and https allow
machine image(v-17)
-----
create a instance-
name-instance-1
type-e2
advance option-disk-add disk
disk source type-blank disk
disk type- balanced persistent disk
size-10
deleteion rule-delete disk
save create
open ssh
sudo su
touch file1 file2 file3
mkdir mydir
apt update
apt install apache2 -y
systemctl status apache2
lsblk
go instance-machine image-create-
name-mymachineimage
source-instance-1
location-regional
create
select the mymachineimage-create instance-
open ssh
sudo su
ls
lsblk
cloud storage
--------
storage types in google cloud
1-cloud storage----------in aws s3 storage
2-persistent disk-----------in aws EBS
3-filestorage-----------in aws EFS(elastic file storage)
cloudstorage in cloudshell
------
gsutil mb -b on -l us-east1 gs://rajbuckett1979/
upload
---
in cloushell : upload-upload the file
pwd
ls (file is there)
gsutil cp disk.txt gs://rajbuckett1979
to download
--
gsutil cp gs://rajbuckett1979/disk.txt
/home/rajlaxmidas80/myfd/raj.txt
ls
myfd directory is there
cd myfd
ls
raj.txt is there
public access
--
gsutil iam ch allusers:objectViewer gs://rajbuckett1979
delete permission
---
gsutil iam ch -d allusers:objectViewer gs://rajbuckett1979
versioning in cloudshell
---------
how to do versioning off in cloud shell
------
gsutil versioning set off gs://bucker568974
how to do versioning on in cloud shell
---
gsutil versioning set on gs://bucker568974
lifecycle management
-----
cloudshell
----
1st upload the rule1 file in json format
gsutil lifecycle set 1rule.json gs://bucket40279
create bucket
name-web-bucket345
open cloud shell
then search google-https://www.html5webtemplates.co.uk/-websites templates-
simplestylebanner-right click on download simplystylebanner-copy the website
in cloudshel put it
command:-
---
wget
https://www.html5webtemplates.co.uk/wp-content/uploads/2020/05/simplestyle_banner.z
ip
ls
mkdir websites
mv simplestyle_banner.zip website
cd website
ls
unzip simplestyle_banner.zip
cd simplestyle_banner/
ls
cd ..
gsutil -m cp -r simplestyle_banner gs://web-bucket789
in cloud shell
----
gcloud compute networks create myvpc1 --project=central-cab-410203 --subnet-
mode=auto --mtu=1460 --bgp-routing-mode=regional
custom vpc(l-27)
--
automode vpc custom vpc
1.when you create vpc,then vpc and 1-but in custom only vpc created
not subnet
subnet automatically created in every region
2-control is less 2-control is more,in real scenarion it is
used
lab
---
vpc network-vpcnetworks-create vpc network-
name-mycustomvpc
vpc network ULA internal ipv6 range -disabled
subnets -custom
newsubnet
--
name--subnet-east
region-asia-east1
ip stack type- ipv4(single-stack)
ipv4 range-10.0.1.0/24
private google access-off
flow logs -off
done
add subnet-
name-subnet-useast
region-us-east1
ip stack type- IPV4(single-stack)
IPV4 range-10.0.2.0/24
done
Firewall rules
--
1-icmp allow
2-tcp:22 allow
dynamic routing mode-regional
create
then create vm1 on east-asia region
another vm2 on us-east1
ping on vmi ping vm2
its pinging
click equivalent command line copy the command
you can also create in cloud shell
----------------------------
gcloud compute networks create customvpc --project=central-cab-410203 --subnet-
mode=custom --mtu=1460 --bgp-routing-mode=regional
vpc peering(l-28)
------
vpc network-vpc networks-create
name-vpc-usa
maximum-1460
vpc network ULA-disabled
subnets-custom
new subnet
--
name-subnet-usa
region-us-east1
IP stack-IPv4
IPV4 range-10.0.0.0/24
pvt-off
flow logs-off
hybrid subnet-off
allow--- ssh,icmp
dynamic routing mode-regional
create
another vpc
---------
vpc network-vpc networks-create
name-vpc-asia
maximum-1460
vpc network ULA-disabled
subnets-custom
new subnet
--
name-subnet-asia
region-asia-east1
IP stack-IPv4
IPV4 range-172.16.0.0/24
pvt-off
flow logs-off
hybrid subnet-off
allow--- ssh,icmp
dynamic routing mode-regional
create
create instance
-----
instance-1
----------
compute engine=vm instance-create
name-us-vm
region-us-east1
networkinterface-us-vpc
subnet-10.0.0.0/24
create
instance-2
------
then go to
vpc network--vpc network peering--create connection-continue-
name-mypeering
your vpc-network-vpc-usa
in project central-cab-410203
vpc network name-vpc-asia
ipv4--create
name-mypeering2
your vpc-network-vpc-asia
in project central-cab-410203
vpc network name-vpc-us
ipv4--create
then ping it will happen
then-vm1-set passwd-set-Bz(IRlvg@mYQ1tr
download the file-
remote desktop-
computer name=pvt ip of 2nd vm
username-rajlaxmidas80
pass -2nd vm passwd
ping-8.8.8.8 not happening
go to vpc network-ip addree-reserve external ip-
name-nat-ip
region-asia-specic
attached to -none-reserve
vm2-set passwd-\+)Ui]:]fES+%fM
load balancer(l-32)
----
create a custom vpc-
name-myvpc
asia-east1
2 subnet
subnet1-10.0.0.0/24
subnet2-172.16.0.0/24
firewall rules--
--
all,icmp,ssh,rdp
create
num of instance-2
location-multiple zones-asia-east1
target-even
auto scale-off
min-2
max-2
autohealing-create a health check-
name-new-health
scope-global
protocols-tcp
proxy-none
logs -off
health-5 5
2
2
save
create
come to instance
and open in ssh
instance-1
----
sudo su
yum install httpd -y
service httpd start
service httpd status
cd /var/www/html
vi index.html
this is server1
:wq
copy the public id and paste in google its coming
open instance-2
--
sudo su
yum install httpd -y
service httpd start
service httpd status
cd /var/www/html
vi index.html
this is server2
:wq
copy the public id and paste in google its coming
dashboard-networking-network service-loadbalancing-create
type-application
public facinf-public facing-global
create load balancer-
fronted configuration-
name-front
protocol-http
ipv4-ephmeral-80-done
backend-create a backend service
name-my backend
backend type-instance group
protocol-80 80 30sec
instance group-myload
port-80
capacity-60
create
ok
routing rules-
mode-simple
name-mylb
create
copy the public ip of load balance and paste it on google its happening
auto scaling-l-33
----------
IAM
---
dashboard-IAM & identity-IAM
grant access-add [email protected](only gmail account)-basic-owner-
save
ya29.c.c0AY_VpZhadhC5CP16PXdinNT8JRJeMEX5JjOtcXFZ6ltSos5IWHAe_6cB_EJGueGo2lBHxDPC1p
C-u3qhKoJ855qyxI8nUURd3woC9yRWWw-jKUsn6wnlEjRofL3v_e-xV3IMh07xfeXlH-
u4u6BgkqOH6g5pQgn6VNutBJggprPRh1xHD-
BX_xy07cM5QnEVPfI_CN0wFrnE1dtu3I9dMOv8YiPQkqzT_O_D47roPeuQjSo46gxhXt6RwvqY5pNLfroLT
J7Jhg132Twhidi3P2GaATtbvmEovexio4XQPM97wXRo-
C6svM9CtgsGG2_B1IA00RL_EHuFGDoNVuDupRBfC0qAG98INN8ylFSsCl2tHU7Lr7m27yBxER0MpwWhtPlr
fAN399PZpbQlX0abWobytRsw3g0eW0RknxxYiVw_Jyl7QfMUbjIFVaypxcnW0Bb50ddcoBo4tRgjed8Oy7v
vcnz27wfjmgMmbul-0B_mQ06k9QmXJt7yp0_oQZ9dQJVxJF3hgSo2qdmY15jeOskI5Z_zhoZeRyw9jpYM-
qFOYq0mUfi48srBfjFmoy8cYMbxMIy3sqMcf11BVOFhVfMag93WqyFurml1VrYj9eJlOJuMZs2Vu14W8tOV
cQwk7Yo2ca-IR5OgBlXJrwOe70jxQ3l77cpSjXnoIFsdls9YBtnXqZ25zU9M_rfwc60lWQjmr-
Fnym9Qx36-JxqrpiFvk86ip3VgyaayzaOJa6vhFqOx2aRppfWoq0U_nRhexFqiqeOUgyn6dWqxd-
Vu1aeOxx0mUsnw6329skn5ZlFQ5c5zxgsa0-r2wmoO8qme4WwcvvXouY-
lu4uy6jOqIyfQ8rk5vW4BBXqa270u2rJsxRSr1ulpmfha3cqslzscyFmod-FIkcY_OYu1-
3466XO5sBwZRgSed1QqdVVWs1jMJVWz_15gB1WoWSxQUmOvrYYS0M5wrqVk0iuktutychW_3zvRmcRj0q4Y
a4ubwhIIn7V9cX30127"
curl https://compute.googleapis.com/compute/v1/projects/central-cab-410203/zones/
us-central1-a/instances -H "Authorization":"Bearer
ya29.c.c0AY_VpZhadhC5CP16PXdinNT8JRJeMEX5JjOtcXFZ6ltSos5IWHAe_6cB_EJGueGo2lBHxDPC1p
C-u3qhKoJ855qyxI8nUURd3woC9yRWWw-jKUsn6wnlEjRofL3v_e-xV3IMh07xfeXlH-
u4u6BgkqOH6g5pQgn6VNutBJggprPRh1xHD-
BX_xy07cM5QnEVPfI_CN0wFrnE1dtu3I9dMOv8YiPQkqzT_O_D47roPeuQjSo46gxhXt6RwvqY5pNLfroLT
J7Jhg132Twhidi3P2GaATtbvmEovexio4XQPM97wXRo-
C6svM9CtgsGG2_B1IA00RL_EHuFGDoNVuDupRBfC0qAG98INN8ylFSsCl2tHU7Lr7m27yBxER0MpwWhtPlr
fAN399PZpbQlX0abWobytRsw3g0eW0RknxxYiVw_Jyl7QfMUbjIFVaypxcnW0Bb50ddcoBo4tRgjed8Oy7v
vcnz27wfjmgMmbul-0B_mQ06k9QmXJt7yp0_oQZ9dQJVxJF3hgSo2qdmY15jeOskI5Z_zhoZeRyw9jpYM-
qFOYq0mUfi48srBfjFmoy8cYMbxMIy3sqMcf11BVOFhVfMag93WqyFurml1VrYj9eJlOJuMZs2Vu14W8tOV
cQwk7Yo2ca-IR5OgBlXJrwOe70jxQ3l77cpSjXnoIFsdls9YBtnXqZ25zU9M_rfwc60lWQjmr-
Fnym9Qx36-JxqrpiFvk86ip3VgyaayzaOJa6vhFqOx2aRppfWoq0U_nRhexFqiqeOUgyn6dWqxd-
Vu1aeOxx0mUsnw6329skn5ZlFQ5c5zxgsa0-r2wmoO8qme4WwcvvXouY-
lu4uy6jOqIyfQ8rk5vW4BBXqa270u2rJsxRSr1ulpmfha3cqslzscyFmod-FIkcY_OYu1-
3466XO5sBwZRgSed1QqdVVWs1jMJVWz_15gB1WoWSxQUmOvrYYS0M5wrqVk0iuktutychW_3zvRmcRj0q4Y
a4ubwhIIn7V9cX30127"
roles
---
create a user
give service account permission
give cloud admin permission
give seraacount user permission
then create instance on oteher user it happen
how to create custom role
---
35.235.240.0/20
app engine
--------
dashboard-serverless-appengine-dashboard-
cloudshell
ls
upload app folder
ls
cd app
node server.js
gcloud app describe
gcloud app create
gcloud app describe
cloud run
---------
dashboard-serverless-cloudrun-create
open cloudshell
sql
---
dashboard-more option-database-sql-create-mysql
cloud spanner
---------
database-spanner-