#3858·kubescape

Parse gitVersion to set cloud provider in apiserverinfo

Author: shellyco-codeCreated Sep 17, 2026Updated Sep 17, 2026
Labelsfeature

Overview

Currently, the SetApiServerVersion function in cloudsupport/apiserverinfo.go captures the Kubernetes API server version metadata, but does not extract the underlying cloud provider from the version string.

Problem

Kubernetes distributions deployed on major cloud providers (like EKS, GKE, AKS) typically embed provider-specific identifiers directly into the API server's gitVersion string (e.g., v1.27.1-gke.100, v1.28.2-eks-abcd). There is a maintainer TODO in SetApiServerVersion to parse this string and automatically set the cloud provider, but it has not been implemented. This forces the system to rely on secondary fallback mechanisms to determine the cloud environment.

Solution

  1. Update SetApiServerVersion(version *version.Info) in cloudsupport/apiserverinfo.go.
  2. Implement string matching on version.GitVersion (e.g., check for -gke, -eks, -aks).
  3. Call apiServerInfo.SetProvider(provider) if a match is found.
  4. Remove the // TODO: Parse the gitVersion and set the provider comment.

Alternatives

Relying purely on node labels or cloud APIs for discovery. However, that requires more cluster permissions and takes more time than simply parsing the API server version string we already receive.

Additional context

  • File location: k8s-interface/cloudsupport/apiserverinfo.go:115
  • This is a small but highly impactful enhancement that makes cloud discovery faster and more robust from the very first API server query.