Deploy Kubernetes in Google Cloud Plaform

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

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

Bài viết liên quan

7 Cách Tăng Tốc Ứng Dụng React Hiệu Quả Mà Bạn Có Thể Làm Ngay

React là một thư viện JavaScript phổ biến trong việc xây dựng giao diện người d

Trung Quốc “thả quân bài tẩy”: hàng loạt robot hình người!

MỘT CUỘC CÁCH MẠNG ROBOT ĐANG HÌNH THÀNH Ở TRUNG QUỐC Thượng Hải, ngày 13/5 –

9 Mẹo lập trình Web “ẩn mình” giúp tiết kiệm hàng giờ đồng hồ

Hầu hết các lập trình viên (kể cả những người giỏi) đều tốn thời gian x

Can GPT-4o Generate Images? All You Need to Know about GPT-4o-image

OpenAI‘s GPT-4o, introduced on March 25, 2025, has revolutionized the way we create visual con