github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/pkg/cluster-runtime/upgrader.go (about) 1 // Copyright © 2022 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package clusterruntime 16 17 import ( 18 "net" 19 20 "github.com/sealerio/sealer/common" 21 "github.com/sealerio/sealer/pkg/registry" 22 ) 23 24 func (i *Installer) Upgrade() error { 25 var ( 26 masters = i.infraDriver.GetHostIPListByRole(common.MASTER) 27 master0 = masters[0] 28 workers = getWorkerIPList(i.infraDriver) 29 all = append(masters, workers...) 30 rootfs = i.infraDriver.GetClusterRootfsPath() 31 ) 32 33 // distribute rootfs 34 if err := i.Distributor.Distribute(all, rootfs); err != nil { 35 return err 36 } 37 38 if err := i.runHostHook(UpgradeHost, all); err != nil { 39 return err 40 } 41 42 crInfo, err := i.containerRuntimeInstaller.GetInfo() 43 if err != nil { 44 return err 45 } 46 47 var deployHosts []net.IP 48 if i.regConfig.LocalRegistry != nil { 49 installer := registry.NewInstaller(nil, i.regConfig.LocalRegistry, i.infraDriver, i.Distributor) 50 if *i.regConfig.LocalRegistry.HA { 51 deployHosts, err = installer.Reconcile(masters) 52 if err != nil { 53 return err 54 } 55 } else { 56 deployHosts, err = installer.Reconcile([]net.IP{master0}) 57 if err != nil { 58 return err 59 } 60 } 61 } 62 registryConfigurator, err := registry.NewConfigurator(deployHosts, crInfo, i.regConfig, i.infraDriver, i.Distributor) 63 if err != nil { 64 return err 65 } 66 67 if err = registryConfigurator.InstallOn(masters, workers); err != nil { 68 return err 69 } 70 71 if err := i.runClusterHook(master0, UpgradeCluster); err != nil { 72 return err 73 } 74 75 return nil 76 }