Discovers Kubernetes Pod and Service CIDRs without creating probe pods for fast cluster connectivity.
// Source: https://github.com/kubenetworks/kubevpn | License: MIT | Copyright 2022 wencaiwulue // Provided via justclaw.it.com; keep this notice with the code. package discovery import ( "context" "fmt" "net" "strings" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/kubernetes" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" plog "github.com/wencaiwulue/kubevpn/v2/pkg/log" ) // GetCIDR discovers cluster Pod and Service CIDRs using pod-free strategies only: // component flags in kube-system pods, the Service IP-range error trick, and inference from // live Pod/Service IPs. It deliberately does NOT create a probe pod / exec (which added ~15s // per connect) — trading some completeness on locked- ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key