Skip to content

Commit

Permalink
add init container in vpc-nat-gateway statefulset for init (#3254)
Browse files Browse the repository at this point in the history
* add initcontainer for vpc-nat-gw statefulset for init

---------

Signed-off-by: xiongww <xiongww@chinatelecom.cn>
Co-authored-by: xiongww <xiongww@chinatelecom.cn>
  • Loading branch information
2 people authored and bobz965 committed Sep 26, 2023
1 parent 1156c03 commit 70a1352
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/controller/vpc_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1
selectors[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
}
klog.V(3).Infof("prepare for vpc nat gateway pod, node selector: %v", selectors)

v4SubnetGw, _, _ := c.GetGwBySubnet(gw.Spec.Subnet)
newSts = &v1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down Expand Up @@ -797,6 +797,19 @@ func (c *Controller) genNatGwStatefulSet(gw *kubeovnv1.VpcNatGateway, oldSts *v1
},
},
},
InitContainers: []corev1.Container{
{
Name: "vpc-nat-gw-init",
Image: vpcNatImage,
Command: []string{"bash"},
Args: []string{"-c", fmt.Sprintf("bash /kube-ovn/nat-gateway.sh init %s,%s", c.config.ServiceClusterIPRange, v4SubnetGw)},
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: &privileged,
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
},
},
},
NodeSelector: selectors,
Tolerations: gw.Spec.Tolerations,
Affinity: &gw.Spec.Affinity,
Expand Down

0 comments on commit 70a1352

Please sign in to comment.