diff --git a/dist/images/install.sh b/dist/images/install.sh index 8c57e7aa235..dd68b24b905 100755 --- a/dist/images/install.sh +++ b/dist/images/install.sh @@ -410,10 +410,17 @@ spec: type: string operator: type: string + enum: + - Equal + - Exists value: type: string effect: type: string + enum: + - NoExecute + - NoSchedule + - PreferNoSchedule tolerationSeconds: type: integer affinity: diff --git a/kubeovn-helm/templates/kube-ovn-crd.yaml b/kubeovn-helm/templates/kube-ovn-crd.yaml index 28c449346b8..5a3c54667e7 100644 --- a/kubeovn-helm/templates/kube-ovn-crd.yaml +++ b/kubeovn-helm/templates/kube-ovn-crd.yaml @@ -191,10 +191,17 @@ spec: type: string operator: type: string + enum: + - Equal + - Exists value: type: string effect: type: string + enum: + - NoExecute + - NoSchedule + - PreferNoSchedule tolerationSeconds: type: integer affinity: diff --git a/pkg/apis/kubeovn/v1/types.go b/pkg/apis/kubeovn/v1/types.go index c8a23c95f70..f9ef6160f57 100644 --- a/pkg/apis/kubeovn/v1/types.go +++ b/pkg/apis/kubeovn/v1/types.go @@ -462,20 +462,12 @@ type VpcNatGateway struct { } type VpcNatSpec struct { - Vpc string `json:"vpc"` - Subnet string `json:"subnet"` - LanIp string `json:"lanIp"` - Selector []string `json:"selector"` - Tolerations []VpcNatToleration `json:"tolerations"` - Affinity corev1.Affinity `json:"affinity"` -} - -type VpcNatToleration struct { - Key string `json:"key"` - Operator string `json:"operator"` - Value string `json:"value"` - Effect string `json:"effect"` - TolerationSeconds int64 `json:"tolerationSeconds"` + Vpc string `json:"vpc"` + Subnet string `json:"subnet"` + LanIp string `json:"lanIp"` + Selector []string `json:"selector"` + Tolerations []corev1.Toleration `json:"tolerations"` + Affinity corev1.Affinity `json:"affinity"` } // +genclient diff --git a/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go b/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go index 0f60d2128f0..6e202ef233e 100644 --- a/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go +++ b/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ limitations under the License. package v1 import ( + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -2210,9 +2211,12 @@ func (in *VpcNatSpec) DeepCopyInto(out *VpcNatSpec) { } if in.Tolerations != nil { in, out := &in.Tolerations, &out.Tolerations - *out = make([]VpcNatToleration, len(*in)) - copy(*out, *in) + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } + in.Affinity.DeepCopyInto(&out.Affinity) return } @@ -2226,22 +2230,6 @@ func (in *VpcNatSpec) DeepCopy() *VpcNatSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VpcNatToleration) DeepCopyInto(out *VpcNatToleration) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VpcNatToleration. -func (in *VpcNatToleration) DeepCopy() *VpcNatToleration { - if in == nil { - return nil - } - out := new(VpcNatToleration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VpcPeering) DeepCopyInto(out *VpcPeering) { *out = *in diff --git a/pkg/controller/vpc_nat_gateway.go b/pkg/controller/vpc_nat_gateway.go index 3268efb4fbb..ff0af6555cb 100644 --- a/pkg/controller/vpc_nat_gateway.go +++ b/pkg/controller/vpc_nat_gateway.go @@ -685,21 +685,6 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1 } klog.V(3).Infof("prepare for vpc nat gateway pod, node selector: %v", selectors) - var tolerations []corev1.Toleration - for _, t := range gw.Spec.Tolerations { - toleration := corev1.Toleration{ - Key: t.Key, - Value: t.Value, - Effect: corev1.TaintEffect(t.Effect), - Operator: corev1.TolerationOperator(t.Operator), - } - - if t.TolerationSeconds != 0 { - toleration.TolerationSeconds = &t.TolerationSeconds - } - tolerations = append(tolerations, toleration) - } - newSts = &v1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -730,7 +715,7 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1 }, }, NodeSelector: selectors, - Tolerations: tolerations, + Tolerations: gw.Spec.Tolerations, Affinity: &gw.Spec.Affinity, }, }, diff --git a/yamls/crd.yaml b/yamls/crd.yaml index 82bf9d7e485..60acaa790de 100644 --- a/yamls/crd.yaml +++ b/yamls/crd.yaml @@ -191,10 +191,17 @@ spec: type: string operator: type: string + enum: + - Equal + - Exists value: type: string effect: type: string + enum: + - NoExecute + - NoSchedule + - PreferNoSchedule tolerationSeconds: type: integer affinity: