Skip to content

Commit e4b20c1

Browse files
doc(volumes): add docs for attaching additional volumes (#739)
Co-authored-by: Houston Putman <houston@apache.org>
1 parent 5df015e commit e4b20c1

4 files changed

Lines changed: 138 additions & 0 deletions

File tree

docs/modules/solr-cloud/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
** xref:custom-solr-config.adoc[Custom Solr Configuration]
2424
** xref:tls.adoc[]
2525
** xref:authentication-and-authorization.adoc[]
26+
** xref:custom-kube-options.adoc[]
2627
* xref:cluster-operations.adoc[]
2728
* xref:managed-updates.adoc[]
2829
* xref:scaling.adoc[]
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
= Customizing Resources
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
19+
The Solr Operator creates a number of Kubernetes resources to run a SolrCloud (StatefulSet, Services, ConfigMap, etc.).
20+
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.
21+
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.
22+
23+
== Mounting Additional Volumes
24+
25+
Arbitrary additional volumes can be mounted into the Solr pods (and their init/sidecar containers) via `SolrCloud.spec.customSolrKubeOptions.podOptions.volumes`.
26+
This is separate from the xref:solr-cloud-crd.adoc#data-storage[data storage] used for Solr's index data.
27+
Some example scenarios where this is useful:
28+
29+
* Custom Solr plugins that rely on certain data being present on disk.
30+
* Bootstrapping additional configuration for Solr via a `ConfigMap`.
31+
* A dedicated volume to support backups.
32+
33+
Each entry under `volumes` has the following fields:
34+
35+
* **`name`** - The name of the volume, used to reference it from container `volumeMounts`.
36+
* **`source`** - A standard Kubernetes https://kubernetes.io/docs/concepts/storage/volumes/#volume-types[volume source] (e.g. `configMap`, `persistentVolumeClaim`, `secret`, `emptyDir`).
37+
The required fields depend on the source type chosen (for example, a `configMap` source requires `name`, while a `persistentVolumeClaim` source requires `claimName`).
38+
* **`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.
39+
Init containers and sidecar containers can mount the same volume by referencing it by `name` in their own `volumeMounts`.
40+
41+
The following example mounts a `ConfigMap` into the Solr container and a sidecar container:
42+
43+
[source,yaml]
44+
----
45+
spec:
46+
customSolrKubeOptions:
47+
podOptions:
48+
volumes:
49+
- source:
50+
configMap:
51+
name: configset
52+
defaultMode: 0777
53+
name: configset
54+
defaultContainerMount:
55+
mountPath: /configset
56+
name: configset
57+
sidecarContainers:
58+
- name: config-loader
59+
image: alpine/curl:latest
60+
command:
61+
- "sh"
62+
- "-c"
63+
- "ls -la /configset"
64+
volumeMounts:
65+
- name: configset
66+
mountPath: /configset
67+
----
68+
69+
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`].

docs/modules/solr-cloud/pages/solr-cloud-crd.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The following topics are covered on their own pages:
2525
* xref:custom-solr-config.adoc[Overriding built-in Solr configuration files]
2626
* xref:tls.adoc[Enabling TLS between Solr pods]
2727
* xref:authentication-and-authorization.adoc[Authentication and Authorization]
28+
* xref:custom-kube-options.adoc[Customizing Kubernetes resources]
2829
2930
== Solr Options
3031

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership.
4+
# The ASF licenses this file to You under the Apache License, Version 2.0
5+
# (the "License"); you may not use this file except in compliance with
6+
# the License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Mounting Additional Volumes
17+
#
18+
# It is also possible to mount additional volumes to the SolrCloud (or its initContainers). Some example scenarios where you might use this would be:
19+
# - Custom solr plugins that rely on certain data to be present on disk
20+
# - Bootstrapping additional configuration for Solr via a ConfigMap
21+
#
22+
# Below is an example of the last scenario:
23+
24+
apiVersion: solr.apache.org/v1beta1
25+
kind: SolrCloud
26+
metadata:
27+
name: test
28+
namespace: test
29+
spec:
30+
replicas: 1
31+
customSolrKubeOptions:
32+
podOptions:
33+
volumes:
34+
- source:
35+
configMap:
36+
name: configset
37+
defaultMode: 0777
38+
name: configset
39+
defaultContainerMount:
40+
mountPath: /configset
41+
name: configset
42+
sidecarContainers:
43+
- name: config-loader
44+
image: alpine/curl:latest
45+
command:
46+
- "sh"
47+
- "-c"
48+
- "ls -la /configset"
49+
volumeMounts:
50+
- name: configset
51+
mountPath: /configset
52+
53+
# Note the `source` spec may change based on the implementation. In this case, the `configMap` spec requires field `name`.
54+
# See volume spec in CRD: https://github.com/apache/solr-operator/blob/main/config/crd/bases/solr.apache.org_solrclouds.yaml#L6800
55+
56+
---
57+
kind: ConfigMap
58+
apiVersion: v1
59+
metadata:
60+
name: configset
61+
namespace: test
62+
data:
63+
config.xml: |
64+
<?xml version="1.0" encoding="UTF-8" ?>
65+
<config>
66+
...
67+
</config>

0 commit comments

Comments
 (0)