feat: allow overriding kubelet kubeconfig tls-server-name when KubePrism is enabled#13425
Closed
IvanHunters wants to merge 1 commit into
Closed
feat: allow overriding kubelet kubeconfig tls-server-name when KubePrism is enabled#13425IvanHunters wants to merge 1 commit into
IvanHunters wants to merge 1 commit into
Conversation
IvanHunters
force-pushed
the
feat/kubeprism-tls-server-name
branch
from
May 24, 2026 12:54
7470709 to
f2a6763
Compare
… KubePrism Add an optional `tlsServerName` field to `machine.features.kubePrism`. When set, the generated kubelet kubeconfig carries `clusters[0].cluster.tls-server-name` set to that value, so the kubelet uses it for SNI and certificate hostname verification while still dialing `https://127.0.0.1:<kubePrismPort>` as the TCP destination. Without this knob, the endpoint in the kubelet kubeconfig is hardcoded to `https://127.0.0.1:<port>` (see `internal/app/machined/pkg/controllers/secrets/kubelet.go`), which forces SNI=`127.0.0.1` over the proxied connection. In setups where KubePrism's upstream apiserver is reached through an SNI-routing L4 proxy (for example nginx-ingress in ssl-passthrough mode in front of a Kamaji-hosted apiserver), SNI=`127.0.0.1` does not match any route and the proxy serves a fallback certificate, so the kubelet rejects the connection with `cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs`. Setting `tls-server-name` in the kubeconfig is the Kubernetes-native way to decouple the TCP destination from the TLS SNI/hostname check, and matches how kubeconfigs already support this field. When the field is empty (default), behavior is unchanged. Refs siderolabs#13424 Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
IvanHunters
force-pushed
the
feat/kubeprism-tls-server-name
branch
from
May 24, 2026 12:54
f2a6763 to
13b3d38
Compare
|
This PR is stale because it has been open 45 days with no activity. |
smira
added a commit
to smira/talos
that referenced
this pull request
Jul 21, 2026
Mostly one-to-one translation, but it also incorporates work from the PR siderolabs#13425 to add support for TLSServerName. Fixes siderolabs#13424 Fixes siderolabs#13777 Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Jul 21, 2026
Mostly one-to-one translation, but it also incorporates work from the PR siderolabs#13425 to add support for TLSServerName. Fixes siderolabs#13424 Fixes siderolabs#13777 Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
Member
|
Merged into #13820, thank you! |
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.
Pull Request
Refs #13424
What? (description)
Add a new optional field
tlsServerNameto the KubePrism feature config:When set, the generated kubelet kubeconfig carries
clusters[0].cluster.tls-server-nameset to that value, so the kubelet uses it for SNI and certificate hostname verification. KubePrism keeps binding to127.0.0.1:<port>and the kubelet keeps dialinghttps://127.0.0.1:<port>as the TCP destination. Only the TLS SNI/hostname that the kubelet sends and verifies against is decoupled from the TCP target.When the field is empty (default), behavior is unchanged.
Why? (reasoning)
In
internal/app/machined/pkg/controllers/secrets/kubelet.gothe endpoint is hardcoded:This forces SNI=
127.0.0.1over the proxied connection. In setups where KubePrism's upstream is reached through an SNI-routing L4 proxy (for example nginx-ingress inssl-passthroughmode in front of a Kamaji-hosted apiserver), SNI=127.0.0.1does not match any ingress route and the proxy serves a fallback certificate without IP SANs, so the kubelet rejects with:Setting
tls-server-namein the kubeconfig makes Go'stls.Config.ServerName(and therefore SNI) be the configured value, while the TCP destination stays loopback. This is the natural Kubernetes-native way to decouple the two, and aligns with how kubeconfigs already support this field.Changes
tlsServerNamefield onKubePrisminpkg/machinery/config/types/v1alpha1.TLSServerName() stringmethod on theconfig.KubePrismprovider interface.EndpointTLSServerNamefield onsecrets.KubeletSpecresource (protobuf id6,omitempty), so the kubeconfig writer has access to the value.secrets.KubeletControllerpopulatesEndpointTLSServerNamefrom the KubePrism config when KubePrism is enabled, and leaves it empty otherwise.k8s.KubeletServiceController.writePKIsetscluster.TLSServerNameon the bootstrap kubeconfig.k8s.KubeletServiceController.updateKubeconfigsetscluster.TLSServerNamewhen refreshing the kubelet runtime kubeconfig.v1alpha1_types_doc.goand updated the website config reference forv1.14.Acceptance
Please use the following checklist:
make conformance)make fmt)make lint)make docs)make unit-tests)Notes on the unchecked items:
make conformanceandmake lintgo through the project's Docker/buildkit pipeline and were not run locally; CI will exercise them.go test ./pkg/machinery/config/...passes; secrets/k8s controllers compile cleanly withGOOS=linux).TestReconcileKubePrismTLSServerNameininternal/app/machined/pkg/controllers/secrets/kubelet_test.goasserts thatEndpointTLSServerNameis propagated when configured.Test plan
machine.features.kubePrism.tlsServerNameto the apiserver's hostname./etc/kubernetes/kubelet.confand/etc/kubernetes/bootstrap-kubeconfigcontaintls-server-name: <hostname>under the cluster entry.tlsServerNameunset produces an unchanged kubeconfig (notls-server-namekey) and behaves identically to current Talos.