跳到主要內容

發表文章

目前顯示的是有「gce」標籤的文章

如何使用 Cloud VPN 跨專案存取私有 GKE 叢集 - 使用 Classic VPN

  如何使用 Cloud VPN 跨專案存取私有 GKE 叢集 - 使用 Classic VPN Classic VPN 使用 Route Based 的方式, 跟據 Routing Table 裡設定的路由規則, 將封包轉送到指定的目的地 以下示範在 project 01, project 02 各自建立 GKE, VM, 接著透過 Classic VPN 讓 us-east4 的 VM 可以 access project 01 下 us-central1 的 private GKE 叢集 Step 1. 建立 VPN Gateway 需要建立一個 VPN Gateway 作為 VPC 網路對外溝通的橋樑 variable "p1_project_id" {     default = "project-01" } variable "p1_region" {     default = "us-central1" } resource "google_compute_vpn_gateway" "p1_vpn_gw" {   project   = var.p1_project_id   region    = var.p1_region   name      = "vpn-gw"   network = "projects/ ${var.p1_ project_id } /global/networks/default" } Step 2. 建立 Routing 規則 需要一個對外 IP, 讓外部流量可以流進 VPN Gateway resource "google_compute_address" "p1_vpn_ip" {   project      = var.p1_project_id   region       = var.p1_region   name         = "p1-vpn-ip"   address_type = ...

如何在 local 端使用 kubectl 操作 private GKE 叢集

如何在 local 端使用 kubectl 操作 private GKE 叢集 Private GKE cluster set up with bastion vm   基於安全考量,  通常在創建 GKE 叢集時, 會選擇 Private Cluster 的部署方式, 將 Control Plan 藏在內網裡, 若想要在 local 端使用 kubectl 來操作 GKE 的話, 會須要一個跳板機(Bastion Host) 將請求 轉送給內網的 Control Plan, 架構如下 然而這個做法有個安全疑慮, 就是當對外 IP 不小心被洩露了, 駭客就能透過它連進跳板機來進行惡意的操作 比較好的做法是,  Cloud IAP + Private 的 Bastion Host  透過 IAP 的TCP 轉送功能, 就不需要分配對外 IP 給 Bastion Host 實際做法如下 環境建立 Step 1. 建立一個新的 Subnet 給 GKE Cluster 使用 gcloud compute networks create k8s-proxy \   --subnet-mode=custom \   --project=backend gcloud compute networks subnets create subnet-cluster \     --network=k8s-proxy \     --range=10.50.0.0/16 \     --region=us-central1 gcloud compute firewall-rules create k8s-proxy-ssh \     --network k8s-proxy \     --allow tcp:22 因為 Cloud IAP 會從  35.235.240.0/20 這個網段連進內網, 所以防火牆需要開放從從 35.235.240.0/20 過來的流量 gcloud compute firewall-rules create allow-ssh-ingress-from-iap...