github.com/SUSE/skuba@v1.4.17/pkg/skuba/actions/node/upgrade/plan.go (about) 1 /* 2 * Copyright (c) 2019 SUSE LLC. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package upgrade 19 20 import ( 21 "fmt" 22 23 "github.com/SUSE/skuba/internal/pkg/skuba/kubeadm" 24 "github.com/SUSE/skuba/internal/pkg/skuba/kubernetes" 25 upgradenode "github.com/SUSE/skuba/internal/pkg/skuba/upgrade/node" 26 clientset "k8s.io/client-go/kubernetes" 27 ) 28 29 func Plan(client clientset.Interface, nodeName string) error { 30 currentClusterVersion, err := kubeadm.GetCurrentClusterVersion(client) 31 if err != nil { 32 return err 33 } 34 nodeVersionInfoUpdate, err := upgradenode.UpdateStatus(client, nodeName) 35 if err != nil { 36 return err 37 } 38 39 fmt.Printf("Current Kubernetes cluster version: %s\n", currentClusterVersion.String()) 40 fmt.Printf("Latest Kubernetes version: %s\n", kubernetes.LatestVersion().String()) 41 fmt.Printf("Current Node version: %s\n", nodeVersionInfoUpdate.Current.KubeletVersion.String()) 42 fmt.Println() 43 44 if nodeVersionInfoUpdate.IsUpdated() { 45 fmt.Printf("Node %s is up to date\n", nodeName) 46 } else { 47 fmt.Printf("Component versions in %s\n", nodeName) 48 if nodeVersionInfoUpdate.Current.IsControlPlane() { 49 fmt.Printf(" - apiserver: %s -> %s\n", nodeVersionInfoUpdate.Current.APIServerVersion.String(), nodeVersionInfoUpdate.Update.APIServerVersion.String()) 50 fmt.Printf(" - controller-manager: %s -> %s\n", nodeVersionInfoUpdate.Current.ControllerManagerVersion.String(), nodeVersionInfoUpdate.Update.ControllerManagerVersion.String()) 51 fmt.Printf(" - scheduler: %s -> %s\n", nodeVersionInfoUpdate.Current.SchedulerVersion.String(), nodeVersionInfoUpdate.Update.SchedulerVersion.String()) 52 fmt.Printf(" - etcd: %s -> %s\n", nodeVersionInfoUpdate.Current.EtcdVersion.String(), nodeVersionInfoUpdate.Update.EtcdVersion.String()) 53 } 54 fmt.Printf(" - kubelet: %s -> %s\n", nodeVersionInfoUpdate.Current.KubeletVersion.String(), nodeVersionInfoUpdate.Update.KubeletVersion.String()) 55 fmt.Printf(" - cri-o: %s -> %s\n", nodeVersionInfoUpdate.Current.ContainerRuntimeVersion.String(), nodeVersionInfoUpdate.Update.ContainerRuntimeVersion.String()) 56 57 // Check if the node is upgradeable (matches preconditions) 58 if err := nodeVersionInfoUpdate.NodeUpgradeableCheck(client, currentClusterVersion); err != nil { 59 fmt.Println() 60 return err 61 } 62 } 63 64 return nil 65 }