From 3cb870bd4d170390de829683ff4649f37e3a5658 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 16 Dec 2024 11:08:33 -0500 Subject: [PATCH 1/2] 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/2] 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