in controllers/util/solr_util.go [1060:1138]
func GenerateIngress(solrCloud *solr.SolrCloud, nodeNames []string) (ingress *netv1.Ingress) {
labels := solrCloud.SharedLabelsWith(solrCloud.GetLabels())
var annotations map[string]string
customOptions := solrCloud.Spec.CustomSolrKubeOptions.IngressOptions
if nil != customOptions {
labels = MergeLabelsOrAnnotations(labels, customOptions.Labels)
annotations = MergeLabelsOrAnnotations(annotations, customOptions.Annotations)
}
extOpts := solrCloud.Spec.SolrAddressability.External
// Create advertised domain name and possible additional domain names'
allDomains := append([]string{extOpts.DomainName}, extOpts.AdditionalDomainNames...)
rules, allHosts := CreateSolrIngressRules(solrCloud, nodeNames, allDomains)
var ingressTLS []netv1.IngressTLS
if solrCloud.Spec.SolrTLS != nil && solrCloud.Spec.SolrTLS.PKCS12Secret != nil {
ingressTLS = append(ingressTLS, netv1.IngressTLS{SecretName: solrCloud.Spec.SolrTLS.PKCS12Secret.Name})
} // else if using mountedTLSDir, it's likely they'll have an auto-wired TLS solution for Ingress as well via annotations
if extOpts.HasIngressTLSTermination() {
newIngressTLS := netv1.IngressTLS{
Hosts: allHosts,
}
if extOpts.IngressTLSTermination.TLSSecret != "" {
newIngressTLS.SecretName = extOpts.IngressTLSTermination.TLSSecret
}
ingressTLS = append(ingressTLS, newIngressTLS)
}
solrNodesRequireTLS := solrCloud.Spec.SolrTLS != nil
ingressFrontedByTLS := len(ingressTLS) > 0
// TLS Passthrough annotations
if solrNodesRequireTLS {
if annotations == nil {
annotations = make(map[string]string, 1)
}
_, ok := annotations["nginx.ingress.kubernetes.io/backend-protocol"]
if !ok {
annotations["nginx.ingress.kubernetes.io/backend-protocol"] = "HTTPS"
}
} else {
if annotations == nil {
annotations = make(map[string]string, 1)
}
_, ok := annotations["nginx.ingress.kubernetes.io/backend-protocol"]
if !ok {
annotations["nginx.ingress.kubernetes.io/backend-protocol"] = "HTTP"
}
}
// TLS Accept annotations
if ingressFrontedByTLS {
_, ok := annotations["nginx.ingress.kubernetes.io/ssl-redirect"]
if !ok {
annotations["nginx.ingress.kubernetes.io/ssl-redirect"] = "true"
}
}
ingress = &netv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: solrCloud.CommonIngressName(),
Namespace: solrCloud.GetNamespace(),
Labels: labels,
Annotations: annotations,
},
Spec: netv1.IngressSpec{
Rules: rules,
TLS: ingressTLS,
},
}
if nil != customOptions && customOptions.IngressClassName != nil {
ingress.Spec.IngressClassName = customOptions.IngressClassName
}
return ingress
}