Skip to content

Commit

Permalink
Add headless and wildcard DNS names to service certificate (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
idlewis authored Sep 20, 2024
1 parent 74c596c commit 58836ec
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion utils/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,22 @@ func (r *ReconcilerBase) GenerateSvcCertSecret(ba common.BaseComponent, prefix s
}

svcCert.Spec.CommonName = trimCommonName(bao.GetName(), bao.GetNamespace())
svcCert.Spec.DNSNames = make([]string, 2)
svcCert.Spec.DNSNames = make([]string, 4)
svcCert.Spec.DNSNames[0] = bao.GetName() + "." + bao.GetNamespace() + ".svc"
svcCert.Spec.DNSNames[1] = bao.GetName() + "." + bao.GetNamespace() + ".svc.cluster.local"
svcCert.Spec.DNSNames[2] = bao.GetName() + "." + bao.GetNamespace()
svcCert.Spec.DNSNames[3] = bao.GetName()
if ba.GetStatefulSet() != nil {
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, bao.GetName()+"-headless."+bao.GetNamespace()+".svc")
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, bao.GetName()+"-headless."+bao.GetNamespace()+".svc.cluster.local")
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, bao.GetName()+"-headless."+bao.GetNamespace())
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, bao.GetName()+"-headless")
// Wildcard entries for the pods
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, "*."+bao.GetName()+"-headless."+bao.GetNamespace()+".svc")
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, "*."+bao.GetName()+"-headless."+bao.GetNamespace()+".svc.cluster.local")
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, "*."+bao.GetName()+"-headless."+bao.GetNamespace())
svcCert.Spec.DNSNames = append(svcCert.Spec.DNSNames, "*."+bao.GetName()+"-headless")
}
svcCert.Spec.IsCA = false
svcCert.Spec.IssuerRef = certmanagermetav1.ObjectReference{
Name: prefix + "-ca-issuer",
Expand Down

0 comments on commit 58836ec

Please sign in to comment.