Add nodeSelector and tolerations
Change-Id: I4e50f21add4f56b08fa6f3b5df6d5508d52b960c
This commit is contained in:
parent
98eb3813c1
commit
d03a182dbc
@ -1,6 +1,7 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@ -11,8 +12,10 @@ type McrouterPoolSpec struct {
|
||||
|
||||
// McrouterSpec defines the desired state of Mcrouter
|
||||
type McrouterSpec struct {
|
||||
Pools map[string]McrouterPoolSpec `json:"pools"`
|
||||
Route string `json:"route"`
|
||||
Pools map[string]McrouterPoolSpec `json:"pools"`
|
||||
Route string `json:"route"`
|
||||
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
|
||||
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
|
||||
}
|
||||
|
||||
// McrouterStatus defines the observed state of Mcrouter
|
||||
|
@ -1,6 +1,7 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
@ -8,7 +9,9 @@ import (
|
||||
type MemcachedSpec struct {
|
||||
// +kubebuilder:validation:Required
|
||||
// +kubebuilder:validation:Default=64
|
||||
Megabytes int `json:"megabytes"`
|
||||
Megabytes int `json:"megabytes"`
|
||||
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
|
||||
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
|
||||
}
|
||||
|
||||
// MemcachedStatus defines the observed state of Memcached
|
||||
|
@ -21,6 +21,7 @@ limitations under the License.
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
@ -113,6 +114,20 @@ func (in *McrouterSpec) DeepCopyInto(out *McrouterSpec) {
|
||||
(*out)[key] = *val.DeepCopy()
|
||||
}
|
||||
}
|
||||
if in.NodeSelector != nil {
|
||||
in, out := &in.NodeSelector, &out.NodeSelector
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Tolerations != nil {
|
||||
in, out := &in.Tolerations, &out.Tolerations
|
||||
*out = make([]v1.Toleration, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new McrouterSpec.
|
||||
@ -145,7 +160,7 @@ func (in *Memcached) DeepCopyInto(out *Memcached) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
@ -202,6 +217,20 @@ func (in *MemcachedList) DeepCopyObject() runtime.Object {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *MemcachedSpec) DeepCopyInto(out *MemcachedSpec) {
|
||||
*out = *in
|
||||
if in.NodeSelector != nil {
|
||||
in, out := &in.NodeSelector, &out.NodeSelector
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.Tolerations != nil {
|
||||
in, out := &in.Tolerations, &out.Tolerations
|
||||
*out = make([]v1.Toleration, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemcachedSpec.
|
||||
|
@ -34,6 +34,10 @@ spec:
|
||||
spec:
|
||||
description: McrouterSpec defines the desired state of Mcrouter
|
||||
properties:
|
||||
nodeSelector:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pools:
|
||||
additionalProperties:
|
||||
description: McrouterPoolSpec defines the desired state of an Mcrouter
|
||||
@ -49,6 +53,45 @@ spec:
|
||||
type: object
|
||||
route:
|
||||
type: string
|
||||
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:
|
||||
- pools
|
||||
- route
|
||||
|
@ -36,6 +36,49 @@ spec:
|
||||
properties:
|
||||
megabytes:
|
||||
type: integer
|
||||
nodeSelector:
|
||||
additionalProperties:
|
||||
type: string
|
||||
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:
|
||||
- megabytes
|
||||
type: object
|
||||
|
@ -34,6 +34,10 @@ spec:
|
||||
spec:
|
||||
description: McrouterSpec defines the desired state of Mcrouter
|
||||
properties:
|
||||
nodeSelector:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pools:
|
||||
additionalProperties:
|
||||
description: McrouterPoolSpec defines the desired state of an Mcrouter
|
||||
@ -49,6 +53,45 @@ spec:
|
||||
type: object
|
||||
route:
|
||||
type: string
|
||||
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:
|
||||
- pools
|
||||
- route
|
||||
|
@ -36,6 +36,49 @@ spec:
|
||||
properties:
|
||||
megabytes:
|
||||
type: integer
|
||||
nodeSelector:
|
||||
additionalProperties:
|
||||
type: string
|
||||
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:
|
||||
- megabytes
|
||||
type: object
|
||||
|
@ -203,6 +203,8 @@ func (r *McrouterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
},
|
||||
},
|
||||
},
|
||||
NodeSelector: mcrouter.Spec.NodeSelector,
|
||||
Tolerations: mcrouter.Spec.Tolerations,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -220,6 +220,9 @@ func (r *MemcachedReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
},
|
||||
}
|
||||
op, err = controllerutil.CreateOrUpdate(ctx, r, mcrouter, func() error {
|
||||
mcrouter.Spec.NodeSelector = memcached.Spec.NodeSelector
|
||||
mcrouter.Spec.Tolerations = memcached.Spec.Tolerations
|
||||
|
||||
mcrouter.Spec.Route = "PoolRoute|default"
|
||||
mcrouter.Spec.Pools = map[string]infrastructurev1alpha1.McrouterPoolSpec{
|
||||
"default": infrastructurev1alpha1.McrouterPoolSpec{
|
||||
|
Loading…
Reference in New Issue
Block a user