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

bug: adding missing inputs for zk tolerations and node selector support #108

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
11 changes: 10 additions & 1 deletion api/v1beta1/solrcloud_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package v1beta1

import (
"fmt"
"strings"

zk "github.com/pravega/zookeeper-operator/pkg/apis/zookeeper/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
)

const (
Expand Down Expand Up @@ -353,6 +354,14 @@ type ZookeeperPodPolicy struct {
// +optional
Affinity *corev1.Affinity `json:"affinity,omitempty"`

// Node Selector to be added on pods.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// Tolerations to be added on pods.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Resources is the resource requirements for the container.
// This field cannot be updated once the cluster is created.
// +optional
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

49 changes: 49 additions & 0 deletions config/crd/bases/solr.bloomberg.com_solrclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7053,6 +7053,11 @@ spec:
type: array
type: object
type: object
nodeSelector:
additionalProperties:
type: string
description: Node Selector to be added on pods.
type: object
resources:
description: Resources is the resource requirements
for the container. This field cannot be updated once
Expand All @@ -7074,6 +7079,50 @@ spec:
an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
tolerations:
description: Tolerations to be added on pods.
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
type: object
type: object
Expand Down
22 changes: 22 additions & 0 deletions controllers/util/zk_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func GenerateZookeeperCluster(solrCloud *solr.SolrCloud, zkSpec solr.ZookeeperSp
zkCluster.Spec.Pod.Resources = zkSpec.ZookeeperPod.Resources
}

if zkSpec.ZookeeperPod.Tolerations != nil {
zkCluster.Spec.Pod.Tolerations = zkSpec.ZookeeperPod.Tolerations
}

if zkSpec.ZookeeperPod.NodeSelector != nil {
zkCluster.Spec.Pod.NodeSelector = zkSpec.ZookeeperPod.NodeSelector
}

return zkCluster
}

Expand Down Expand Up @@ -153,6 +161,20 @@ func CopyZookeeperClusterFields(from, to *zk.ZookeeperCluster) bool {
}
to.Spec.Pod.Resources = from.Spec.Pod.Resources

if !DeepEqualWithNils(to.Spec.Pod.Tolerations, from.Spec.Pod.Tolerations) {
log.Info("Updating Zk tolerations")
log.Info("Update required because:", "Spec.Pod.Tolerations canged from", to.Spec.Pod.Tolerations, "To:", from.Spec.Pod.Tolerations)
requireUpdate = true
to.Spec.Pod.Tolerations = from.Spec.Pod.Tolerations
}

if !DeepEqualWithNils(to.Spec.Pod.NodeSelector, from.Spec.Pod.NodeSelector) {
log.Info("Updating Zk nodeSelector")
log.Info("Update required because:", "Spec.Pod.NodeSelector canged from", to.Spec.Pod.NodeSelector, "To:", from.Spec.Pod.NodeSelector)
requireUpdate = true
to.Spec.Pod.NodeSelector = from.Spec.Pod.NodeSelector
}

if from.Spec.Pod.Affinity != nil {
if !DeepEqualWithNils(to.Spec.Pod.Affinity.NodeAffinity, from.Spec.Pod.Affinity.NodeAffinity) {
log.Info("Updating Zk pod node affinity")
Expand Down
8 changes: 8 additions & 0 deletions example/test_solrcloud_toleration_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ spec:
storage: "5Gi"
replicas: 1
zookeeperPodPolicy:
nodeSelector:
beta.kubernetes.io/os: linux
beta.kubernetes.io/arch: amd64
tolerations:
- effect: NoSchedule
key: node-restriction.kubernetes.io/workloads
operator: Equal
value: zookeeper
resources:
limits:
memory: "1G"
Expand Down
49 changes: 49 additions & 0 deletions helm/solr-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8531,6 +8531,11 @@ spec:
type: array
type: object
type: object
nodeSelector:
additionalProperties:
type: string
description: Node Selector to be added on pods.
type: object
resources:
description: Resources is the resource requirements
for the container. This field cannot be updated once
Expand All @@ -8552,6 +8557,50 @@ spec:
an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
tolerations:
description: Tolerations to be added on pods.
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
type: object
type: object
Expand Down