From 16dbbd11d051b6fe7905388d3d2fb3b1b22207b4 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 9 Mar 2022 11:15:40 +0000 Subject: [PATCH] Update for config-sync sidecar --- client/router_update.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/router_update.go b/client/router_update.go index 0af38b9dd..be90bd948 100644 --- a/client/router_update.go +++ b/client/router_update.go @@ -381,6 +381,15 @@ func (cli *VanClient) RouterUpdateVersionInNamespace(ctx context.Context, hup bo router.Spec.Template.Spec.Containers[0].Image = desiredRouterImage updateRouter = true } + configSync := ConfigSyncContainer() + if !hasContainer(configSync.Name, router.Spec.Template.Spec.Containers) { + err = kube.UpdateRole(namespace, types.TransportRoleName, types.TransportPolicyRule, cli.KubeClient) + if err != nil { + return false, err + } + router.Spec.Template.Spec.Containers = append(router.Spec.Template.Spec.Containers, *configSync) + updateRouter = true + } if updateRouter || updateSite || hup { if !updateRouter { // need to trigger a router redployment to pick up the revised metadata field @@ -1043,3 +1052,12 @@ func (cli *VanClient) GetSiteMetadata() (*qdr.SiteMetadata, error) { metadata := config.GetSiteMetadata() return &metadata, nil } + +func hasContainer(name string, containers []corev1.Container) bool { + for _, c := range containers { + if c.Name == name { + return true + } + } + return false +}