Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(installer): upgrade gateway in installer #1565

Merged
merged 1 commit into from
Sep 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions cmd/tke-installer/app/installer/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ func (t *TKE) upgradeSteps() {
}

t.steps = append(t.steps, []types.Handler{
{
Name: "Prepare images before upgrade",
Func: t.prepareImages,
},
{
Name: "Upgrade tke-platform-api",
Func: t.upgradeTKEPlatformAPI,
Expand All @@ -96,6 +100,10 @@ func (t *TKE) upgradeSteps() {
Name: "Upgrade tke-monitor-controller",
Func: t.upgradeTKEMonitorController,
},
{
Name: "Upgrade tke-gateway",
Func: t.upgradeTKEGateway,
},
}...)

t.steps = append(t.steps, []types.Handler{
Expand Down Expand Up @@ -266,6 +274,32 @@ func (t *TKE) upgradeTKEMonitorController(ctx context.Context) error {
})
}

func (t *TKE) upgradeTKEGateway(ctx context.Context) error {
com := "tke-gateway"
ds, err := t.globalClient.AppsV1().DaemonSets(t.namespace).Get(ctx, com, metav1.GetOptions{})
if err != nil {
return err
}

if len(ds.Spec.Template.Spec.Containers) == 0 {
return fmt.Errorf("%s has no containers", com)
}
ds.Spec.Template.Spec.Containers[0].Image = images.Get().TKEGateway.FullName()

_, err = t.globalClient.AppsV1().DaemonSets(t.namespace).Update(ctx, ds, metav1.UpdateOptions{})
if err != nil {
return err
}

return wait.PollImmediate(5*time.Second, 10*time.Minute, func() (bool, error) {
ok, err := apiclient.CheckDaemonset(ctx, t.globalClient, t.namespace, com)
if err != nil {
return false, nil
}
return ok, nil
})
}

func (t *TKE) prepareForUpgrade(ctx context.Context) error {
t.namespace = namespace

Expand Down