Skip to content

Commit 40666ba

Browse files
authored
Merge pull request #68 from spotahome/devops-785-add-persistance
Add Persistence to Redis pods
2 parents 2c2212c + 5f32d56 commit 40666ba

File tree

14 files changed

+532
-21
lines changed

14 files changed

+532
-21
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION := 0.3.0
1+
VERSION := 0.4.0
22

33
# Name of this service/application
44
SERVICE_NAME := redis-operator
@@ -144,6 +144,6 @@ endif
144144

145145
# Generate kubernetes code for types..
146146
.PHONY: update-codegen
147-
update-codegen: build
147+
update-codegen: docker-build
148148
@echo ">> Generating code for Kubernetes CRD types..."
149149
docker run --rm -v $(PWD):/go/src/github.com/spotahome/redis-operator/ $(REPOSITORY)-dev /bin/bash -c '$(UPDATE_CODEGEN_CMD)'

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ helm install --name redisfailover charts/redisoperator
3636
## Usage
3737
Once the operator is deployed inside a Kubernetes cluster, a new API will be accesible, so you'll be able to create, update and delete redisfailovers.
3838

39-
In order to deploy a new redis-failover a [specification](example/redisfailover.yaml) has to be created:
39+
In order to deploy a new redis-failover a [specification](example/redisfailover/all-options.yaml) has to be created:
4040
```
41-
kubectl create -f https://raw.githubusercontent.com/spotahome/redis-operator/master/example/redisfailover.yaml
41+
kubectl create -f https://raw.githubusercontent.com/spotahome/redis-operator/master/redisfailover/all-options.yaml
4242
```
4343

4444
This redis-failover will be managed by the operator, resulting in the following elements created inside Kubernetes:
@@ -51,6 +51,13 @@ This redis-failover will be managed by the operator, resulting in the following
5151

5252
**NOTE**: `NAME` is the named provided when creating the RedisFailover.
5353

54+
### Persistance
55+
The operator has the ability of add persistance to Redis data. By default an `emptyDir` will be used, so the data is not saved.
56+
57+
In order to have persistance, a PersistentVolumeClaim usage is allowed. The full [PVC definition has to be added](example/redisfailover/persistant-storage.yaml) to the Redis Failover Spec under the `Storage` section.
58+
59+
**IMPORTANT**: By default, the persistent volume claims will be deleted when the Redis Failover is. If this is not the expected usage, a `keepAfterDeletion` flag can be added under the `storage` section of Redis. [An example is given](example/redisfailover/persistant-storage-no-pvc-deletion.yaml).
60+
5461
### Connection
5562
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.
5663
The connection parameters are the following:

api/redisfailover/v1alpha2/types.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type RedisSettings struct {
4343
Image string `json:"image,omitempty"`
4444
Version string `json:"version,omitempty"`
4545
ConfigMap string `json:"configMap,omitempty"`
46-
DataVolume corev1.Volume `json:"dataVolume,omitempty"`
46+
Storage RedisStorage `json:"storage,omitempty"`
4747
}
4848

4949
// SentinelSettings defines the specification of the sentinel cluster
@@ -65,6 +65,13 @@ type CPUAndMem struct {
6565
Memory string `json:"memory"`
6666
}
6767

68+
// RedisStorage defines the structure used to store the Redis Data
69+
type RedisStorage struct {
70+
KeepAfterDeletion bool `json:"keepAfterDeletion,omitempty"`
71+
EmptyDir *corev1.EmptyDirVolumeSource `json:"emptyDir,omitempty"`
72+
PersistentVolumeClaim *corev1.PersistentVolumeClaim `json:"persistentVolumeClaim,omitempty"`
73+
}
74+
6875
// RedisFailoverStatus has the status of the cluster
6976
type RedisFailoverStatus struct {
7077
Phase Phase `json:"phase"`

api/redisfailover/v1alpha2/zz_generated.deepcopy.go

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

example/redisfailover.yaml renamed to example/redisfailover/all-options.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ spec:
2525
exporter: false # Optional. False by default. Adds a redis-exporter container to export metrics.
2626
exporterImage: oliver006/redis_exporter # Optional. oliver006/redis_exporter by default.
2727
exporterVersion: v0.11.3 # Optional. v0.11.3 by default.
28-
dataVolume:
29-
name: redis-data
30-
emptyDir: {}
28+
storage:
29+
emptyDir: {} # Optional. emptyDir by default.
30+
File renamed without changes.

0 commit comments

Comments
 (0)