Repository navigation
Add extra API server certificate names to CKS clusters at creation - #14904
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
The API server certificate of a CKS cluster covers only the control node IP and the cluster's public or external load balancer IP. Clients that reach the cluster through a DNS name in front of the load balancer, a VIP or a NAT address fail TLS verification. createKubernetesCluster takes apiserversans, a list of DNS names and IP addresses. CKS validates them, stores them as a cluster detail and adds them to kubeadm init (--apiserver-cert-extra-sans, or certSANs in the kubeadm config with external etcd). kubeadm keeps them in the cluster configuration, so control nodes that join later and kubeadm certs renew keep them too. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14904 +/- ##
============================================
+ Coverage 3.86% 20.94% +17.08%
- Complexity 0 21170 +21170
============================================
Files 494 6057 +5563
Lines 42888 549600 +506712
Branches 8141 73485 +65344
============================================
+ Hits 1657 115139 +113482
- Misses 40999 421003 +380004
- Partials 232 13458 +13226
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
Tested on a KVM lab running a main (24.0) build that includes this change. Primary storage is Ceph RBD, CKS clusters on Kubernetes 1.33.1. Each cluster was created with
Both clusters were deleted afterwards. Not tested: the UI create field and details row. |
This branch has not been deployed
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.
Description
The API server certificate of a CKS cluster covers only the addresses CloudStack knows: the cluster's public (or external load balancer) IP, plus the control node IP that kubeadm adds. A client that reaches the cluster through a DNS name in front of the load balancer, a VIP or a NAT address fails TLS verification, and the only way out is
insecure-skip-tls-verifyor re-issuing the certificate by hand on every control node.createKubernetesClustertakes a new parameter,apiserversans: a comma-separated list of DNS names and IP addresses to add to the certificate.kubeadm init(stacked etcd)--apiserver-cert-extra-sans=<public IP>--apiserver-cert-extra-sans=<public IP>,k8s.example.com,198.51.100.7kubeadm-config.yamlcertSANs(external etcd)<public IP><public IP>,k8s.example.com,198.51.100.7listKubernetesClusters"apiserversans": ["k8s.example.com", "198.51.100.7"]Invalid apiserversans entry '<entry>': give a DNS name or an IP address. A name whose last label is all digits (203.0.113.256) is refused as a mistyped IP address. Wildcards are not accepted.kubeadm-configConfigMap, so control nodes that join later get them.kubeadm certs renewand upgrades keep them, because kubeadm renews from the existing certificate.server:(or--tls-server-name) itself.This touches the same lines in
KubernetesClusterStartWorkeras #14769 (4.22) and #14783; whichever is merged second adds the extra SANs to the address list there.Fixes: #14903
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Unit tests,
mvn test -pl plugins/integrations/kubernetes-service -am -Dtest='Kubernetes*Test': 137 passed, 0 failed.KubernetesClusterUtilTest: DNS names and IPv4/IPv6 addresses are accepted, trimmed and lower-cased; empty entries, underscores, leading hyphens, trailing dots, empty labels, wildcards, URLs, names over 253 characters and mistyped IPv4 addresses are refused.KubernetesClusterManagerImplTest: an ExternalManaged create withapiserversansis refused.KubernetesClusterStartWorkerTest: renders the realk8s-control-node.ymland checks the SANs in both thekubeadm initarguments and the kubeadm config, with and without extra SANs.Not yet tested on a live cluster; a lab report will follow.
How did you try to break this feature and the system with this change?
*starts a YAML alias and is a shell glob) are refused by the validation, and the kubeadm config quotes every entry.certSANs.