Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1alpha4] upstream v1alpha3 kcp strategy #26

Open
wants to merge 2 commits into
base: spectro-v0.4.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/v1alpha3/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,32 @@ const (
// tool uses this label for implementing provider's lifecycle operations.
ProviderLabelName = "cluster.x-k8s.io/provider"

// ClusterNameAnnotation is the annotation set on nodes identifying the name of the cluster the node belongs to.
ClusterNameAnnotation = "cluster.x-k8s.io/cluster-name"

// ClusterNamespaceAnnotation is the annotation set on nodes identifying the namespace of the cluster the node belongs to.
ClusterNamespaceAnnotation = "cluster.x-k8s.io/cluster-namespace"

// MachineAnnotation is the annotation set on nodes identifying the machine the node belongs to.
MachineAnnotation = "cluster.x-k8s.io/machine"

// OwnerKindAnnotation is the annotation set on nodes identifying the owner kind.
OwnerKindAnnotation = "cluster.x-k8s.io/owner-kind"

// OwnerNameAnnotation is the annotation set on nodes identifying the owner name.
OwnerNameAnnotation = "cluster.x-k8s.io/owner-name"

// PausedAnnotation is an annotation that can be applied to any Cluster API
// object to prevent a controller from processing a resource.
//
// Controllers working with Cluster API objects must check the existence of this annotation
// on the reconciled object.
PausedAnnotation = "cluster.x-k8s.io/paused"

// DeleteMachineAnnotation marks control plane and worker nodes that will be given priority for deletion
// when KCP or a machineset scales down. This annotation is given top priority on all delete policies.
DeleteMachineAnnotation = "cluster.x-k8s.io/delete-machine"

// TemplateClonedFromNameAnnotation is the infrastructure machine annotation that stores the name of the infrastructure template resource
// that was cloned for the machine. This annotation is set only during cloning a template. Older/adopted machines will not have this annotation.
TemplateClonedFromNameAnnotation = "cluster.x-k8s.io/cloned-from-name"
Expand All @@ -46,6 +65,9 @@ const (
// that was cloned for the machine. This annotation is set only during cloning a template. Older/adopted machines will not have this annotation.
TemplateClonedFromGroupKindAnnotation = "cluster.x-k8s.io/cloned-from-groupkind"

// MachineSkipRemediationAnnotation is the annotation used to mark the machines that should not be considered for remediation by MachineHealthCheck reconciler.
MachineSkipRemediationAnnotation = "cluster.x-k8s.io/skip-remediation"

// ClusterSecretType defines the type of secret created by core components.
ClusterSecretType corev1.SecretType = "cluster.x-k8s.io/secret" //nolint:gosec
)
Expand Down
7 changes: 7 additions & 0 deletions api/v1alpha3/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ const (
// to be available.
// NOTE: This reason is used only as a fallback when the control plane object is not reporting its own ready condition.
WaitingForControlPlaneFallbackReason = "WaitingForControlPlane"

// WaitingForControlPlaneAvailableReason (Severity=Info) documents a Cluster API object
// waiting for the control plane machine to be available.
//
// NOTE: Having the control plane machine available is a pre-condition for joining additional control planes
// or workers nodes.
WaitingForControlPlaneAvailableReason = "WaitingForControlPlaneAvailable"
)

// Conditions and condition Reasons for the Machine object
Expand Down
1 change: 0 additions & 1 deletion controlplane/kubeadm/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func (src *KubeadmControlPlane) ConvertTo(destRaw conversion.Hub) error {
return err
}

dest.Spec.RolloutStrategy = restored.Spec.RolloutStrategy
dest.Spec.MachineTemplate.ObjectMeta = restored.Spec.MachineTemplate.ObjectMeta
dest.Status.Version = restored.Status.Version

Expand Down
42 changes: 42 additions & 0 deletions controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ package v1alpha3
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"

cabpkv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha3"
"sigs.k8s.io/cluster-api/errors"
)

// RolloutStrategyType defines the rollout strategies for a KubeadmControlPlane.
type RolloutStrategyType string

const (
// RollingUpdateStrategyType replaces the old control planes by new one using rolling update
// i.e. gradually scale up or down the old control planes and scale up or down the new one.
RollingUpdateStrategyType RolloutStrategyType = "RollingUpdate"
)

const (
// KubeadmControlPlaneFinalizer is the finalizer applied to KubeadmControlPlane resources
// by its managing controller.
Expand Down Expand Up @@ -77,6 +87,38 @@ type KubeadmControlPlaneSpec struct {
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
// +optional
NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`

// The RolloutStrategy to use to replace control plane machines with
// new ones.
// +optional
RolloutStrategy *RolloutStrategy `json:"rolloutStrategy,omitempty"`
}

// RolloutStrategy describes how to replace existing machines
// with new ones.
type RolloutStrategy struct {
// Type of rollout. Currently the only supported strategy is
// "RollingUpdate".
// Default is RollingUpdate.
// +optional
Type RolloutStrategyType `json:"type,omitempty"`

// Rolling update config params. Present only if
// RolloutStrategyType = RollingUpdate.
// +optional
RollingUpdate *RollingUpdate `json:"rollingUpdate,omitempty"`
}

// RollingUpdate is used to control the desired behavior of rolling update.
type RollingUpdate struct {
// The maximum number of control planes that can be scheduled above or under the
// desired number of control planes.
// Value can be an absolute number 1 or 0.
// Defaults to 1.
// Example: when this is set to 1, the control plane can be scaled
// up immediately when the rolling update starts.
// +optional
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
}

// KubeadmControlPlaneStatus defines the observed state of KubeadmControlPlane.
Expand Down
66 changes: 65 additions & 1 deletion controlplane/kubeadm/api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions controlplane/kubeadm/api/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,30 @@ spec:
This is a pointer to distinguish between explicit zero and not specified.
format: int32
type: integer
rolloutStrategy:
description: The RolloutStrategy to use to replace control plane machines
with new ones.
properties:
rollingUpdate:
description: Rolling update config params. Present only if RolloutStrategyType
= RollingUpdate.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
description: 'The maximum number of control planes that can
be scheduled above or under the desired number of control
planes. Value can be an absolute number 1 or 0. Defaults
to 1. Example: when this is set to 1, the control plane
can be scaled up immediately when the rolling update starts.'
x-kubernetes-int-or-string: true
type: object
type:
description: Type of rollout. Currently the only supported strategy
is "RollingUpdate". Default is RollingUpdate.
type: string
type: object
upgradeAfter:
description: UpgradeAfter is a field to indicate an upgrade should
be performed after the specified time even if no changes have been
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg

framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
Lister: managementClusterProxy.GetClient(),
Namespace: managementClusterNamespace.Name,
Namespace: testNamespace.Name,
LogPath: filepath.Join(input.ArtifactFolder, "clusters", managementClusterResources.Cluster.Name, "resources"),
})

Expand Down