Skip to content

Commit

Permalink
Add additionalVolumes to K8ssandraCluster.spec.medusa.storageProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
a-mroz committed Dec 16, 2024
1 parent 75c9f23 commit d988f7e
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ When cutting a new release, update the `unreleased` heading to the tag being gen
* [CHANGE] [#1441](https://github.com/k8ssandra/k8ssandra-operator/issues/1441) Use k8ssandra-client instead of k8ssandra-tools for CRD upgrades
* [BUGFIX] [#1383](https://github.com/k8ssandra/k8ssandra-operator/issues/1383) Do not create MedusaBackup if MedusaBakupJob did not fully succeed
* [ENHANCEMENT] [#1667](https://github.com/k8ssahttps://github.com/k8ssandra/k8ssandra/issues/1667) Add `skipSchemaMigration` option to `K8ssandraCluster.spec.reaper`
* [ENHANCEMENT] [#1465](https://github.com/k8ssandra/k8ssandra/issues/1465) Add `volumeMounts` option to `K8ssandraCluster.spec.medusa.storageProperties`
4 changes: 4 additions & 0 deletions apis/medusa/v1alpha1/medusa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ type Storage struct {
// Pod storage settings for the local storage provider
// +optional
PodStorage *PodStorageSettings `json:"podStorage,omitempty"`

// Volume mounts for Medusa container.
// +optional
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
}

type PodStorageSettings struct {
Expand Down
7 changes: 7 additions & 0 deletions apis/medusa/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26564,6 +26564,49 @@ spec:
Max upload bandwidth in MB/s.
Defaults to 50 MB/s.
type: string
volumeMounts:
description: Volume mounts for Medusa container.
items:
description: VolumeMount describes a mounting of a Volume
within a container.
properties:
mountPath:
description: |-
Path within the container at which the volume should be mounted. Must
not contain ':'.
type: string
mountPropagation:
description: |-
mountPropagation determines how mounts are propagated from the host
to container and the other way around.
When not set, MountPropagationNone is used.
This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: |-
Mounted read-only if true, read-write otherwise (false or unspecified).
Defaults to false.
type: boolean
subPath:
description: |-
Path within the volume from which the container's volume should be mounted.
Defaults to "" (volume's root).
type: string
subPathExpr:
description: |-
Expanded path within the volume from which the container's volume should be mounted.
Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment.
Defaults to "" (volume's root).
SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
type: object
type: object
reaper:
Expand Down Expand Up @@ -32242,6 +32285,49 @@ spec:
Max upload bandwidth in MB/s.
Defaults to 50 MB/s.
type: string
volumeMounts:
description: Volume mounts for Medusa container.
items:
description: VolumeMount describes a mounting of a Volume within
a container.
properties:
mountPath:
description: |-
Path within the container at which the volume should be mounted. Must
not contain ':'.
type: string
mountPropagation:
description: |-
mountPropagation determines how mounts are propagated from the host
to container and the other way around.
When not set, MountPropagationNone is used.
This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: |-
Mounted read-only if true, read-write otherwise (false or unspecified).
Defaults to false.
type: boolean
subPath:
description: |-
Path within the volume from which the container's volume should be mounted.
Defaults to "" (volume's root).
type: string
subPathExpr:
description: |-
Expanded path within the volume from which the container's volume should be mounted.
Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment.
Defaults to "" (volume's root).
SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
type: object
type: object
status:
Expand Down
43 changes: 43 additions & 0 deletions config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26502,6 +26502,49 @@ spec:
Max upload bandwidth in MB/s.
Defaults to 50 MB/s.
type: string
volumeMounts:
description: Volume mounts for Medusa container.
items:
description: VolumeMount describes a mounting of a Volume
within a container.
properties:
mountPath:
description: |-
Path within the container at which the volume should be mounted. Must
not contain ':'.
type: string
mountPropagation:
description: |-
mountPropagation determines how mounts are propagated from the host
to container and the other way around.
When not set, MountPropagationNone is used.
This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: |-
Mounted read-only if true, read-write otherwise (false or unspecified).
Defaults to false.
type: boolean
subPath:
description: |-
Path within the volume from which the container's volume should be mounted.
Defaults to "" (volume's root).
type: string
subPathExpr:
description: |-
Expanded path within the volume from which the container's volume should be mounted.
Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment.
Defaults to "" (volume's root).
SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
type: object
type: object
reaper:
Expand Down
43 changes: 43 additions & 0 deletions config/crd/bases/medusa.k8ssandra.io_medusaconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,49 @@ spec:
Max upload bandwidth in MB/s.
Defaults to 50 MB/s.
type: string
volumeMounts:
description: Volume mounts for Medusa container.
items:
description: VolumeMount describes a mounting of a Volume within
a container.
properties:
mountPath:
description: |-
Path within the container at which the volume should be mounted. Must
not contain ':'.
type: string
mountPropagation:
description: |-
mountPropagation determines how mounts are propagated from the host
to container and the other way around.
When not set, MountPropagationNone is used.
This field is beta in 1.10.
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: |-
Mounted read-only if true, read-write otherwise (false or unspecified).
Defaults to false.
type: boolean
subPath:
description: |-
Path within the volume from which the container's volume should be mounted.
Defaults to "" (volume's root).
type: string
subPathExpr:
description: |-
Expanded path within the volume from which the container's volume should be mounted.
Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment.
Defaults to "" (volume's root).
SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
type: array
type: object
type: object
status:
Expand Down
4 changes: 4 additions & 0 deletions pkg/medusa/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ func medusaVolumeMounts(dcConfig *cassandra.DatacenterConfig, medusaSpec *api.Me
})
}

if medusaSpec.StorageProperties.VolumeMounts != nil {
volumeMounts = append(volumeMounts, medusaSpec.StorageProperties.VolumeMounts...)
}

return volumeMounts
}

Expand Down
37 changes: 37 additions & 0 deletions pkg/medusa/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package medusa

import (
"fmt"
"slices"
"testing"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -706,3 +707,39 @@ func TestPurgeCronJobNameTooLong(t *testing.T) {
_, err := PurgeCronJob(dcConfig, clusterName, namespace, logger)
assert.NotNil(t, err)
}

func TestMedusaVolumeMounts(t *testing.T) {
mountName := "testMount"
mountPath := "/home/cassandra/config"

medusaSpec := &medusaapi.MedusaClusterTemplate{
StorageProperties: medusaapi.Storage{
StorageProvider: "s3",
BucketName: "bucket",
VolumeMounts: []corev1.VolumeMount{{
Name: mountName,
MountPath: mountPath,
}},
},
CassandraUserSecretRef: corev1.LocalObjectReference{
Name: "test-superuser",
},
}

dcConfig := cassandra.DatacenterConfig{}

logger := logr.New(logr.Discard().GetSink())

medusaContainer, err := CreateMedusaMainContainer(&dcConfig, medusaSpec, true, "test", logger)

assert.NoError(t, err)

volumeMounts := medusaContainer.VolumeMounts

assert.NotNil(t, volumeMounts)

idx := slices.IndexFunc(volumeMounts, func(c corev1.VolumeMount) bool { return c.Name == mountName })
assert.NotEqual(t, idx, -1)

assert.Equal(t, volumeMounts[idx].MountPath, mountPath)
}

0 comments on commit d988f7e

Please sign in to comment.