Skip to content
hannctl.
PDF ↓
← All work
02 / PF-02 · GCP · IaC IaC automation

GCP Terraform GKE platform.

A module set that keeps capacity during GKE node pool upgrades with SURGE, and opens only what a VPN needs through a firewall baseline, all as code.

PERIOD
Personal project · released Nov 2026
MY ROLE
Design and implementation
TOOLS & CONTEXT
Terraform · GCP · GKE · Cloud Logging · Cloud Monitoring — 22 modules · 3 examples
GKE node pool SURGE upgrademax_surge = 5 max_unavailable = 0New nodesOld nodesOld nodes leave one at a time · 0 unavailableSwapped to 5 new nodes · 0 nodes unavailableSoak 3600s applies only to BLUE_GREEN
The swap finishes. The 3600s soak value is read only under BLUE_GREEN.
01 / CONTEXT

Problem

A GKE node upgrade must not reduce serving capacity, and management ports should open only from a VPN.

02 / DECISIONS

Approach

The node pool upgrades with SURGE: five new nodes come up first and unavailable stays at zero. The c2sfirewall module opens management ports from the VPN at priority 1000 and denies other tcp and udp outbound at priority 65534.

03 / ENGINEERING

Implementation

  • Terraform
  • GCP
  • GKE
  • Cloud Logging
  • Cloud Monitoring

Scale · 22 modules · 3 examples

FLOW / 05
GKE node pool SURGE upgrademax_surge = 5 max_unavailable = 0Old nodes

The node pool upgrades with SURGE: max_surge 5, max_unavailable 0.

01 / 05
Read every step
  1. The node pool upgrades with SURGE: max_surge 5, max_unavailable 0.
  2. Five new nodes come up first. The existing nodes stay in place.
  3. Workloads move to the new nodes. No node drops out during the swap.
  4. Only after a replacement is ready does an old node leave.
  5. The swap finishes. The 3600s soak value is read only under BLUE_GREEN.
Firewall evaluated in priority orderTwo rules from the c2sfirewall module, plus the GCP implied rules1000 · INGRESS allowVPN ranges to tcp 22, 3389, 637965534 · EGRESS denytcp and udp 0-65535 outbound denied65535 · GCP implied rulesInbound deny, outbound allowVPNallowServer outbounddenyDeny by default, open only what is needed with an earlier rule
An allow rule ahead of 65534 can still open a specific path.
04 / VERIFICATION

Result

Old nodes leave only after replacements are ready. Host errors flow from the hostError audit log to a log-based metric, an alert policy, and a Slack channel.

22
Terraform modules
5
Extra nodes first (max_surge)
0
Nodes down at once (max_unavailable)
05 / REFLECTION

What I learned

I learned that judging behavior from a setting's name can be wrong. A value like soak time sounds as if it applies to every upgrade, but it is read only under the BLUE_GREEN strategy, so the SURGE example states in a comment that the value has no effect there. Protecting capacity during upgrades also works only when the intent is pinned in numbers, such as bring five new nodes up first (max_surge 5) and take none away (max_unavailable 0), so the result stays the same whoever runs it. The firewall follows the same idea: the module ships a baseline that opens only management ports at priority 1000 and blocks the rest at 65534, so every new environment starts from the same rules.

OUTCOME

22 modules — max_surge 5, max_unavailable 0

Public repo: pf-02-gcp-terraform-gke-platform ↗

NEXT / PF-03 · Tencent · IaC Tencent Cloud audit-ready Terraform

Search the site

Quick links ↑ ↓ move · Enter open · Esc close

Choose a theme

Click a badge to switch to that theme on the same content. Dragging only swings it.

Back to the front page →