|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + "io" |
| 7 | + |
| 8 | + "k8s.io/kops/cmd/kops/util" |
| 9 | + "k8s.io/kops/pkg/apis/kops" |
| 10 | +) |
| 11 | + |
| 12 | +func AnnealCluster(ctx context.Context, f *util.Factory, out io.Writer, c *UpdateClusterOptions) error { |
| 13 | + fmt.Fprintf(out, "Updating control plane configuration\n") |
| 14 | + { |
| 15 | + opt := *c |
| 16 | + opt.Anneal = false // Prevent infinite loop |
| 17 | + opt.InstanceGroupRoles = []string{ |
| 18 | + string(kops.InstanceGroupRoleAPIServer), |
| 19 | + string(kops.InstanceGroupRoleControlPlane), |
| 20 | + } |
| 21 | + if _, err := RunUpdateCluster(ctx, f, out, &opt); err != nil { |
| 22 | + return err |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + fmt.Fprintf(out, "Doing rolling-update for control plane\n") |
| 27 | + { |
| 28 | + opt := &RollingUpdateOptions{} |
| 29 | + opt.InitDefaults() |
| 30 | + opt.ClusterName = c.ClusterName |
| 31 | + opt.InstanceGroupRoles = []string{ |
| 32 | + string(kops.InstanceGroupRoleAPIServer), |
| 33 | + string(kops.InstanceGroupRoleControlPlane), |
| 34 | + } |
| 35 | + opt.Yes = c.Yes |
| 36 | + if err := RunRollingUpdateCluster(ctx, f, out, opt); err != nil { |
| 37 | + return err |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + fmt.Fprintf(out, "Updating node configuration\n") |
| 42 | + { |
| 43 | + opt := *c |
| 44 | + opt.Anneal = false // Prevent infinite loop |
| 45 | + // TODO: or just do all roles? |
| 46 | + opt.InstanceGroupRoles = []string{ |
| 47 | + string(kops.InstanceGroupRoleBastion), |
| 48 | + string(kops.InstanceGroupRoleNode), |
| 49 | + } |
| 50 | + if _, err := RunUpdateCluster(ctx, f, out, &opt); err != nil { |
| 51 | + return err |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + fmt.Fprintf(out, "Doing rolling-update for nodes\n") |
| 56 | + { |
| 57 | + opt := &RollingUpdateOptions{} |
| 58 | + opt.InitDefaults() |
| 59 | + opt.ClusterName = c.ClusterName |
| 60 | + // TODO: or just do all roles? |
| 61 | + opt.InstanceGroupRoles = []string{ |
| 62 | + string(kops.InstanceGroupRoleBastion), |
| 63 | + string(kops.InstanceGroupRoleNode), |
| 64 | + } |
| 65 | + opt.Yes = c.Yes |
| 66 | + if err := RunRollingUpdateCluster(ctx, f, out, opt); err != nil { |
| 67 | + return err |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + return nil |
| 72 | +} |
0 commit comments