Repository navigation
feat(orchestrator): add generic k8s kubeconfig helpers, pinned kubectlIn, and air-gap telemetry guard - #6649
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors Kubernetes orchestration logic to improve reliability and environment awareness. By centralizing kubeconfig management and enforcing pinned context execution, it eliminates common connectivity pitfalls. Additionally, it introduces robust support for air-gapped environments by allowing telemetry uploads to be disabled, ensuring the CLI remains performant in restricted network settings. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for air-gapped environments via the GCLUSTER_AIR_GAPPED environment variable, which disables telemetry uploads and external probes. It also refactors kubeconfig loading and context resolution into a shared pkg/orchestrator/k8s package. The reviewer suggested using the existing shell.ExtractRegion helper in kube_auth.go to simplify the zonal-to-regional fallback logic instead of manually splitting the location string.
…lIn, and air-gap telemetry guard - Add provider-agnostic kubeconfig loading, deterministic context resolution, cross-OS exec-plugin basename normalization, and --context pinning helpers in pkg/orchestrator/k8s. - Refactor pkg/orchestrator/gke kube_auth, inspector, and namespace resolution onto pkg/orchestrator/k8s, move kube_auth type declarations into types.go, add empty-context-safe kubectlIn, and extend TestNoUnpinnedKubectlCalls across pkg/orchestrator/... - Add non-probing GCLUSTER_AIR_GAPPED Environment state classification and skip Clearcut CLI telemetry uploads when air-gapped so disconnected runs exit immediately.
…onor current-context, and reuse ExtractRegion
…tighten doc comments, and defer ResolveContext
…ersionFunc in TestExecute
ebf11d8 to
feec9c3
Compare
c9d0258 to
dd49a69
Compare
Summary
Extracts provider-agnostic kubeconfig loading, context resolution, and
--contextpinning utilities intopkg/orchestrator/k8s, hardenskubectlprobe pinning withkubectlIn, and guards CLI telemetry uploads in air-gapped environments via foundationalpkg/shellstate.pkg/orchestrator/k8s/types.go,pkg/orchestrator/k8s/kubeconfig.go):KubeconfigLoader,DefaultKubeconfigLoader,FindContextByCluster(preferring exact context name matches, then activecurrent-contextwhen its cluster matches, before deterministic sorted cluster-entry lookup),ResolveCurrentContext,ExecPluginBaseName(normalizing Windows\paths and.exesuffixes on Unix/WSL), andWithContext.kubectlIn&gkeKubeconfig Refactor (pkg/orchestrator/gke/types.go,pkg/orchestrator/gke/kube_auth.go,pkg/orchestrator/gke/inspector.go,pkg/orchestrator/gke/sps_client.go,pkg/orchestrator/gke/gke_job_orchestrator.go):pkg/orchestrator/gke/types.go, wirespkg/orchestrator/gkeontopkg/orchestrator/k8swithshell.ExtractRegionzonal-to-regional GKE context fallback inresolveGKEContext, distinguishes missingcurrent-contextfrom unknown cluster names inGetCurrentNamespace, addskubectlInrefusing empty contexts so connectivity probes never silently fall back tocurrent-context, and extendsTestNoUnpinnedKubectlCallsacrosspkg/orchestrator/....pkg/shell/airgap.go,pkg/telemetry/telemetry.go,pkg/telemetry/README.md):GCLUSTER_AIR_GAPPEDclassification (IsKnownAirGapped,IsAirGappedEnv,SetDefaultAirGapped,SetDefaultAirGappedState) inpkg/shell(preserving strict Layer-1 separation withoutpkg/telemetryimportingpkg/orchestrator), short-circuitstelemetry.Collector.Executewhen air-gapped so disconnected CLI runs never stall on Clearcut uploads at exit, and documentsGCLUSTER_AIR_GAPPEDinpkg/telemetry/README.md.Cloud-Docs: none
Testing
KUBECONFIG=/dev/null GOOGLE_API_USE_CLIENT_CERTIFICATE=false go test -race -count=1 ./pkg/shell/... ./pkg/orchestrator/... ./pkg/telemetry/... ./cmd/job/...TestFindContextByCluster,TestResolveCurrentContext,TestExecPluginBaseName,TestWithContextAndDefaultLoader,TestNoUnpinnedKubectlCalls,TestKubectlIn_RefusesEmptyContextAndPinsNonEmpty,TestResolveGKEContext_ZonalFallbackAndCurrentContext,TestDefaultKubeClient_GetCurrentNamespaceErrors,TestAirGappedPrecedenceAndConcurrency, andTestExecute_AirGappedSkipsClearcut.