mirror of https://github.com/kubernetes/kops.git
Add rolling upgrade to openstack
This commit is contained in:
parent
a39beb20c8
commit
aa66c4f6d8
|
|
@ -328,6 +328,7 @@ func RunRollingUpdateCluster(ctx context.Context, f *util.Factory, out io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
d := &instancegroups.RollingUpdateCluster{
|
d := &instancegroups.RollingUpdateCluster{
|
||||||
|
Clientset: clientset,
|
||||||
Ctx: ctx,
|
Ctx: ctx,
|
||||||
Cluster: cluster,
|
Cluster: cluster,
|
||||||
MasterInterval: options.MasterInterval,
|
MasterInterval: options.MasterInterval,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ go_library(
|
||||||
"//pkg/featureflag:go_default_library",
|
"//pkg/featureflag:go_default_library",
|
||||||
"//pkg/validation:go_default_library",
|
"//pkg/validation:go_default_library",
|
||||||
"//upup/pkg/fi:go_default_library",
|
"//upup/pkg/fi:go_default_library",
|
||||||
|
"//upup/pkg/fi/cloudup:go_default_library",
|
||||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
|
|
@ -40,8 +41,6 @@ go_test(
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//cloudmock/aws/mockautoscaling:go_default_library",
|
"//cloudmock/aws/mockautoscaling:go_default_library",
|
||||||
"//cloudmock/openstack/mockcompute:go_default_library",
|
|
||||||
"//cloudmock/openstack/mocknetworking:go_default_library",
|
|
||||||
"//pkg/apis/kops:go_default_library",
|
"//pkg/apis/kops:go_default_library",
|
||||||
"//pkg/assets:go_default_library",
|
"//pkg/assets:go_default_library",
|
||||||
"//pkg/client/simple/vfsclientset:go_default_library",
|
"//pkg/client/simple/vfsclientset:go_default_library",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
|
"k8s.io/kops/upup/pkg/fi/cloudup"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
@ -371,6 +374,11 @@ func (c *RollingUpdateCluster) drainTerminateAndWait(u *cloudinstances.CloudInst
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := c.reconcileInstanceGroup(); err != nil {
|
||||||
|
klog.Errorf("error reconciling instance group %q: %v", u.CloudInstanceGroup.HumanName, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for the minimum interval
|
// Wait for the minimum interval
|
||||||
klog.Infof("waiting for %v after terminating instance", sleepAfterTerminate)
|
klog.Infof("waiting for %v after terminating instance", sleepAfterTerminate)
|
||||||
time.Sleep(sleepAfterTerminate)
|
time.Sleep(sleepAfterTerminate)
|
||||||
|
|
@ -378,6 +386,29 @@ func (c *RollingUpdateCluster) drainTerminateAndWait(u *cloudinstances.CloudInst
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *RollingUpdateCluster) reconcileInstanceGroup() error {
|
||||||
|
if api.CloudProviderID(c.Cluster.Spec.CloudProvider) != api.CloudProviderOpenstack {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
rto := fi.RunTasksOptions{}
|
||||||
|
rto.InitDefaults()
|
||||||
|
applyCmd := &cloudup.ApplyClusterCmd{
|
||||||
|
Cloud: c.Cloud,
|
||||||
|
Clientset: c.Clientset,
|
||||||
|
Cluster: c.Cluster,
|
||||||
|
DryRun: false,
|
||||||
|
AllowKopsDowngrade: true,
|
||||||
|
RunTasksOptions: &rto,
|
||||||
|
OutDir: "",
|
||||||
|
Phase: "",
|
||||||
|
TargetName: "direct",
|
||||||
|
LifecycleOverrides: map[string]fi.Lifecycle{},
|
||||||
|
}
|
||||||
|
|
||||||
|
return applyCmd.Run(c.Ctx)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (c *RollingUpdateCluster) maybeValidate(operation string, validateCount int) error {
|
func (c *RollingUpdateCluster) maybeValidate(operation string, validateCount int) error {
|
||||||
if c.CloudOnly {
|
if c.CloudOnly {
|
||||||
klog.Warningf("Not validating cluster as cloudonly flag is set.")
|
klog.Warningf("Not validating cluster as cloudonly flag is set.")
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"k8s.io/kops/pkg/client/simple"
|
||||||
|
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
api "k8s.io/kops/pkg/apis/kops"
|
api "k8s.io/kops/pkg/apis/kops"
|
||||||
|
|
@ -33,9 +35,10 @@ import (
|
||||||
|
|
||||||
// RollingUpdateCluster is a struct containing cluster information for a rolling update.
|
// RollingUpdateCluster is a struct containing cluster information for a rolling update.
|
||||||
type RollingUpdateCluster struct {
|
type RollingUpdateCluster struct {
|
||||||
Ctx context.Context
|
Clientset simple.Clientset
|
||||||
Cluster *api.Cluster
|
Ctx context.Context
|
||||||
Cloud fi.Cloud
|
Cluster *api.Cluster
|
||||||
|
Cloud fi.Cloud
|
||||||
|
|
||||||
// MasterInterval is the amount of time to wait after stopping a master instance
|
// MasterInterval is the amount of time to wait after stopping a master instance
|
||||||
MasterInterval time.Duration
|
MasterInterval time.Duration
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,6 @@ func (c *openstackCloud) DeleteInstance(i *cloudinstances.CloudInstance) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteInstance(c OpenstackCloud, i *cloudinstances.CloudInstance) error {
|
func deleteInstance(c OpenstackCloud, i *cloudinstances.CloudInstance) error {
|
||||||
klog.Warning("This does not work without running kops update cluster --yes in another terminal")
|
|
||||||
return deleteInstanceWithID(c, i.ID)
|
return deleteInstanceWithID(c, i.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue