diff --git a/api/v1beta1/solrcloud_types.go b/api/v1beta1/solrcloud_types.go index 995a9acd..4ce61788 100644 --- a/api/v1beta1/solrcloud_types.go +++ b/api/v1beta1/solrcloud_types.go @@ -540,6 +540,11 @@ type ExternalAddressability struct { // +optional AdditionalDomainNames []string `json:"additionalDomainNames,omitempty"` + // Provide a custom host / dns name for the ingress resource that gets created. + // This uses the DomainName, so you only specify the actual Host in front of it. + // e.g. given.domain.name.com -> my-solr-ingress.given.domain.name.com + HostName string `json:"hostName,omitempty"` + // NodePortOverride defines the port to have all Solr node service(s) listen on and advertise itself as if advertising through an Ingress or LoadBalancer. // This overrides the default usage of the podPort. // @@ -1459,6 +1464,12 @@ func (sc *SolrCloud) ExternalCommonUrl(domainName string, withPort bool) (url st return url } +// ExternalHostNameUrl assumes we are using Ingress as the Addressability method +func (sc *SolrCloud) ExternalHostNameUrl(domainName string, withPort bool) (url string) { + url = fmt.Sprintf("%s.%s", sc.Spec.SolrAddressability.External.HostName, domainName) + return url +} + func (ea *ExternalAddressability) HasIngressTLSTermination() bool { if ea != nil && ea.Method == Ingress && ea.IngressTLSTermination != nil { return ea.IngressTLSTermination.UseDefaultTLSSecret || ea.IngressTLSTermination.TLSSecret != "" diff --git a/config/crd/bases/solr.apache.org_solrbackups.yaml b/config/crd/bases/solr.apache.org_solrbackups.yaml index 463694c4..c71ca3fd 100644 --- a/config/crd/bases/solr.apache.org_solrbackups.yaml +++ b/config/crd/bases/solr.apache.org_solrbackups.yaml @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrbackups.solr.apache.org diff --git a/config/crd/bases/solr.apache.org_solrclouds.yaml b/config/crd/bases/solr.apache.org_solrclouds.yaml index 76809b56..68348a39 100644 --- a/config/crd/bases/solr.apache.org_solrclouds.yaml +++ b/config/crd/bases/solr.apache.org_solrclouds.yaml @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrclouds.solr.apache.org @@ -9899,6 +9899,12 @@ spec: The number of services this affects could range from 1 (a headless service for ExternalDNS) to the number of Solr pods your cloud contains (individual node services for Ingress/LoadBalancer). Defaults to false. type: boolean + hostName: + description: |- + Provide a custom host / dns name for the ingress resource that gets created. + This uses the DomainName, so you only specify the actual Host in front of it. + e.g. given.domain.name.com -> my-solr-ingress.given.domain.name.com + type: string ingressTLSTermination: description: |- IngressTLSTermination tells the SolrCloud Ingress to terminate TLS on incoming connections. diff --git a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml index 766b8884..8350bfce 100644 --- a/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml +++ b/config/crd/bases/solr.apache.org_solrprometheusexporters.yaml @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrprometheusexporters.solr.apache.org diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go index 478145a5..632684ce 100644 --- a/controllers/util/solr_util.go +++ b/controllers/util/solr_util.go @@ -1169,6 +1169,13 @@ func CreateSolrIngressRules(solrCloud *solr.SolrCloud, nodeNames []string, domai } } } + if solrCloud.Spec.SolrAddressability.External.HostName != "" { + for _, domainName := range domainNames { + rule := CreateHostNameIngressRule(solrCloud, domainName) + ingressRules = append(ingressRules, rule) + allHosts = append(allHosts, rule.Host) + } + } return } @@ -1229,6 +1236,34 @@ func CreateNodeIngressRule(solrCloud *solr.SolrCloud, nodeName string, domainNam return ingressRule } +// CreateHostNameIngressRule returns a new Ingress Rule generated for a SolrCloud under the given hostName in the solrCloud instance +// solrCloud: SolrCloud instance +// domainName: string Domain for the ingress rule to use +func CreateHostNameIngressRule(solrCloud *solr.SolrCloud, domainName string) (ingressRule netv1.IngressRule) { + pathType := netv1.PathTypeImplementationSpecific + ingressRule = netv1.IngressRule{ + Host: solrCloud.ExternalHostNameUrl(domainName, false), + IngressRuleValue: netv1.IngressRuleValue{ + HTTP: &netv1.HTTPIngressRuleValue{ + Paths: []netv1.HTTPIngressPath{ + { + Backend: netv1.IngressBackend{ + Service: &netv1.IngressServiceBackend{ + Name: solrCloud.CommonServiceName(), + Port: netv1.ServiceBackendPort{ + Number: int32(solrCloud.Spec.SolrAddressability.CommonServicePort), + }, + }, + }, + PathType: &pathType, + }, + }, + }, + }, + } + return ingressRule +} + // TODO: Have this replace the postStart hook for creating the chroot func generateZKInteractionInitContainer(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCloudStatus, security *SecurityConfig) (bool, corev1.Container) { allSolrOpts := make([]string, 0) diff --git a/docs/solr-cloud/solr-cloud-crd.md b/docs/solr-cloud/solr-cloud-crd.md index 5eaf6e9d..2ce1c4dc 100644 --- a/docs/solr-cloud/solr-cloud-crd.md +++ b/docs/solr-cloud/solr-cloud-crd.md @@ -132,6 +132,7 @@ Under `SolrCloud.Spec.solrAddressability`: Currently available options are [`Ingress`](https://kubernetes.io/docs/concepts/services-networking/ingress/) and [`ExternalDNS`](https://github.com/kubernetes-sigs/external-dns). The goal is to support more methods in the future, such as LoadBalanced Services. - **`domainName`** - (Required) The primary domain name to open your cloud endpoints on. If `useExternalAddress` is set to `true`, then this is the domain that will be used in Solr Node names. + - **`hostName`** - (Optional) Provide a custom host / dns name for the ingress resource that gets created. This uses the `domainName`, so you only specify the actual Host in front of it, e.g. k8s.solr.cloud -> solr-ingress.k8s.solr.cloud - **`additionalDomainNames`** - You can choose to listen on additional domains for each endpoint, however Solr will not register itself under these names. - **`useExternalAddress`** - Use the external address to advertise the SolrNode. If a domain name is required for the chosen external `method`, then the one provided in `domainName` will be used. \ This can not be set to `true` when **`hideNodes`** is set to `true` or **`ingressTLSTermination`** is used. diff --git a/helm/solr-operator/crds/crds.yaml b/helm/solr-operator/crds/crds.yaml index a1229dcf..f92c369b 100644 --- a/helm/solr-operator/crds/crds.yaml +++ b/helm/solr-operator/crds/crds.yaml @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrbackups.solr.apache.org @@ -275,7 +275,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrclouds.solr.apache.org @@ -10157,6 +10157,12 @@ spec: The number of services this affects could range from 1 (a headless service for ExternalDNS) to the number of Solr pods your cloud contains (individual node services for Ingress/LoadBalancer). Defaults to false. type: boolean + hostName: + description: |- + Provide a custom host / dns name for the ingress resource that gets created. + This uses the DomainName, so you only specify the actual Host in front of it. + e.g. given.domain.name.com -> my-solr-ingress.given.domain.name.com + type: string ingressTLSTermination: description: |- IngressTLSTermination tells the SolrCloud Ingress to terminate TLS on incoming connections. @@ -17870,7 +17876,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - operator.solr.apache.org/version: v0.10.0-prerelease + operator.solr.apache.org/version: v0.11.0-prerelease argocd.argoproj.io/sync-options: Replace=true controller-gen.kubebuilder.io/version: v0.16.4 name: solrprometheusexporters.solr.apache.org diff --git a/tests/scripts/manage_e2e_tests.sh b/tests/scripts/manage_e2e_tests.sh index c42b92fb..73f03aa0 100755 --- a/tests/scripts/manage_e2e_tests.sh +++ b/tests/scripts/manage_e2e_tests.sh @@ -81,7 +81,8 @@ fi if [[ "${SOLR_IMAGE}" != *":"* ]]; then SOLR_IMAGE="solr:${SOLR_IMAGE}" fi -IFS=$'\036'; RAW_GINKGO=(${RAW_GINKGO:-}); unset IFS +#IFS=$'\036'; RAW_GINKGO=(${RAW_GINKGO:-}); unset IFS +IFS=$'\036'; RAW_GINKGO=(${RAW_GINKGO[@]:-()}); unset IFS CLUSTER_NAME="$(echo "solr-op-e2e-${OPERATOR_IMAGE##*:}-k-${KUBERNETES_VERSION}-s-${SOLR_IMAGE##*:}" | tr '[:upper:]' '[:lower:]' | sed "s/snapshot/snap/" | sed "s/prerelease/pre/")" export CLUSTER_NAME diff --git a/version/version.go b/version/version.go index 710de53c..5a69843a 100644 --- a/version/version.go +++ b/version/version.go @@ -19,7 +19,7 @@ package version var ( // Version information for the Solr Operator - Version = "v0.10.0" + Version = "v0.11.0" VersionSuffix = "prerelease" BuildTime string GitSHA string