diff --git a/README.md b/README.md index 63ffa593b..15f5795ff 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,43 @@ In order to have persistence, a `PersistentVolumeClaim` usage is allowed. The fu **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/persistent-storage-no-pvc-deletion.yaml). +### NodeAffinity and Tolerations +You can use NodeAffinity and Tolerations to deploy Pods to isolated groups of Nodes + +Example: +```yaml +apiVersion: v1 +items: +- apiVersion: storage.spotahome.com/v1alpha2 + kind: RedisFailover + metadata: + name: redis + spec: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kops.k8s.io/instancegroup + operator: In + values: + - productionnodes + hardAntiAffinity: false + redis: null + sentinel: + replicas: 3 + resources: + limits: + memory: 100Mi + requests: + cpu: 100m + tolerations: + - effect: NoExecute + key: dedicated + operator: Equal + value: production +kind: List +``` + ### Custom configurations It is possible to configure both Redis and Sentinel. This is done with the `customConfig` option inside their spec. It is a list of configurations and their values. diff --git a/api/redisfailover/v1alpha2/types.go b/api/redisfailover/v1alpha2/types.go index fc9dc1e90..3c7936dbd 100644 --- a/api/redisfailover/v1alpha2/types.go +++ b/api/redisfailover/v1alpha2/types.go @@ -31,6 +31,9 @@ type RedisFailoverSpec struct { // NodeAffinity defines the rules for scheduling the Redis and Sentinel // nodes NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty"` + + //Tolerations provides a way to schedule Pods on Tainted Nodes + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` } // RedisSettings defines the specification of the redis cluster diff --git a/api/redisfailover/v1alpha2/zz_generated.deepcopy.go b/api/redisfailover/v1alpha2/zz_generated.deepcopy.go index 92824b5fe..32e6d666a 100644 --- a/api/redisfailover/v1alpha2/zz_generated.deepcopy.go +++ b/api/redisfailover/v1alpha2/zz_generated.deepcopy.go @@ -1,7 +1,7 @@ // +build !ignore_autogenerated /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -150,6 +150,13 @@ func (in *RedisFailoverSpec) DeepCopyInto(out *RedisFailoverSpec) { (*in).DeepCopyInto(*out) } } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/client/k8s/clientset/versioned/clientset.go b/client/k8s/clientset/versioned/clientset.go index 6719ab78b..bb2309b5e 100644 --- a/client/k8s/clientset/versioned/clientset.go +++ b/client/k8s/clientset/versioned/clientset.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/doc.go b/client/k8s/clientset/versioned/doc.go index 006b79214..dc992b90b 100644 --- a/client/k8s/clientset/versioned/doc.go +++ b/client/k8s/clientset/versioned/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/fake/clientset_generated.go b/client/k8s/clientset/versioned/fake/clientset_generated.go index ffedf3807..5204aacc1 100644 --- a/client/k8s/clientset/versioned/fake/clientset_generated.go +++ b/client/k8s/clientset/versioned/fake/clientset_generated.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/fake/doc.go b/client/k8s/clientset/versioned/fake/doc.go index 0bc260bca..acfa6173b 100644 --- a/client/k8s/clientset/versioned/fake/doc.go +++ b/client/k8s/clientset/versioned/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/fake/register.go b/client/k8s/clientset/versioned/fake/register.go index 16fefffa0..beb1344d8 100644 --- a/client/k8s/clientset/versioned/fake/register.go +++ b/client/k8s/clientset/versioned/fake/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/scheme/doc.go b/client/k8s/clientset/versioned/scheme/doc.go index 5c5c8debb..7f61dc1f9 100644 --- a/client/k8s/clientset/versioned/scheme/doc.go +++ b/client/k8s/clientset/versioned/scheme/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/scheme/register.go b/client/k8s/clientset/versioned/scheme/register.go index 1da7216a7..6662b27d6 100644 --- a/client/k8s/clientset/versioned/scheme/register.go +++ b/client/k8s/clientset/versioned/scheme/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/doc.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/doc.go index 01dd46de8..e4cda4fe2 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/doc.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/doc.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/doc.go index 87a1873ed..ab4fd43ad 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/doc.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover.go index d7953c4fb..855e86d51 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover_client.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover_client.go index 484152e0d..f61dcee83 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover_client.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/fake/fake_redisfailover_client.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/generated_expansion.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/generated_expansion.go index 4c8a5c22d..450523d83 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/generated_expansion.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/generated_expansion.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover.go index 57872488a..56267d808 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover_client.go b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover_client.go index cf0a5dcbf..d45c230d6 100644 --- a/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover_client.go +++ b/client/k8s/clientset/versioned/typed/redisfailover/v1alpha2/redisfailover_client.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/operator/redisfailover/service/generator.go b/operator/redisfailover/service/generator.go index cfe9029a7..8f6379930 100644 --- a/operator/redisfailover/service/generator.go +++ b/operator/redisfailover/service/generator.go @@ -189,6 +189,7 @@ func generateRedisStatefulSet(rf *redisfailoverv1alpha2.RedisFailover, labels ma NodeAffinity: rf.Spec.NodeAffinity, PodAntiAffinity: createPodAntiAffinity(rf.Spec.HardAntiAffinity, labels), }, + Tolerations: rf.Spec.Tolerations, Containers: []corev1.Container{ { Name: "redis", @@ -297,6 +298,7 @@ func generateSentinelDeployment(rf *redisfailoverv1alpha2.RedisFailover, labels NodeAffinity: rf.Spec.NodeAffinity, PodAntiAffinity: createPodAntiAffinity(rf.Spec.HardAntiAffinity, labels), }, + Tolerations: rf.Spec.Tolerations, InitContainers: []corev1.Container{ { Name: "sentinel-config-copy",