Read cluster facts from the cluster instead of asking for them - #3
Merged
Merged
Conversation
…ng for them Kubernetes was unusable until someone supplied `egress.dnsCIDRs` by hand: the policy check rejected an empty list outright, so the provider reported itself unavailable. That value is the cluster's own DNS service address — 10.96.0.10 on kind, 10.43.0.10 on k3s, different again elsewhere — which is machine data the cluster will state on request. Requiring a person to find it blocked the case Kubernetes exists for, connecting to a cluster somebody else runs, and a wrong value breaks name resolution inside the workspace in a way that is very hard to trace back. The provider now resolves it from the `kube-system` service labelled `k8s-app=kube-dns`, the selector every common distribution uses, covering both addresses of a dual-stack service and rejecting a headless one. A configured range stays authoritative and skips discovery entirely. When RBAC hides `kube-system`, the operator is asked — with an explicit code and a message that says what to request — because that is the one case where the machine genuinely cannot answer. Egress validation moves after the environment checks, since discovery needs a reachable cluster and "the cluster is unreachable" is a more actionable answer than "the egress policy is incomplete". Discovered ranges are validated exactly as configured ones are, and cached per context with an expiry so a cluster rebuilt under a familiar name is not answered from a stale entry. Also exposes a read-only view of kubeconfig contexts, so a surface can offer the clusters the host already knows instead of asking for a context name to be typed exactly. Only context names, their namespaces and which is current are returned: a kubeconfig also holds tokens, client certificates and server addresses, and none of that belongs in a settings surface. Verified live against two clusters with no DNS range configured, where the provider previously refused to start at all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Kubernetes was unusable until the operator supplied
egress.dnsCIDRsby hand.requireKubernetesEgressrejects an empty list, so the provider reported itself unavailable before anything else was tried.That value is the cluster's own DNS service address —
10.96.0.10on kind,10.43.0.10on k3s, different again elsewhere. It is machine data the cluster will state on request, and:Change
The provider resolves the address from the
kube-systemservice labelledk8s-app=kube-dns— the selector kubeadm, kind, k3s, EKS, GKE and AKS all use. It covers both addresses of a dual-stack service and rejects a headless one.kube-system, the operator is asked, with a distinct code and a message naming what to request from their administrator. That is the one case the machine genuinely cannot answer.Egress validation moves after the environment checks: discovery needs a reachable cluster, and "the cluster is unreachable" is a more actionable answer than "the egress policy is incomplete".
Also
A read-only view of kubeconfig contexts, so a surface can offer the clusters the host already knows rather than ask for a context name to be typed exactly — kubeconfig is where the industry keeps this, and it binds cluster and namespace together.
Only context names, their namespaces, and which one is current are returned. A kubeconfig also holds tokens, client certificates and server addresses; none of that belongs in a settings surface.
Validation