Skip to content

Commit

Permalink
Nat gw support toleration (#1907)
Browse files Browse the repository at this point in the history
* vpc-nat-gw支持toleration

Co-authored-by: yl4811 <yl4811@yealink.com>
  • Loading branch information
ShaPoHun and yl4811 committed Sep 16, 2022
1 parent b3bbe1d commit 8d2991e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 4 deletions.
15 changes: 15 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,21 @@ spec:
type: array
items:
type: string
tolerations:
type: array
items:
type: object
properties:
key:
type: string
operator:
type: string
value:
type: string
effect:
type: string
tolerationSeconds:
type: integer
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
17 changes: 13 additions & 4 deletions pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,19 @@ type VpcNatGateway struct {
}

type VpcNatSpec struct {
Vpc string `json:"vpc"`
Subnet string `json:"subnet"`
LanIp string `json:"lanIp"`
Selector []string `json:"selector"`
Vpc string `json:"vpc"`
Subnet string `json:"subnet"`
LanIp string `json:"lanIp"`
Selector []string `json:"selector"`
Tolerations []VpcNatToleration `json:"tolerations"`
}

type VpcNatToleration struct {
Key string `json:"key"`
Operator string `json:"operator"`
Value string `json:"value"`
Effect string `json:"effect"`
TolerationSeconds int64 `json:"tolerationSeconds"`
}

// +genclient
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/kubeovn/v1/zz_generated.deepcopy.go

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

16 changes: 16 additions & 0 deletions pkg/controller/vpc_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,21 @@ 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,
Expand Down Expand Up @@ -703,6 +718,7 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1
},
},
NodeSelector: selectors,
Tolerations: tolerations,
},
},
UpdateStrategy: v1.StatefulSetUpdateStrategy{
Expand Down

0 comments on commit 8d2991e

Please sign in to comment.