Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhf committed Dec 2, 2019
1 parent 847b5ab commit 0573171
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,22 @@ By default, no pod annotations will be applied to Redis nor Sentinel pods.

In order to apply custom pod Annotations, you can provide the `podAnnotations` option inside redis/sentinel spec. An example can be found in the [custom annotations example file](example/redisfailover/custom-annotations.yaml).

### Control of label propagation.
By default the operator will propagate all labels on the CRD down to the resources that it creates. This can be problematic if the
labels on the CRD are not fully under your own control (for example: being deployed by a gitops operator)
as a change to a labels value can fail on immutable resources such as PodDisruptionBudgets. To control what labels the operator propagates
to resource is creates you can modify the labelWhitelist option in the spec.

By default specifying no whitelist or an empty whitelist will cause all labels to still be copied as not to break backwards compatibility.

Items in the array should be regular expressions, see [here](example/redisfailover/control-label-propagation.yaml) as an example of how they can be used and
[here](https://github.com/google/re2/wiki/Syntax) for a syntax reference.

The whitelist can also be used as a form of blacklist by specifying a regular expression that will not match any label.




## 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
29 changes: 29 additions & 0 deletions example/redisfailover/control-label-propagation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: databases.spotahome.com/v1
kind: RedisFailover
metadata:
name: redisfailover2
labels:
# These two labels will be propagated.
app.example.com/label1: value
app.example.com/label2: value
# This one wont be, as there is a non-empty whitelist and the regexp doesnt match it.
anotherlabel: value
spec:
sentinel:
replicas: 3
resources:
requests:
cpu: 100m
limits:
memory: 100Mi
redis:
replicas: 3
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 400m
memory: 500Mi
labelWhitelist:
- ^app.example.com.*
2 changes: 1 addition & 1 deletion operator/redisfailover/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (r *RedisFailoverHandler) getLabels(rf *redisfailoverv1.RedisFailover) map[
}
}
} else {
// If no whitelist is specified then dont filter label.
// If no whitelist is specified then don't filter the labels.
filteredCustomLabels = rf.Labels
}
return util.MergeLabels(defaultLabels, dynLabels, filteredCustomLabels)
Expand Down

0 comments on commit 0573171

Please sign in to comment.