Skip to content

Commit

Permalink
improve version compatibility of yurtctl (#294)
Browse files Browse the repository at this point in the history
Signed-off-by: SataQiu <1527062125@qq.com>
  • Loading branch information
SataQiu authored May 10, 2021
1 parent e3d8c20 commit e53ae63
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
26 changes: 16 additions & 10 deletions pkg/yurtctl/cmd/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,22 @@ func (co *ConvertOptions) RunConvert() (err error) {
if err != nil {
return err
}
if err = kubeutil.RunServantJobs(co.clientSet, map[string]string{
"provider": string(co.Provider),
"action": "convert",
"yurtctl_servant_image": co.YurctlServantImage,
"yurthub_image": co.YurhubImage,
"yurthub_healthcheck_timeout": co.YurthubHealthCheckTimeout.String(),
"joinToken": joinToken,
"pod_manifest_path": co.PodMainfestPath,
"kubeadm_conf_path": co.KubeadmConfPath,
}, edgeNodeNames, true); err != nil {

ctx := map[string]string{
"provider": string(co.Provider),
"action": "convert",
"yurtctl_servant_image": co.YurctlServantImage,
"yurthub_image": co.YurhubImage,
"joinToken": joinToken,
"pod_manifest_path": co.PodMainfestPath,
"kubeadm_conf_path": co.KubeadmConfPath,
}

if co.YurthubHealthCheckTimeout != defaultYurthubHealthCheckTimeout {
ctx["yurthub_healthcheck_timeout"] = co.YurthubHealthCheckTimeout.String()
}

if err = kubeutil.RunServantJobs(co.clientSet, ctx, edgeNodeNames, true); err != nil {
klog.Errorf("fail to run ServantJobs: %s", err)
return
}
Expand Down
24 changes: 15 additions & 9 deletions pkg/yurtctl/cmd/convert/edgenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,21 @@ func (c *ConvertEdgeNodeOptions) RunConvertEdgeNode() (err error) {
if err != nil {
return err
}
if err = kubeutil.RunServantJobs(c.clientSet, map[string]string{
"action": "convert",
"yurtctl_servant_image": c.YurctlServantImage,
"yurthub_image": c.YurthubImage,
"yurthub_healthcheck_timeout": c.YurthubHealthCheckTimeout.String(),
"joinToken": joinToken,
"pod_manifest_path": c.PodMainfestPath,
"kubeadm_conf_path": c.KubeadmConfPath,
}, c.EdgeNodes, true); err != nil {

ctx := map[string]string{
"action": "convert",
"yurtctl_servant_image": c.YurctlServantImage,
"yurthub_image": c.YurthubImage,
"joinToken": joinToken,
"pod_manifest_path": c.PodMainfestPath,
"kubeadm_conf_path": c.KubeadmConfPath,
}

if c.YurthubHealthCheckTimeout != defaultYurthubHealthCheckTimeout {
ctx["yurthub_healthcheck_timeout"] = c.YurthubHealthCheckTimeout.String()
}

if err = kubeutil.RunServantJobs(c.clientSet, ctx, c.EdgeNodes, true); err != nil {
klog.Errorf("fail to run ServantJobs: %s", err)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurtctl/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ spec:
- /bin/sh
- -c
args:
- "cp /usr/local/bin/yurtctl /tmp && nsenter -t 1 -m -u -n -i -- /var/tmp/yurtctl convert edgenode --yurthub-image {{.yurthub_image}} --yurthub-healthcheck-timeout {{.yurthub_healthcheck_timeout}} --join-token {{.joinToken}} && rm /tmp/yurtctl"
- "cp /usr/local/bin/yurtctl /tmp && nsenter -t 1 -m -u -n -i -- /var/tmp/yurtctl convert edgenode --yurthub-image {{.yurthub_image}} {{if .yurthub_healthcheck_timeout}}--yurthub-healthcheck-timeout {{.yurthub_healthcheck_timeout}} {{end}}--join-token {{.joinToken}} && rm /tmp/yurtctl"
securityContext:
privileged: true
volumeMounts:
Expand Down

0 comments on commit e53ae63

Please sign in to comment.