Skip to content

Commit

Permalink
[Development][Add] Added nodeSelector and tolerations for cluster (#410)
Browse files Browse the repository at this point in the history
* Added node selector and tolerations for leader and follower

Signed-off-by: iamabhishek-dubey <[email protected]>

* Added example for node selector and tolerations

Signed-off-by: iamabhishek-dubey <[email protected]>
  • Loading branch information
iamabhishek-dubey authored Jan 16, 2023
1 parent 4e37f66 commit cbcd2ca
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ extends:
QuayImageName: opstree/redis-operator
GithubImageName: ot-container-kit/redis-operator/redis-operator
BuildDocs: false
AppVersion: "v0.13.0"
AppVersion: "v0.14.0"
GolangVersion: "1.17"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Current Operator version
VERSION ?= 0.13.0
VERSION ?= 0.14.0
# Default bundle image tag
BUNDLE_IMG ?= controller-bundle:$(VERSION)
# Options for 'bundle-build'
Expand Down
10 changes: 6 additions & 4 deletions api/v1beta1/rediscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ type RedisClusterSpec struct {
RedisFollower RedisFollower `json:"redisFollower,omitempty"`
RedisExporter *RedisExporter `json:"redisExporter,omitempty"`
Storage *Storage `json:"storage,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
TLS *TLSConfig `json:"TLS,omitempty"`
Sidecars *[]Sidecar `json:"sidecars,omitempty"`
Expand All @@ -63,7 +61,9 @@ type RedisLeader struct {
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
ReadinessProbe *Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,11,opt,name=livenessProbe"`
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,11,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisFollower interface will have the redis follower configuration
Expand All @@ -75,7 +75,9 @@ type RedisFollower struct {
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
ReadinessProbe *Probe `json:"readinessProbe,omitempty" protobuf:"bytes,11,opt,name=readinessProbe"`
// +kubebuilder:default:={initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,11,opt,name=livenessProbe"`
LivenessProbe *Probe `json:"livenessProbe,omitempty" protobuf:"bytes,11,opt,name=livenessProbe"`
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// RedisClusterStatus defines the observed state of RedisCluster
Expand Down
54 changes: 36 additions & 18 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

131 changes: 88 additions & 43 deletions config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ spec:
required:
- image
type: object
nodeSelector:
additionalProperties:
type: string
type: object
persistenceEnabled:
type: boolean
priorityClassName:
Expand Down Expand Up @@ -1306,6 +1302,10 @@ spec:
minimum: 1
type: integer
type: object
nodeSelector:
additionalProperties:
type: string
type: object
pdb:
description: RedisPodDisruptionBudget configure a PodDisruptionBudget
on the resource (leader/follower)
Expand Down Expand Up @@ -1364,6 +1364,46 @@ spec:
replicas:
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match.
Empty means match all taint effects. When specified, allowed
values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match
all values and all keys.
type: string
operator:
description: Operator represents a key's relationship to
the value. Valid operators are Exists and Equal. Defaults
to Equal. Exists is equivalent to wildcard for value,
so that a pod can tolerate all taints of a particular
category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of
time the toleration (which must be of effect NoExecute,
otherwise this field is ignored) tolerates the taint.
By default, it is not set, which means tolerate the taint
forever (do not evict). Zero and negative values will
be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
redisLeader:
default:
Expand Down Expand Up @@ -2281,6 +2321,10 @@ spec:
minimum: 1
type: integer
type: object
nodeSelector:
additionalProperties:
type: string
type: object
pdb:
description: RedisPodDisruptionBudget configure a PodDisruptionBudget
on the resource (leader/follower)
Expand Down Expand Up @@ -2339,6 +2383,46 @@ spec:
replicas:
format: int32
type: integer
tolerations:
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match.
Empty means match all taint effects. When specified, allowed
values are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match
all values and all keys.
type: string
operator:
description: Operator represents a key's relationship to
the value. Valid operators are Exists and Equal. Defaults
to Equal. Exists is equivalent to wildcard for value,
so that a pod can tolerate all taints of a particular
category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of
time the toleration (which must be of effect NoExecute,
otherwise this field is ignored) tolerates the taint.
By default, it is not set, which means tolerate the taint
forever (do not evict). Zero and negative values will
be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
resources:
description: ResourceRequirements describes the compute resource requirements.
Expand Down Expand Up @@ -4625,45 +4709,6 @@ spec:
type: array
type: object
type: object
tolerations:
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
required:
- clusterSize
- kubernetesConfig
Expand Down
1 change: 1 addition & 0 deletions example/eks-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ addons:
- name: vpc-cni
- name: coredns
- name: kube-proxy
- name: ebs-csi-driver
iam:
withOIDC: true
32 changes: 32 additions & 0 deletions example/node-selector/clusterd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: RedisCluster
metadata:
name: redis-cluster
spec:
clusterSize: 3
clusterVersion: v7
securityContext:
runAsUser: 1000
fsGroup: 1000
persistenceEnabled: true
kubernetesConfig:
image: quay.io/opstree/redis:v7.0.5
imagePullPolicy: IfNotPresent
redisExporter:
enabled: false
image: quay.io/opstree/redis-exporter:v1.44.0
redisLeader:
nodeSelector:
kubernetes.io/os: linux
redisFollower:
nodeSelector:
kubernetes.io/os: linux
storage:
volumeClaimTemplate:
spec:
# storageClassName: standard
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
25 changes: 25 additions & 0 deletions example/node-selector/standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: redis.redis.opstreelabs.in/v1beta1
kind: Redis
metadata:
name: redis-standalone
spec:
kubernetesConfig:
image: quay.io/opstree/redis:v7.0.5
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 1000
fsGroup: 1000
storage:
volumeClaimTemplate:
spec:
# storageClassName: standard
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
redisExporter:
enabled: false
image: quay.io/opstree/redis-exporter:v1.44.0
nodeSelector:
kubernetes.io/os: linux
Loading

0 comments on commit cbcd2ca

Please sign in to comment.