Skip to content

Commit

Permalink
Adding nodeSelector option for PodSpec (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
aignatov authored Sep 21, 2020
1 parent 646ec58 commit 9565a0a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions deploy/crds/k8s_v1alpha1_redis_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ spec:
description: 'Pod ServiceAccountName is the name of the ServiceAccount
to use to run this pod. More info: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/'
type: string
nodeSelector:
additionalProperties:
type: string
description: NodeSelector specifies a map of key-value pairs. For the
pod to be eligible to run on a node, the node must have each of the
indicated key-value pairs as labels.
type: object
tolerations:
description: Pod tolerations
items:
Expand Down
2 changes: 1 addition & 1 deletion example/k8s_v1alpha1_redis_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
# key: password
# name: redis-password-secret

# affinity, annotations, securityContext, tolerations and priorityClassName (all optional)
# affinity, annotations, securityContext, nodeSelector tolerations and priorityClassName (all optional)
# are added to the resulting StatefulSet's PodTemplate.
# More info: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.14/#podspec-v1-core
affinity:
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/k8s/v1alpha1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ type RedisSpec struct {
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
// Pod affinity
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// NodeSelector specifies a map of key-value pairs. For the pod to be
// eligible to run on a node, the node must have each of the indicated
// key-value pairs as labels.
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Pod tolerations
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// Pod ServiceAccountName is the name of the ServiceAccount to use to run this pod.
Expand Down
9 changes: 8 additions & 1 deletion pkg/apis/k8s/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions pkg/controller/redis/object_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ func generateStatefulSet(r *k8sv1alpha1.Redis, password string) *appsv1.Stateful
SecurityContext: r.Spec.SecurityContext,
ImagePullSecrets: r.Spec.ImagePullSecrets,
Affinity: r.Spec.Affinity,
NodeSelector: r.Spec.NodeSelector,
Tolerations: r.Spec.Tolerations,
PriorityClassName: r.Spec.PriorityClassName,
},
Expand Down

0 comments on commit 9565a0a

Please sign in to comment.