Google Cloud Platform

glcoud sample

nockdoo 2020. 5. 26. 21:45

VM

Create the source Compute Engine

gcloud container clusters create jenkins-cd \ --num-nodes 2 \ --machine-type n1-standard-2 \ --scopes "https://www.googleapis.com/auth/source.read_write,cloud-platform"
gcloud beta compute instances create source-vm --zone=us-central1-a --machine-type=n1-standard-1 --subnet=default --scopes="cloud-platform" --tags=http-server,https-server --image=ubuntu-minimal-1604-xenial-v20200317 --image-project=ubuntu-os-cloud --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-device-name=source-vm --metadata startup-script='#! /bin/bash # Installs apache and a custom homepage sudo su - apt-get update apt-get install -y apache2 cat <<EOF > /var/www/html/index.html <html><body><h1>Hello World</h1> <p>This page was created from a simple start up script!</p> </body></html> EOF'

GKE

Create a kubernetes cluster

gcloud container clusters create target-cluster --scopes="cloud-platform" --zone=us-central1-c --machine-type n1-standard-4 --image-type ubuntu --num-nodes 3 --enable-stackdriver-kubernetes

Get credentials from K8S cluster

gcloud container clusters get-credentials target-cluster --zone us-central1-c 

Network

Create the private network

gcloud compute networks create privatenet --subnet-mode=custom 

Create the sub network

gcloud compute networks subnets create privatesubnet-us --network=privatenet --region=us-central1 --range=172.16.0.0/24
gcloud compute networks subnets create privatesubnet-eu --network=privatenet --region=europe-west1 --range=172.20.0.0/20

List of network

gcloud compute networks list

List of subnet

gcloud compute networks subnets list --sort-by=NETWORK

Create the firewall rules for privatenet

gcloud compute firewall-rules create privatenet-allow-icmp-ssh-rdp --direction=INGRESS --priority=1000 --network=privatenet --action=ALLOW --rules=icmp,tcp:22,tcp:3389 --source-ranges=0.0.0.0/0

Create a firewall rule to allow the HTTP:

gcloud compute firewall-rules create default-allow-http --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:80 --source-ranges=0.0.0.0/0 --target-tags=http-server

'Google Cloud Platform' 카테고리의 다른 글

[VM] Authorize the VM with credentials  (0) 2020.06.02
[VM] upload file  (0) 2020.06.02
[GKE] Blue-green deployments  (0) 2020.05.24
[GKE] Canary deployments  (0) 2020.05.24
[GKE] Canary deployments in production - session affinity  (0) 2020.05.23