Skip to content

Commit

Permalink
Add extravolumes and extravolumemounts
Browse files Browse the repository at this point in the history
  • Loading branch information
samof76 committed Sep 2, 2022
1 parent d92dfef commit 432f174
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,37 @@ app.kubernetes.io/part-of
redisfailovers.databases.spotahome.com/name
```


### ExtraVolumes and ExtraVolumeMounts

If the user choose to have extra volumes creates and mounted, he could use the `extraVolumes` and `extraVolumeMounts`, in `spec.redis` of the CRD. This allows users to mount the extra configurations, or secrets to be used. A typical use case for this might be
- Secrets that sidecars might use to backup of RDBs
- Extra users and their secrets and acls that could used the initContainers to create multiple users
- Extra Configurations that could merge on top the existing configurations

```
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: redisfailover
spec:
sentinel:
replicas: 3
redis:
replicas: 3
extraVolumes:
- name: foo_user
secret:
secretName: mysecret
optional: false
exraVolumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
```



## Connection to the created Redis Failovers

In order to connect to the redis-failover and use it, a [Sentinel-ready](https://redis.io/topics/sentinel-clients) library has to be used. This will connect through the Sentinel service to the Redis node working as a master.
Expand Down
2 changes: 2 additions & 0 deletions api/redisfailover/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type RedisSettings struct {
PriorityClassName string `json:"priorityClassName,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
TerminationGracePeriodSeconds int64 `json:"terminationGracePeriod,omitempty"`
ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"`
ExtraVolumeMounts []corev1.VolumeMount `json:"extraVolumeMounts,omitempty"`
}

// SentinelSettings defines the specification of the sentinel cluster
Expand Down
18 changes: 18 additions & 0 deletions example/redisfailover/extravolumes-mounts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: redisfailover
spec:
sentinel:
replicas: 3
redis:
replicas: 3
extraVolumes:
- name: foo_user
secret:
secretName: mysecret
optional: false
exraVolumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
8 changes: 8 additions & 0 deletions operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ func getRedisVolumeMounts(rf *redisfailoverv1.RedisFailover) []corev1.VolumeMoun
},
}

if rf.Spec.Redis.ExtraVolumeMounts != nil {
volumeMounts = append(volumeMounts, rf.Spec.Redis.ExtraVolumeMounts...)
}

return volumeMounts
}

Expand Down Expand Up @@ -830,6 +834,10 @@ func getRedisVolumes(rf *redisfailoverv1.RedisFailover) []corev1.Volume {
volumes = append(volumes, *dataVolume)
}

if rf.Spec.Redis.ExtraVolumes != nil {
volumes = append(volumes, rf.Spec.Redis.ExtraVolumes...)
}

return volumes
}

Expand Down

0 comments on commit 432f174

Please sign in to comment.