Repository navigation
CKS: set control plane, etcd and kubelet options at create time - #14783
bhouse-nexthop wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14783 +/- ##
============================================
+ Coverage 20.80% 20.95% +0.14%
- Complexity 20919 21205 +286
============================================
Files 6053 6058 +5
Lines 548451 549902 +1451
Branches 78719 73532 -5187
============================================
+ Hits 114128 115216 +1088
- Misses 420958 421221 +263
- Partials 13365 13465 +100
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:
|
2fedbba to
39786ab
Compare
39786ab to
43d5967
Compare
createKubernetesCluster gains six optional parameters: | parameter | type | used for | |---|---|---| | apiserverargs | map | kube-apiserver flags, e.g. OIDC (oidc-issuer-url, oidc-client-id, ...) | | etcdargs | map | etcd flags, e.g. heartbeat-interval, election-timeout | | controllermanagerargs | map | kube-controller-manager flags, e.g. leader-elect-lease-duration | | schedulerargs | map | kube-scheduler flags, e.g. leader-elect-lease-duration | | kubeletconfig | JSON object | KubeletConfiguration fields, e.g. systemReserved, kubeReserved, evictionHard | | auditpolicy | string | audit Policy document; turns on audit logging | - Stored in kubernetes_cluster_details and returned in the cluster response. No schema change. - Rendered into the kubeadm init config (ClusterConfiguration apiServer, controllerManager, scheduler and etcd.local extraArgs, apiServer extraVolumes, plus a KubeletConfiguration document), not into shell flags. - With external etcd nodes, etcdargs are added to the etcd service on those nodes instead. - kubeadm uploads the ClusterConfiguration and the kubelet config to the cluster, so nodes that join later (scale, HA control nodes) get the same settings. The audit policy file is also written on the extra control nodes. - Audit logs go to /var/log/kubernetes/audit with rotation defaults (maxage 30, maxbackup 3, maxsize 100 MB) that apiserverargs can override. The policy is written gzip+base64 encoded. - kubeadm config is now built in Java for both the external etcd and the stacked case, as kubeadm.k8s.io/v1beta3 (extraArgs as a map), or v1beta4 (extraArgs as a name/value list) for Kubernetes 1.31+. The stacked case keeps the old flag based kubeadm init unless one of the new parameters is set. - Validation: flag names [a-z0-9-], values and kubelet strings limited to a plain character set (no spaces, quotes, braces), flags and kubelet fields CloudStack or kubeadm rely on reserved per component (kube-apiserver secure-port, etcd-servers, anonymous-auth, audit-policy-file, proxy-client-*, requestheader-*; etcd name, initial-cluster, data-dir, wal-dir, the URL and TLS flags; controller-manager and scheduler kubeconfig, bind-address, secure-port, leader-elect, controllers, config; kubelet cgroupDriver, clusterDNS, ...), NodeRestriction kept in enable-admission-plugins, Kubernetes 1.22+, rejected for ExternalManaged clusters, duplicate flags rejected. - kubeadm-config.yaml is now 0600: it holds the bootstrap token and certificate key. - The API server certificate lists the control node's own IP as well as the public IP, and with external etcd the control node advertises its own IP (as kubeadm does for stacked etcd). The public IP stays the controlPlaneEndpoint. - UI: in advanced mode the create cluster form has kube-apiserver, etcd, kube-controller-manager and kube-scheduler arguments (one name=value per line), kubelet configuration and audit policy fields; the cluster details tab shows them. Signed-off-by: Brad House <bhouse@nexthop.ai>
43d5967 to
9914316
Compare
|
Extended this PR: Test report: a management server built from main plus this change, KVM, advanced zone, Ceph RBD primary storage, Kubernetes 1.33.1 (kubeadm v1beta4). Both clusters were created through the UI form, with etcd
|
Description
createKubernetesCluster gains six optional parameters:
apiserverargsoidc-issuer-url,oidc-client-id, ...)etcdargsheartbeat-interval,election-timeoutcontrollermanagerargsleader-elect-lease-duration,leader-elect-renew-deadline,leader-elect-retry-periodschedulerargskubeletconfigsystemReserved,kubeReserved,evictionHardauditpolicykubernetes_cluster_detailsand returned in the cluster response. No schema change.kubeadm.k8s.io/v1beta3, or v1beta4 for Kubernetes 1.31+.apiServer,controllerManager,schedulerandetcd.localextraArgs(a map in v1beta3, a name/value list in v1beta4),apiServer.extraVolumes, plus a KubeletConfiguration document, not into shell flags.etcdargsare added to the etcd service on those nodes instead.kubeadm initunless one of the new parameters is set./var/log/kubernetes/auditwith rotation defaults (maxage 30, maxbackup 3, maxsize 100 MB) thatapiserverargscan override.[a-z0-9-]. Values and kubelet strings are limited to a plain character set (no spaces, quotes or braces).secure-port,etcd-servers,anonymous-auth,audit-policy-file,proxy-client-*,requestheader-*; etcdname,data-dir,wal-dir,initial-cluster*and the URL and TLS flags; controller-manager and schedulerkubeconfig,bind-address,secure-port,leader-elect,master,controllers,config; kubeletcgroupDriver,clusterDNS,staticPodURL.NodeRestrictionstays inenable-admission-plugins.kubeadm-config.yamlis now 0600, since it holds the bootstrap token and certificate key.certSANs(and--apiserver-cert-extra-sansin the flag path) list the control node's own IP next to the public IP. With external etcd,advertiseAddressis the control node's own IP, as kubeadm already picks for stacked etcd. The public IP stays thecontrolPlaneEndpoint, so kubeconfig is unchanged.name=valueper line; leading dashes are stripped), kubelet configuration (JSON) and audit policy fields. The cluster details tab shows the six values.A use for the new ones: a cluster on network storage can ride out a short storage stall (e.g. a disk failing in the storage cluster) with longer etcd and leader election timeouts, instead of failing over etcd leaders and restarting controllers.
Fixes #14782
Types of changes
How Has This Been Tested?
Unit tests: 173 in the kubernetes-service module, 42 of them in
KubeadmConfigBuilderTest(v1beta3/v1beta4 output, stacked and external etcd, the etcd service flags, validation and reserved names per component) and 3 inCreateKubernetesClusterCmdTest.First version (apiserverargs, kubeletconfig, auditpolicy), KVM lab (build that also carried other pending CKS changes), Kubernetes v1.33.13, HA cluster (2 control + 1 worker) created with OIDC
apiserverargs, akubeletconfigwithsystemReservedandevictionHard, and a Metadata-levelauditpolicy:--oidc-issuer-url,--oidc-client-id,--audit-policy-file,--audit-log-*defaults,--enable-admission-plugins=NodeRestriction/var/log/kubernetes/audit/audit.logwritten, Metadata-level events/var/lib/kubelet/config.yamlsystemReservedandevictionHardas givenkubeadm-config.yamlUI:
npm run lintclean;tests/unit/components/viewandtests/unit/views/computeunit tests pass.