diff --git a/pkg/yurtctl/util/kubernetes/apply_addons.go b/pkg/yurtctl/util/kubernetes/apply_addons.go index c643fa7b7d4..5c62bd787f9 100644 --- a/pkg/yurtctl/util/kubernetes/apply_addons.go +++ b/pkg/yurtctl/util/kubernetes/apply_addons.go @@ -106,6 +106,7 @@ func DeployYurtAppManager( // 7. create the Service if err := CreateServiceFromYaml(client, + SystemNamespace, constants.YurtAppManagerService); err != nil { return err } @@ -161,12 +162,14 @@ func DeployYurttunnelServer( // 4. create the Service if err := CreateServiceFromYaml(client, + SystemNamespace, constants.YurttunnelServerService); err != nil { return err } // 5. create the internal Service(type=ClusterIP) if err := CreateServiceFromYaml(client, + SystemNamespace, constants.YurttunnelServerInternalService); err != nil { return err } @@ -199,6 +202,7 @@ func DeployYurttunnelAgent( yurttunnelAgentImage string) error { // 1. Deploy the yurt-tunnel-agent DaemonSet if err := CreateDaemonSetFromYaml(client, + SystemNamespace, constants.YurttunnelAgentDaemonSet, map[string]string{ "image": yurttunnelAgentImage, diff --git a/pkg/yurtctl/util/kubernetes/util.go b/pkg/yurtctl/util/kubernetes/util.go index a4de554d807..2529898c20a 100644 --- a/pkg/yurtctl/util/kubernetes/util.go +++ b/pkg/yurtctl/util/kubernetes/util.go @@ -194,7 +194,7 @@ func CreateDeployFromYaml(cliSet *kubernetes.Clientset, ns, dplyTmpl string, ctx } // CreateDaemonSetFromYaml creates the DaemonSet from the yaml template. -func CreateDaemonSetFromYaml(cliSet *kubernetes.Clientset, dsTmpl string, ctx interface{}) error { +func CreateDaemonSetFromYaml(cliSet *kubernetes.Clientset, ns, dsTmpl string, ctx interface{}) error { var ytadstmp string var err error if ctx != nil { @@ -214,7 +214,7 @@ func CreateDaemonSetFromYaml(cliSet *kubernetes.Clientset, dsTmpl string, ctx in if !ok { return fmt.Errorf("fail to assert daemonset: %v", err) } - _, err = cliSet.AppsV1().DaemonSets(SystemNamespace).Create(context.Background(), ds, metav1.CreateOptions{}) + _, err = cliSet.AppsV1().DaemonSets(ns).Create(context.Background(), ds, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("fail to create the daemonset/%s: %v", ds.Name, err) } @@ -223,7 +223,7 @@ func CreateDaemonSetFromYaml(cliSet *kubernetes.Clientset, dsTmpl string, ctx in } // CreateServiceFromYaml creates the Service from the yaml template. -func CreateServiceFromYaml(cliSet *kubernetes.Clientset, svcTmpl string) error { +func CreateServiceFromYaml(cliSet *kubernetes.Clientset, ns, svcTmpl string) error { obj, err := YamlToObject([]byte(svcTmpl)) if err != nil { return err @@ -232,7 +232,7 @@ func CreateServiceFromYaml(cliSet *kubernetes.Clientset, svcTmpl string) error { if !ok { return fmt.Errorf("fail to assert service: %v", err) } - _, err = cliSet.CoreV1().Services(SystemNamespace).Create(context.Background(), svc, metav1.CreateOptions{}) + _, err = cliSet.CoreV1().Services(ns).Create(context.Background(), svc, metav1.CreateOptions{}) return processCreateErr("service", svc.Name, err) }