forked from Azure/acs-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgradecluster.go
50 lines (43 loc) · 1.52 KB
/
upgradecluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package dcosupgrade
import (
"github.com/Azure/acs-engine/pkg/api"
"github.com/Azure/acs-engine/pkg/armhelpers"
"github.com/Azure/acs-engine/pkg/i18n"
uuid "github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
)
// ClusterTopology contains resources of the cluster the upgrade operation
// is targeting
type ClusterTopology struct {
DataModel *api.ContainerService
Location string
ResourceGroup string
CurrentDcosVersion string
NameSuffix string
SSHKey []byte
}
// UpgradeCluster upgrades a cluster with Orchestrator version X.X to version Y.Y.
// Right now upgrades are supported for Kubernetes cluster only.
type UpgradeCluster struct {
Translator *i18n.Translator
Logger *logrus.Entry
ClusterTopology
Client armhelpers.ACSEngineClient
}
// UpgradeCluster runs the workflow to upgrade a DCOS cluster.
func (uc *UpgradeCluster) UpgradeCluster(subscriptionID uuid.UUID, resourceGroup, currentDcosVersion string,
cs *api.ContainerService, nameSuffix string, sshKey []byte) error {
uc.ClusterTopology = ClusterTopology{}
uc.ResourceGroup = resourceGroup
uc.CurrentDcosVersion = currentDcosVersion
uc.DataModel = cs
uc.NameSuffix = nameSuffix
uc.SSHKey = sshKey
upgradeVersion := uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion
uc.Logger.Infof("Upgrading DCOS from %s to %s", uc.CurrentDcosVersion, upgradeVersion)
if err := uc.runUpgrade(); err != nil {
return err
}
uc.Logger.Infof("Cluster upgraded successfully to DCOS %s", upgradeVersion)
return nil
}