Create new project
You can use Google Cloud CLI, download at https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe
Enable Compute Engine API
https://cloud.google.com/compute/docs/regions-zones
You can use
asia-southeast1-a
: Jurong West, Singapore, APAC (code 30
)
asia-southeast1-b
: Jurong West, Singapore, APAC
asia-southeast1-c
: Jurong West, Singapore, APAC
Create network
Create filewall rules for internal connection
Create filewall rules for external connection
Create kubernetes controller
Get public IP address
Mapping kubernetes controller with public IP
Run commands
gcloud auth login
gcloud config set compute/region asia-southeast1
gcloud config set compute/zone asia-southeast1-a
gcloud config set project my-project-337503
gcloud compute networks create kubernetes-cluster --subnet-mode custom
gcloud compute networks subnets create kubernetes --network kubernetes-cluster --range 10.240.0.0/24
gcloud compute firewall-rules create kubernetes-cluster-allow-internal --allow tcp,udp,icmp --network kubernetes-cluster --source-ranges 10.240.0.0/24,10.244.0.0/16
gcloud compute firewall-rules create kubernetes-cluster-allow-external --allow tcp:22,tcp:6443,icmp --network kubernetes-cluster --source-ranges 0.0.0.0/0
gcloud compute addresses create kubernetes-controller --region $(gcloud config get-value compute/region)
gcloud compute addresses create kubernetes-controller --region asia-southeast1
gcloud compute address list
gcloud compute instances create controller --async --boot-disk-size 200GB --can-ip-forward --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud --machine-type n1-standard-1 --private-network-ip 10.240.0.10 --scopes compute-rw,storage-ro,service-management,service-control,logging-write,monitoring --subnet kubernetes --address 34.124.180.248
for i in 0 1;
do gcloud compute instances create worker-${i} --async --boot-disk-size 200GB --can-ip-forward --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud --machine-type n1-standard-1 --private-network-ip 10.240.0.2${i} --scopes compute-rw,storage-ro,service-management,servicecontrol,logging-write,monitoring --subnet kubernetes;
done
If you catch error
Install Docker
Install Docker
gcloud compute ssh controller
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-propertiescommon
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-cache madison docker-ce
sudo apt-get update && sudo apt-get install -y docker-ce=5:20.10.12~3-0~ubuntu-focal docker-ce-cli=5:20.10.12~3-0~ubuntu-focal
Nguồn: viblo.asia