Skip to content

Commit

Permalink
handle update deployment vpc-nat-gw
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyanker committed Apr 28, 2021
1 parent cef78f1 commit fc92fbc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/controller/vpc_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ func (c *Controller) handleAddOrUpdateVpcNatGw(key string) error {
return err
}
return nil
} else {
_, err := c.config.KubeClient.AppsV1().Deployments(c.config.PodNamespace).
Update(context.Background(), newDp, metav1.UpdateOptions{})

if err != nil {
klog.Errorf("failed to update deployment %s, err: %v", newDp.Name, err)
return err
}
}

pod, err := c.getNatGwPod(key)
Expand Down Expand Up @@ -660,7 +668,7 @@ func (c *Controller) handleUpdateNatGwSubnetRoute(natGwKey string) error {
}

func (c *Controller) execNatGwRules(pod *corev1.Pod, operation string, rules []string) error {
stdOutput, errOutput, err := util.ExecuteCommandInContainer(c.config.KubeClient, c.config.KubeRestConfig, pod.Namespace, pod.Name, "vpc-gat-gw",
stdOutput, errOutput, err := util.ExecuteCommandInContainer(c.config.KubeClient, c.config.KubeRestConfig, pod.Namespace, pod.Name, "vpc-nat-gw",
[]string{"/bin/bash", "-c", fmt.Sprintf("bash /kube-ovn/nat-gateway.sh %s %s", operation, strings.Join(rules, " "))}...)

if err != nil {
Expand Down Expand Up @@ -718,7 +726,7 @@ func (c *Controller) genNatGwDeployment(gw *kubeovnv1.VpcNatGateway) (dp *v1.Dep
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "vpc-gat-gw",
Name: "vpc-nat-gw",
Image: vpcNatImage,
Command: []string{"bash"},
Args: []string{"-c", "while true; do sleep 10000; done"},
Expand Down Expand Up @@ -753,7 +761,7 @@ func (c *Controller) cleanUpVpcNatGw() error {

func (c *Controller) getNatGwPod(name string) (*corev1.Pod, error) {
sel, _ := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{"app": genNatGwDpName(name)},
MatchLabels: map[string]string{"app": genNatGwDpName(name), util.VpcNatGatewayLabel: "true"},
})

pods, err := c.podsLister.Pods(c.config.PodNamespace).List(sel)
Expand Down

0 comments on commit fc92fbc

Please sign in to comment.