Skip to content

Commit

Permalink
added option to use emptyDir as additional mount
Browse files Browse the repository at this point in the history
  • Loading branch information
mdarii committed May 12, 2023
1 parent 41ee305 commit 8f1459d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,16 @@ spec:
additionalVolumes:
items:
properties:
emptyDir:
description: emptyDir to use to populate the volume
type: object
properties:
sizeLimit:
description: Total amount of local storage required for this EmptyDir volume
type: string
medium:
description: hat type of storage medium should back this directory
type: string
configMap:
description: ConfigMap to use to populate the volume
properties:
Expand Down Expand Up @@ -2666,6 +2676,16 @@ spec:
description: Additional volumes to mount to all pods in the cluster
items:
properties:
emptyDir:
description: emptyDir to use to populate the volume
properties:
sizeLimit:
description: Total amount of local storage required for this EmptyDir volume
type: string
medium:
description: hat type of storage medium should back this directory
type: string
type: object
configMap:
description: ConfigMap to use to populate the volume
properties:
Expand Down
2 changes: 2 additions & 0 deletions opensearch-operator/api/v1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ type AdditionalVolume struct {
Secret *corev1.SecretVolumeSource `json:"secret,omitempty"`
// ConfigMap to use to populate the volume
ConfigMap *corev1.ConfigMapVolumeSource `json:"configMap,omitempty"`
// EmptyDir to use to populate the volume
EmptyDir *corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty"`
// Whether to restart the pods on content change
RestartPods bool `json:"restartPods,omitempty"`
}
Expand Down
5 changes: 5 additions & 0 deletions opensearch-operator/api/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,16 @@ spec:
additionalVolumes:
items:
properties:
emptyDir:
description: emptyDir to use to populate the volume
type: object
properties:
sizeLimit:
description: Total amount of local storage required for this EmptyDir volume
type: string
medium:
description: hat type of storage medium should back this directory
type: string
configMap:
description: ConfigMap to use to populate the volume
properties:
Expand Down Expand Up @@ -2666,6 +2676,16 @@ spec:
description: Additional volumes to mount to all pods in the cluster
items:
properties:
emptyDir:
description: emptyDir to use to populate the volume
type: object
properties:
sizeLimit:
description: Total amount of local storage required for this EmptyDir volume
type: string
medium:
description: hat type of storage medium should back this directory
type: string
configMap:
description: ConfigMap to use to populate the volume
properties:
Expand Down
12 changes: 11 additions & 1 deletion opensearch-operator/pkg/reconcilers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func CreateAdditionalVolumes(
namesIndex := map[string]int{}

for i, volumeConfig := range volumeConfigs {
readOnly := true
if volumeConfig.ConfigMap != nil {
retVolumes = append(retVolumes, corev1.Volume{
Name: volumeConfig.Name,
Expand All @@ -114,13 +115,22 @@ func CreateAdditionalVolumes(
},
})
}
if volumeConfig.EmptyDir != nil {
readOnly = false
retVolumes = append(retVolumes, corev1.Volume{
Name: volumeConfig.Name,
VolumeSource: corev1.VolumeSource{
EmptyDir: volumeConfig.EmptyDir,
},
})
}
if volumeConfig.RestartPods {
namesIndex[volumeConfig.Name] = i
names = append(names, volumeConfig.Name)
}
retVolumeMounts = append(retVolumeMounts, corev1.VolumeMount{
Name: volumeConfig.Name,
ReadOnly: true,
ReadOnly: readOnly,
MountPath: volumeConfig.Path,
})
}
Expand Down

0 comments on commit 8f1459d

Please sign in to comment.