Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding nodeSelector option for PodSpec #19

Merged
merged 1 commit into from
Sep 21, 2020
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
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