Skip to content

Commit

Permalink
add tunnelServerAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoulei5 committed Sep 24, 2021
1 parent 4fa1d93 commit a68957e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
12 changes: 11 additions & 1 deletion pkg/yurtctl/cmd/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type ConvertOptions struct {
YurtControllerManagerImage string
YurctlServantImage string
YurttunnelServerImage string
YurttunnelServerAddress string
YurttunnelAgentImage string
PodMainfestPath string
KubeadmConfPath string
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurtctl/cmd/yurtinit/phases/install_yurt_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/yurtctl/constants/yurt-tunnel-agent-tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ spec:
name: https
- port: 10262
targetPort: 10262
nodePort: 31008
name: tcp
selector:
k8s-app: yurt-tunnel-server
Expand Down
7 changes: 4 additions & 3 deletions pkg/yurtctl/util/kubernetes/apply_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a68957e

Please sign in to comment.