Allow trailing dot for service.spec.externalName

This commit is contained in:
Tobias Hintze
2019-05-24 17:32:38 +02:00
parent da31c50da1
commit 8829efaeb0
2 changed files with 14 additions and 2 deletions

View File

@@ -3692,8 +3692,11 @@ func ValidateService(service *core.Service) field.ErrorList {
if service.Spec.ClusterIP != "" {
allErrs = append(allErrs, field.Forbidden(specPath.Child("clusterIP"), "must be empty for ExternalName services"))
}
if len(service.Spec.ExternalName) > 0 {
allErrs = append(allErrs, ValidateDNS1123Subdomain(service.Spec.ExternalName, specPath.Child("externalName"))...)
// The value (a CNAME) may have a trailing dot to denote it as fully qualified
cname := strings.TrimSuffix(service.Spec.ExternalName, ".")
if len(cname) > 0 {
allErrs = append(allErrs, ValidateDNS1123Subdomain(cname, specPath.Child("externalName"))...)
} else {
allErrs = append(allErrs, field.Required(specPath.Child("externalName"), ""))
}