Skip to content

feat(DM01-6276): add keepAlive option to GKE cluster service - #644

Open
liuwei08 wants to merge 4 commits into
masterfrom
feat/DM01-6276
Open

liuwei08 wants to merge 4 commits into
masterfrom
feat/DM01-6276

Conversation

@liuwei08

Copy link
Copy Markdown
Contributor

Summary

Adds a keepAlive option to the GKECluster service spec, allowing clusters to persist after the InfraBox job ends. This enables teams to use long-running GKE clusters for debugging without needing manual provisioning.

Closes DM01-6276 — Vsystem team needs a long-running GKE 1.37 cluster to debug InfraBox job compatibility issues.

Changes

  • types.go: Add KeepAlive bool field to GKEClusterSpec
  • handler.go createCluster: Append --labels infrabox-keep-alive=true to the gcloud create command when keepAlive: true
  • handler.go deleteGKECluster: Skip cluster deletion and only remove the CRD when keepAlive: true
  • handler.go getOutdatedClusters: Exclude clusters with infrabox-keep-alive=true label from GC loop

Usage

"services": [{
  "apiVersion": "gcp.service.infrabox.net/v1alpha1",
  "kind": "GKECluster",
  "metadata": { "name": "my-cluster" },
  "spec": {
    "zone": "us-east1-b",
    "machineType": "n1-standard-1",
    "numNodes": 1,
    "diskSize": 100,
    "clusterVersion": "1.37",
    "keepAlive": true
  }
}]

After the job ends, the GKE cluster continues running in GCP. The user is responsible for manually deleting it via gcloud container clusters delete.

Test plan

  • Create a job with keepAlive: true and verify cluster is not deleted after job finishes
  • Create a job with keepAlive: false (default) and verify cluster is deleted as before
  • Verify GC loop does not clean up clusters tagged with infrabox-keep-alive=true
  • Verify clusterVersion field works together with keepAlive

Allow GKE clusters created as InfraBox job services to persist after
the job ends by setting keepAlive: true in the GKECluster spec.

- Add KeepAlive field to GKEClusterSpec in types.go
- Tag keepAlive clusters with GCP label infrabox-keep-alive=true at creation
- Skip cluster deletion in deleteGKECluster when keepAlive=true
- Exclude labeled clusters from GC loop to prevent auto-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant