From 3cb870bd4d170390de829683ff4649f37e3a5658 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 16 Dec 2024 11:08:33 -0500 Subject: [PATCH 1/4] doc(volumes): add docs for attaching additional volumes --- docs/solr-cloud/solr-cloud-crd.md | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/docs/solr-cloud/solr-cloud-crd.md b/docs/solr-cloud/solr-cloud-crd.md index c1053cd1..66cfded6 100644 --- a/docs/solr-cloud/solr-cloud-crd.md +++ b/docs/solr-cloud/solr-cloud-crd.md @@ -71,6 +71,62 @@ These options can be found in `SolrCloud.spec.dataStorage` - **`emptyDir`** - An [`emptyDir` volume source](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) that describes the desired emptyDir volume to use in each SolrCloud pod to store data. - **`hostPath`** - A [`hostPath` volume source](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that describes the desired hostPath volume to use in each SolrCloud pod to store data. + +### Mounting Additional Volumes + +It is also possible to mount additional volumes to the SolrCloud (or its initContainers). Some example scenarios where you might use this would be: +- Custom solr plugins that rely on certain data to be present on disk +- Bootstrapping additional configuration for Solr via a ConfigMap +- A dedicated volume to support backups + +Below is an example of the last scenario: + +```yaml +apiVersion: solr.apache.org/v1beta1 +kind: SolrCloud +metadata: + name: test + namespace: test +spec: + replicas: 1 + customSolrKubeOptions: + podOptions: + volumes: + - source: + persistentVolumeClaim: + claimName: backup-data-pvc + name: backup-data + defaultContainerMount: + mountPath: /var/solr/data/backup + name: backup-data + initContainers: + - name: chmod-backup + image: busybox:1.28.0-glibc + command: + - "chmod" + - "-R" + - "766" + - "/var/solr/data/backup" + volumeMounts: + - name: backup-data + mountPath: /var/solr/data/backup + +--- +# Volume itself provisioned elsewhere +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: backup-data-pvc + namespace: test +spec: + storageClassName: "" # Implementation specific + volumeName: backup-data + accessModes: + - ReadWriteMany +``` + +Note the `source` spec may change based on the implementation. In this case, the `persisentVolumeClaim` spec requires field `claimName`. + ## Update Strategy _Since v0.2.7_ From 9d4cfcbe4a2c1340c7827bd483a528a4775303d7 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 6 Jan 2025 10:58:04 -0500 Subject: [PATCH 2/4] move additional volume doc to examples --- docs/solr-cloud/solr-cloud-crd.md | 56 ------------------- example/test_solrcloud_additional_volume.yaml | 52 +++++++++++++++++ 2 files changed, 52 insertions(+), 56 deletions(-) create mode 100644 example/test_solrcloud_additional_volume.yaml diff --git a/docs/solr-cloud/solr-cloud-crd.md b/docs/solr-cloud/solr-cloud-crd.md index 66cfded6..c1053cd1 100644 --- a/docs/solr-cloud/solr-cloud-crd.md +++ b/docs/solr-cloud/solr-cloud-crd.md @@ -71,62 +71,6 @@ These options can be found in `SolrCloud.spec.dataStorage` - **`emptyDir`** - An [`emptyDir` volume source](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) that describes the desired emptyDir volume to use in each SolrCloud pod to store data. - **`hostPath`** - A [`hostPath` volume source](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath) that describes the desired hostPath volume to use in each SolrCloud pod to store data. - -### Mounting Additional Volumes - -It is also possible to mount additional volumes to the SolrCloud (or its initContainers). Some example scenarios where you might use this would be: -- Custom solr plugins that rely on certain data to be present on disk -- Bootstrapping additional configuration for Solr via a ConfigMap -- A dedicated volume to support backups - -Below is an example of the last scenario: - -```yaml -apiVersion: solr.apache.org/v1beta1 -kind: SolrCloud -metadata: - name: test - namespace: test -spec: - replicas: 1 - customSolrKubeOptions: - podOptions: - volumes: - - source: - persistentVolumeClaim: - claimName: backup-data-pvc - name: backup-data - defaultContainerMount: - mountPath: /var/solr/data/backup - name: backup-data - initContainers: - - name: chmod-backup - image: busybox:1.28.0-glibc - command: - - "chmod" - - "-R" - - "766" - - "/var/solr/data/backup" - volumeMounts: - - name: backup-data - mountPath: /var/solr/data/backup - ---- -# Volume itself provisioned elsewhere -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: backup-data-pvc - namespace: test -spec: - storageClassName: "" # Implementation specific - volumeName: backup-data - accessModes: - - ReadWriteMany -``` - -Note the `source` spec may change based on the implementation. In this case, the `persisentVolumeClaim` spec requires field `claimName`. - ## Update Strategy _Since v0.2.7_ diff --git a/example/test_solrcloud_additional_volume.yaml b/example/test_solrcloud_additional_volume.yaml new file mode 100644 index 00000000..a33dba3e --- /dev/null +++ b/example/test_solrcloud_additional_volume.yaml @@ -0,0 +1,52 @@ +# Mounting Additional Volumes +# +# It is also possible to mount additional volumes to the SolrCloud (or its initContainers). Some example scenarios where you might use this would be: +# - Custom solr plugins that rely on certain data to be present on disk +# - Bootstrapping additional configuration for Solr via a ConfigMap +# +# Below is an example of the last scenario: + +apiVersion: solr.apache.org/v1beta1 +kind: SolrCloud +metadata: + name: test + namespace: test +spec: + replicas: 1 + customSolrKubeOptions: + podOptions: + volumes: + - source: + configMap: + name: configset + defaultMode: 0777 + name: configset + defaultContainerMount: + mountPath: /configset + name: configset + sidecarContainers: + - name: config-loader + image: alpine/curl:latest + command: + - "sh" + - "-c" + - "ls -la /configset" + volumeMounts: + - name: configset + mountPath: /configset + +# Note the `source` spec may change based on the implementation. In this case, the `configMap` spec requires field `name`. +# See volume spec in CRD: https://github.com/apache/solr-operator/blob/main/config/crd/bases/solr.apache.org_solrclouds.yaml#L6800 + +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: configset + namespace: test +data: + config.xml: | + + + ... + \ No newline at end of file From ddfe64f1b7de79420bc5ab4291cb723cd2a6b0b8 Mon Sep 17 00:00:00 2001 From: Houston Putman Date: Wed, 24 Jun 2026 13:13:22 -0700 Subject: [PATCH 3/4] Make documentation page --- docs/modules/solr-cloud/nav.adoc | 1 + .../solr-cloud/pages/custom-kube-options.adoc | 69 +++++++++++++++++++ .../solr-cloud/pages/solr-cloud-crd.adoc | 1 + 3 files changed, 71 insertions(+) create mode 100644 docs/modules/solr-cloud/pages/custom-kube-options.adoc diff --git a/docs/modules/solr-cloud/nav.adoc b/docs/modules/solr-cloud/nav.adoc index 44ca7bf5..c16f8a12 100644 --- a/docs/modules/solr-cloud/nav.adoc +++ b/docs/modules/solr-cloud/nav.adoc @@ -23,6 +23,7 @@ ** xref:custom-solr-config.adoc[Custom Solr Configuration] ** xref:tls.adoc[] ** xref:authentication-and-authorization.adoc[] +** xref:custom-kube-options.adoc[] * xref:cluster-operations.adoc[] * xref:managed-updates.adoc[] * xref:scaling.adoc[] diff --git a/docs/modules/solr-cloud/pages/custom-kube-options.adoc b/docs/modules/solr-cloud/pages/custom-kube-options.adoc new file mode 100644 index 00000000..97dc6d96 --- /dev/null +++ b/docs/modules/solr-cloud/pages/custom-kube-options.adoc @@ -0,0 +1,69 @@ += Customizing Resources +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +The Solr Operator creates a number of Kubernetes resources to run a SolrCloud (StatefulSet, Services, ConfigMap, etc.). +Most aspects of these resources can be customized through `SolrCloud.spec.customSolrKubeOptions`, which exposes per-resource option objects such as `podOptions`, `statefulSetOptions`, `commonServiceOptions`, and others. +This allows you to add labels, annotations, environment variables, affinity rules, resource requests, extra containers, and more, without the operator needing explicit support for every option. + +== Mounting Additional Volumes + +Arbitrary additional volumes can be mounted into the Solr pods (and their init/sidecar containers) via `SolrCloud.spec.customSolrKubeOptions.podOptions.volumes`. +This is separate from the xref:solr-cloud-crd.adoc#data-storage[data storage] used for Solr's index data. +Some example scenarios where this is useful: + +* Custom Solr plugins that rely on certain data being present on disk. +* Bootstrapping additional configuration for Solr via a `ConfigMap`. +* A dedicated volume to support backups. + +Each entry under `volumes` has the following fields: + +* **`name`** - The name of the volume, used to reference it from container `volumeMounts`. +* **`source`** - A standard Kubernetes https://kubernetes.io/docs/concepts/storage/volumes/#volume-types[volume source] (e.g. `configMap`, `persistentVolumeClaim`, `secret`, `emptyDir`). +The required fields depend on the source type chosen (for example, a `configMap` source requires `name`, while a `persistentVolumeClaim` source requires `claimName`). +* **`defaultContainerMount`** - An optional https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath[`volumeMount`] describing where the volume should be mounted in the main Solr container. +Init containers and sidecar containers can mount the same volume by referencing it by `name` in their own `volumeMounts`. + +The following example mounts a `ConfigMap` into the Solr container and a sidecar container: + +[source,yaml] +---- +spec: + customSolrKubeOptions: + podOptions: + volumes: + - source: + configMap: + name: configset + defaultMode: 0777 + name: configset + defaultContainerMount: + mountPath: /configset + name: configset + sidecarContainers: + - name: config-loader + image: alpine/curl:latest + command: + - "sh" + - "-c" + - "ls -la /configset" + volumeMounts: + - name: configset + mountPath: /configset +---- + +A complete, runnable example (including the backing `ConfigMap`) is available in https://github.com/apache/solr-operator/blob/main/example/test_solrcloud_additional_volume.yaml[`example/test_solrcloud_additional_volume.yaml`]. diff --git a/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc b/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc index a72ec09a..07b37b3a 100644 --- a/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc +++ b/docs/modules/solr-cloud/pages/solr-cloud-crd.adoc @@ -25,6 +25,7 @@ The following topics are covered on their own pages: * xref:custom-solr-config.adoc[Overriding built-in Solr configuration files] * xref:tls.adoc[Enabling TLS between Solr pods] * xref:authentication-and-authorization.adoc[Authentication and Authorization] +* xref:custom-kube-options.adoc[Customizing Kubernetes resources] == Solr Options From bfdf8188d3f89fc2206b546d52c963a9243d1332 Mon Sep 17 00:00:00 2001 From: Houston Putman Date: Fri, 26 Jun 2026 10:57:48 -0700 Subject: [PATCH 4/4] Add ASF header to example --- example/test_solrcloud_additional_volume.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example/test_solrcloud_additional_volume.yaml b/example/test_solrcloud_additional_volume.yaml index a33dba3e..0e7ddc24 100644 --- a/example/test_solrcloud_additional_volume.yaml +++ b/example/test_solrcloud_additional_volume.yaml @@ -1,3 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Mounting Additional Volumes # # It is also possible to mount additional volumes to the SolrCloud (or its initContainers). Some example scenarios where you might use this would be: