Choose a Kubernetes naming rule before cleaning a batch
Admin ·
Choose the rule for the field you plan to set. The same candidate can keep dots under Kubernetes' DNS subdomain rule and require a single label under other rules.
Kubernetes Resource Name Sanitizer
Compare one candidate under each DNS profile
Select Load example, choose DNS subdomain and select Sanitize names. The first line turns 9.Métrics_API-- into 9.metrics-api. The DNS subdomain profile retains the separator between the initial 9 and the remaining name.
Repeat the check with DNS 1123 label and DNS 1035 label. The label form replaces the dot, and DNS 1035 adds x- to the digit-leading result. The results list the transformations so you can decide whether to keep the candidate.
| Profile | Suggested name | Limit |
|---|---|---|
| DNS subdomain | 9.metrics-api | 253 characters |
| DNS 1123 label | 9-metrics-api | 63 characters |
| DNS 1035 label | x-9-metrics-api | 63 characters |
Kubernetes object names and IDsKubernetes apimachinery v0.35 DNS validation functions
Check Service naming against the target setup
The generic DNS 1123 label function permits a starting digit. Kubernetes v1.35's Service creation path uses the DNS 1035 default validator and selects DNS 1123 label validation when RelaxedServiceNameValidation is enabled.
Choose the profile for your resource and version, then review the candidate against any additional rules for that field. A valid syntax result says the candidate fits the selected character and length rules.
Kubernetes object names and IDsKubernetes apimachinery v0.35 DNS validation functionsKubernetes v1.35 Service creation validation
Resolve names that produce the same suggestion
Replace the example with Team Ops on one line and team_ops on the next. Both produce team-ops. Change the inputs to include meaningful qualifiers and rerun the check.
Once every line has a different candidate, download kubernetes-names.txt. Compare the suggestions to the intended objects before setting metadata.name. The matches in this browser cover the supplied list.
Common questions
What if the tool cannot produce a candidate?
If punctuation, emoji or letters outside the supported output alphabet leave no ASCII letters or digits after normalization, enter a meaningful ASCII name.
Does the DNS subdomain profile check DNS availability?
The profile checks the name against Kubernetes' generic syntax and total character limit. DNS registration, object existence and namespace policies use separate checks.
Sources
Put it into practice.
- Kubernetes Resource Name Sanitizer
- Kubernetes Label and Annotation Validator
- Text to Slug
- DNS response reader