Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Redis Operator creates/configures/manages redis-failovers atop Kubernetes.
- [Usage](#usage)
- [Reducing update churn (`--enable-hash`)](#reducing-update-churn---enable-hash)
- [Reconcile interval (`--resync-period`)](#reconcile-interval---resync-period)
- [Sentinel update strategy and PodDisruptionBudget](#sentinel-update-strategy-and-poddisruptionbudget)
- [Persistence](#persistence)
- [NodeAffinity and Tolerations](#nodeaffinity-and-tolerations)
- [Topology Spread Contraints](#topology-spread-contraints)
Expand Down Expand Up @@ -174,6 +175,26 @@ interval so it can recover from missed events and correct drift. This defaults t
tuned with `--resync-period` (any Go duration, e.g. `--resync-period=1m`). Larger values reduce API
load at the cost of slower periodic healing; smaller values react faster but poll more often.

### Sentinel update strategy and PodDisruptionBudget

The sentinel `Deployment` update strategy can be overridden via `sentinel.strategy` (e.g. to set
`rollingUpdate.maxSurge`/`maxUnavailable`). This helps when required anti-affinity plus
`replicas == nodes` would otherwise deadlock the default rolling update:

```yaml
spec:
sentinel:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
```

The `PodDisruptionBudget` `minAvailable` for each component defaults to `2` (or `1` when redis
`replicas <= 2`). Override it per component with `redis.podDisruptionBudgetMinAvailable` /
`sentinel.podDisruptionBudgetMinAvailable` (an integer or percentage string such as `"60%"`).

### Persistence

The operator has the ability of add persistence to Redis data. By default an `emptyDir` will be used, so the data is not saved.
Expand Down
13 changes: 13 additions & 0 deletions api/redisfailover/v1/types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package v1

import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

// +genclient
Expand Down Expand Up @@ -71,6 +73,9 @@ type RedisSettings struct {
CustomReadinessProbe *corev1.Probe `json:"customReadinessProbe,omitempty"`
CustomStartupProbe *corev1.Probe `json:"customStartupProbe,omitempty"`
DisablePodDisruptionBudget bool `json:"disablePodDisruptionBudget,omitempty"`
// PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
// minAvailable for the redis pods. Defaults to 2 (or 1 when replicas <= 2).
PodDisruptionBudgetMinAvailable *intstr.IntOrString `json:"podDisruptionBudgetMinAvailable,omitempty"`
}

// SentinelSettings defines the specification of the sentinel cluster
Expand Down Expand Up @@ -105,6 +110,14 @@ type SentinelSettings struct {
CustomReadinessProbe *corev1.Probe `json:"customReadinessProbe,omitempty"`
CustomStartupProbe *corev1.Probe `json:"customStartupProbe,omitempty"`
DisablePodDisruptionBudget bool `json:"disablePodDisruptionBudget,omitempty"`
// Strategy overrides the sentinel Deployment update strategy (e.g. to set
// rollingUpdate maxSurge/maxUnavailable). Defaults to the Kubernetes default
// RollingUpdate strategy when unset.
Strategy appsv1.DeploymentStrategy `json:"strategy,omitempty"`
// PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
// minAvailable for the sentinel pods. Defaults to 2 (or 1 when redis
// replicas <= 2).
PodDisruptionBudgetMinAvailable *intstr.IntOrString `json:"podDisruptionBudgetMinAvailable,omitempty"`
}

// AuthSettings contains settings about auth
Expand Down
12 changes: 12 additions & 0 deletions api/redisfailover/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 @@ -7157,6 +7157,14 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the redis pods. Defaults to 2 (or 1 when replicas <= 2).
x-kubernetes-int-or-string: true
port:
format: int32
type: integer
Expand Down Expand Up @@ -15437,6 +15445,15 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the sentinel pods. Defaults to 2 (or 1 when redis
replicas <= 2).
x-kubernetes-int-or-string: true
priorityClassName:
type: string
replicas:
Expand Down Expand Up @@ -15745,6 +15762,56 @@ spec:
type: object
startupConfigMap:
type: string
strategy:
description: |-
Strategy overrides the sentinel Deployment update strategy (e.g. to set
rollingUpdate maxSurge/maxUnavailable). Defaults to the Kubernetes default
RollingUpdate strategy when unset.
properties:
rollingUpdate:
description: |-
Rolling update config params. Present only if DeploymentStrategyType =
RollingUpdate.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be scheduled above the desired number of
pods.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
Defaults to 25%.
Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when
the rolling update starts, such that the total number of old and new pods do not exceed
130% of desired pods. Once old pods have been killed,
new ReplicaSet can be scaled up further, ensuring that total number of pods running
at any time during the update is at most 130% of desired pods.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be unavailable during the update.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
Defaults to 25%.
Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
immediately when the rolling update starts. Once new pods are ready, old ReplicaSet
can be scaled down further, followed by scaling up the new ReplicaSet, ensuring
that the total number of pods available at all times during the update is at
least 70% of desired pods.
x-kubernetes-int-or-string: true
type: object
type:
description: Type of deployment. Can be "Recreate" or "RollingUpdate".
Default is RollingUpdate.
type: string
type: object
tolerations:
items:
description: |-
Expand Down
67 changes: 67 additions & 0 deletions manifests/databases.spotahome.com_redisfailovers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7157,6 +7157,14 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the redis pods. Defaults to 2 (or 1 when replicas <= 2).
x-kubernetes-int-or-string: true
port:
format: int32
type: integer
Expand Down Expand Up @@ -15437,6 +15445,15 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the sentinel pods. Defaults to 2 (or 1 when redis
replicas <= 2).
x-kubernetes-int-or-string: true
priorityClassName:
type: string
replicas:
Expand Down Expand Up @@ -15745,6 +15762,56 @@ spec:
type: object
startupConfigMap:
type: string
strategy:
description: |-
Strategy overrides the sentinel Deployment update strategy (e.g. to set
rollingUpdate maxSurge/maxUnavailable). Defaults to the Kubernetes default
RollingUpdate strategy when unset.
properties:
rollingUpdate:
description: |-
Rolling update config params. Present only if DeploymentStrategyType =
RollingUpdate.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be scheduled above the desired number of
pods.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
Defaults to 25%.
Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when
the rolling update starts, such that the total number of old and new pods do not exceed
130% of desired pods. Once old pods have been killed,
new ReplicaSet can be scaled up further, ensuring that total number of pods running
at any time during the update is at most 130% of desired pods.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be unavailable during the update.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
Defaults to 25%.
Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
immediately when the rolling update starts. Once new pods are ready, old ReplicaSet
can be scaled down further, followed by scaling up the new ReplicaSet, ensuring
that the total number of pods available at all times during the update is at
least 70% of desired pods.
x-kubernetes-int-or-string: true
type: object
type:
description: Type of deployment. Can be "Recreate" or "RollingUpdate".
Default is RollingUpdate.
type: string
type: object
tolerations:
items:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7157,6 +7157,14 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the redis pods. Defaults to 2 (or 1 when replicas <= 2).
x-kubernetes-int-or-string: true
port:
format: int32
type: integer
Expand Down Expand Up @@ -15437,6 +15445,15 @@ spec:
additionalProperties:
type: string
type: object
podDisruptionBudgetMinAvailable:
anyOf:
- type: integer
- type: string
description: |-
PodDisruptionBudgetMinAvailable overrides the PodDisruptionBudget
minAvailable for the sentinel pods. Defaults to 2 (or 1 when redis
replicas <= 2).
x-kubernetes-int-or-string: true
priorityClassName:
type: string
replicas:
Expand Down Expand Up @@ -15745,6 +15762,56 @@ spec:
type: object
startupConfigMap:
type: string
strategy:
description: |-
Strategy overrides the sentinel Deployment update strategy (e.g. to set
rollingUpdate maxSurge/maxUnavailable). Defaults to the Kubernetes default
RollingUpdate strategy when unset.
properties:
rollingUpdate:
description: |-
Rolling update config params. Present only if DeploymentStrategyType =
RollingUpdate.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be scheduled above the desired number of
pods.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
Defaults to 25%.
Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when
the rolling update starts, such that the total number of old and new pods do not exceed
130% of desired pods. Once old pods have been killed,
new ReplicaSet can be scaled up further, ensuring that total number of pods running
at any time during the update is at most 130% of desired pods.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of pods that can be unavailable during the update.
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
Defaults to 25%.
Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
immediately when the rolling update starts. Once new pods are ready, old ReplicaSet
can be scaled down further, followed by scaling up the new ReplicaSet, ensuring
that the total number of pods available at all times during the update is at
least 70% of desired pods.
x-kubernetes-int-or-string: true
type: object
type:
description: Type of deployment. Can be "Recreate" or "RollingUpdate".
Default is RollingUpdate.
type: string
type: object
tolerations:
items:
description: |-
Expand Down
Loading
Loading