From 04e65c31012c854048b45496fae45b28c47089b9 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 21 Jun 2018 19:39:25 +0800 Subject: [PATCH] fix router service label --- pkg/models/routes.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/models/routes.go b/pkg/models/routes.go index 781fa5b97..1c29c4322 100644 --- a/pkg/models/routes.go +++ b/pkg/models/routes.go @@ -130,6 +130,7 @@ func CreateRouter(namespace string, routerType coreV1.ServiceType, annotations m service.Name = constants.IngressControllerPrefix + namespace // Add project selector + service.Labels["project"] = namespace service.Spec.Selector["project"] = namespace service, err := k8sClient.CoreV1().Services(constants.IngressControllerNamespace).Create(service) @@ -145,7 +146,8 @@ func CreateRouter(namespace string, routerType coreV1.ServiceType, annotations m deployment.Name = constants.IngressControllerPrefix + namespace // Add project label - deployment.Labels["project"] = namespace + deployment.Spec.Selector.MatchLabels["project"] = namespace + deployment.Spec.Template.Labels["project"] = namespace deployment.Spec.Template.Spec.Containers[0].Args = append(deployment.Spec.Template.Spec.Containers[0].Args, "--watch-namespace="+namespace) glog.Info(deployment.Spec.Template.Spec.Containers[0].Args)