-
Notifications
You must be signed in to change notification settings - Fork 1.2k
draft: Validate naming of Kubernetes clusters #10778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.19
Are you sure you want to change the base?
draft: Validate naming of Kubernetes clusters #10778
Conversation
@blueorangutan package |
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.19 #10778 +/- ##
=========================================
Coverage 15.16% 15.17%
- Complexity 11332 11336 +4
=========================================
Files 5412 5412
Lines 475033 475041 +8
Branches 57963 57962 -1
=========================================
+ Hits 72048 72068 +20
+ Misses 394930 394916 -14
- Partials 8055 8057 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
good idea. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13185 |
@weizhouapache yes, this approach would be much better from a UX perspective. I'll mark this PR as draft while I refactor it. |
Description
Kubernetes has naming conventions for some type of resources. It requires, for instance, that some of them must:
-
;More information regarding Kubernetes naming constraints can be found on its Object Names and IDs documentation section.
Apache CloudStack names the control and worker cluster nodes using the following format:
<cluster-name> + <"control" | "node"> + <hash>
. When generating the names of the nodes, firstly, the cluster name is normalized, in order to meet the Kubernetes naming requirements:cloudstack/plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/actionworkers/KubernetesClusterResourceModifierActionWorker.java
Lines 775 to 788 in 55c8138
However, not all required normalization operations are performed. When a Kubernetes cluster contains uppercase letters in its name, for instance, the static method
NetUtils.verifyDomainLabel
returnstrue
(it verifies the domain name label in a case-insensitive manner). Thus, the uppercase letters are not removed from the string (prefix.replaceAll("[^a-zA-Z0-9-]", "")
is not executed) and the Kubernetes nodes end up with names containing uppercase letters. As a consequence of that, some inconsistencies when consuming the Kubernetes services are faced, because Kubernetes is not able to properly identify its nodes.This PR proposes to restrict users from creating Kubernetes clusters whose names do not meet the following criteria:
-
;The length requirement is defined as 43, because, in the worst case scenario, the node names will contain 43 characters (cluster name) + 9 characters (
-control-
) + 11 characters (hash), resulting in 63 characters in total.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?