diff --git a/pkg/yurtctl/cmd/convert/convert.go b/pkg/yurtctl/cmd/convert/convert.go index c405d4da83d..690ecf3d22c 100644 --- a/pkg/yurtctl/cmd/convert/convert.go +++ b/pkg/yurtctl/cmd/convert/convert.go @@ -69,6 +69,7 @@ type ConvertOptions struct { YurtControllerManagerImage string YurctlServantImage string YurttunnelServerImage string + YurttunnelServerAddress string YurttunnelAgentImage string PodMainfestPath string KubeadmConfPath string @@ -129,6 +130,9 @@ func NewConvertCmd() *cobra.Command { cmd.Flags().String("yurt-tunnel-server-image", "openyurt/yurt-tunnel-server:latest", "The yurt-tunnel-server image.") + cmd.Flags().String("yurt-tunnel-server-address", + "", + "The yurt-tunnel-server address.") cmd.Flags().String("yurt-tunnel-agent-image", "openyurt/yurt-tunnel-agent:latest", "The yurt-tunnel-agent image.") @@ -206,6 +210,12 @@ func (co *ConvertOptions) Complete(flags *pflag.FlagSet) error { } co.YurttunnelServerImage = ytsi + ytsa, err := flags.GetString("yurt-tunnel-server-address") + if err != nil { + return err + } + co.YurttunnelServerAddress = ytsa + ytai, err := flags.GetString("yurt-tunnel-agent-image") if err != nil { return err @@ -351,7 +361,7 @@ func (co *ConvertOptions) RunConvert() (err error) { klog.Info("yurt-tunnel-server is deployed") // we will deploy yurt-tunnel-agent on every edge node if err = kubeutil.DeployYurttunnelAgent(co.clientSet, - edgeNodeNames, + co.YurttunnelServerAddress, co.YurttunnelAgentImage); err != nil { err = fmt.Errorf("fail to deploy the yurt-tunnel-agent: %s", err) return diff --git a/pkg/yurtctl/cmd/yurtinit/phases/install_yurt_addons.go b/pkg/yurtctl/cmd/yurtinit/phases/install_yurt_addons.go index b1cd3a47ef0..f91b5fc6e22 100644 --- a/pkg/yurtctl/cmd/yurtinit/phases/install_yurt_addons.go +++ b/pkg/yurtctl/cmd/yurtinit/phases/install_yurt_addons.go @@ -77,7 +77,7 @@ func runInstallYurtAddons(c workflow.RunData) error { if err := kubeutil.DeployYurttunnelServer(client, nil, fmt.Sprintf("%s/%s:%s", imageRegistry, YurtContants.YurtTunnelServer, version), runtime.GOARCH); err != nil { return err } - if err := kubeutil.DeployYurttunnelAgent(client, nil, fmt.Sprintf("%s/%s:%s", imageRegistry, YurtContants.YurtTunnelAgent, version)); err != nil { + if err := kubeutil.DeployYurttunnelAgent(client, "", fmt.Sprintf("%s/%s:%s", imageRegistry, YurtContants.YurtTunnelAgent, version)); err != nil { return err } return nil diff --git a/pkg/yurtctl/constants/yurt-tunnel-agent-tmpl.go b/pkg/yurtctl/constants/yurt-tunnel-agent-tmpl.go index 7c522b39add..2bc17da6a27 100644 --- a/pkg/yurtctl/constants/yurt-tunnel-agent-tmpl.go +++ b/pkg/yurtctl/constants/yurt-tunnel-agent-tmpl.go @@ -42,6 +42,9 @@ spec: - yurt-tunnel-agent args: - --node-name=$(NODE_NAME) + {{if .tunnelServerAddress }} + - --tunnelserver-addr={{.tunnelServerAddress}} + {{end}} image: {{.image}} imagePullPolicy: IfNotPresent name: yurt-tunnel-agent diff --git a/pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go b/pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go index 081f5006398..c7de0e4e249 100644 --- a/pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go +++ b/pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go @@ -125,6 +125,7 @@ spec: name: https - port: 10262 targetPort: 10262 + nodePort: 31008 name: tcp selector: k8s-app: yurt-tunnel-server diff --git a/pkg/yurtctl/util/kubernetes/apply_addons.go b/pkg/yurtctl/util/kubernetes/apply_addons.go index 69e0c2d3884..2921a5efbad 100644 --- a/pkg/yurtctl/util/kubernetes/apply_addons.go +++ b/pkg/yurtctl/util/kubernetes/apply_addons.go @@ -194,14 +194,15 @@ func DeployYurttunnelServer( func DeployYurttunnelAgent( client *kubernetes.Clientset, - tunnelAgentNodes []string, + tunnelServerAddress string, yurttunnelAgentImage string) error { // 1. Deploy the yurt-tunnel-agent DaemonSet if err := CreateDaemonSetFromYaml(client, constants.YurttunnelAgentDaemonSet, map[string]string{ - "image": yurttunnelAgentImage, - "edgeWorkerLabel": projectinfo.GetEdgeWorkerLabelKey()}); err != nil { + "image": yurttunnelAgentImage, + "edgeWorkerLabel": projectinfo.GetEdgeWorkerLabelKey(), + "tunnelServerAddress": tunnelServerAddress}); err != nil { return err } return nil