|
| 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`]. |
0 commit comments