bhouse-nexthop opened a new pull request, #14904: URL: https://github.com/apache/cloudstack/pull/14904
### 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-verify` or re-issuing the certificate by hand on every control node. `createKubernetesCluster` takes a new parameter, `apiserversans`: a comma-separated list of DNS names and IP addresses to add to the certificate. ``` create kubernetescluster name=prod ... apiserversans=k8s.example.com,198.51.100.7 ``` | | Before | After | |---|---|---| | `kubeadm init` (stacked etcd) | `--apiserver-cert-extra-sans=<public IP>` | `--apiserver-cert-extra-sans=<public IP>,k8s.example.com,198.51.100.7` | | `kubeadm-config.yaml` `certSANs` (external etcd) | `<public IP>` | `<public IP>`, `k8s.example.com`, `198.51.100.7` | | `listKubernetesClusters` | | `"apiserversans": ["k8s.example.com", "198.51.100.7"]` | - Each entry must be an IP address or a DNS name as kubeadm accepts it (lower-case RFC 1123 subdomain). Entries are trimmed and lower-cased; anything else is refused before the cluster is created, with `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. - The list is stored as a cluster detail, so there is no schema change. - kubeadm stores the SANs in the cluster's `kubeadm-config` ConfigMap, so control nodes that join later get them. `kubeadm certs renew` and upgrades keep them, because kubeadm renews from the existing certificate. - The UI's create form has a text field for it, and the cluster's details tab shows it. - The kubeconfig CloudStack returns still points at the public IP; a client that uses another name sets `server:` (or `--tls-server-name`) itself. - The list can not be changed after creation. That needs the certificate re-issued on every control node, and is not part of this PR. - ExternalManaged clusters refuse the parameter, since CloudStack does not issue their certificates. This touches the same lines in `KubernetesClusterStartWorker` as #14769 (4.22) and #14783; whichever is merged second adds the extra SANs to the address list there. Fixes: #14903 ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [x] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] Build/CI - [ ] Test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [ ] Major - [x] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [ ] Minor - [ ] Trivial ### 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 with `apiserversans` is refused. - `KubernetesClusterStartWorkerTest`: renders the real `k8s-control-node.yml` and checks the SANs in both the `kubeadm init` arguments 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? - Values YAML or the shell would misread (`*` starts a YAML alias and is a shell glob) are refused by the validation, and the kubeadm config quotes every entry. - Without the parameter the rendered config is the same as before, apart from the quotes around the public IP in `certSANs`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
