Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Sep 11, 2020
1 parent 9ae5571 commit 11792f8
Showing 1 changed file with 2 additions and 166 deletions.
168 changes: 2 additions & 166 deletions docs/proposals/20191017-kubeadm-based-control-plane.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,171 +151,7 @@ Non-Goals listed in this document are intended to scope bound the current v1alph

#### New API Types

KubeadmControlPlane:

```go
package v1alpha3

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cabpkv1 "sigs.k8s.io/cluster-api-bootstrap-provider-kubeadm/api/v1alpha2"
)

// KubeadmControlPlaneSpec defines the desired state of KubeadmControlPlane.
type KubeadmControlPlaneSpec struct {
// Number of desired machines. Defaults to 1. When stacked etcd is used only
// odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members).
// This is a pointer to distinguish between explicit zero and not specified.
// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Version defines the desired Kubernetes version.
Version string `json:"version"`

// InfrastructureTemplate is a required reference to a custom resource
// offered by an infrastructure provider.
InfrastructureTemplate corev1.ObjectReference `json:"infrastructureTemplate"`

// KubeadmConfigSpec is a KubeadmConfigSpec
// to use for initializing and joining machines to the control plane.
KubeadmConfigSpec cabpkv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"`

// UpgradeAfter is a field to indicate an upgrade should be performed
// after the specified time even if no changes have been made to the
// KubeadmControlPlane
// +optional
UpgradeAfter *metav1.Time `json:"upgradeAfter,omitempty"`
}

// KubeadmControlPlaneStatus defines the observed state of KubeadmControlPlane.
type KubeadmControlPlaneStatus struct {
// Selector is the label selector in string format to avoid introspection
// by clients, and is used to provide the CRD-based integration for the
// scale subresource and additional integrations for things like kubectl
// describe.. The string will be in the same format as the query-param syntax.
// More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors
// +optional
Selector string `json:"selector,omitempty"`

// Total number of non-terminated machines targeted by this control plane
// (their labels match the selector).
// +optional
Replicas int32 `json:"replicas,omitempty"`

// Total number of non-terminated machines targeted by this control plane
// that have the desired template spec.
// +optional
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`

// Total number of fully running and ready control plane machines.
// +optional
ReadyReplicas int32 `json:"readyReplicas,omitempty"`

// Total number of unavailable machines targeted by this control plane.
// This is the total number of machines that are still required for
// the deployment to have 100% available capacity. They may either
// be machines that are running but not yet ready or machines
// that still have not been created.
// +optional
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`

// Initialized denotes whether or not the control plane has the
// uploaded kubeadm-config configmap.
// +optional
Initialized bool `json:"initialized"`

// Ready denotes that the KubeadmControlPlane API Server is ready to
// receive requests.
// +optional
Ready bool `json:"ready"`

// FailureReason indicates that there is a terminal problem reconciling the
// state, and will be set to a token value suitable for
// programmatic interpretation.
// +optional
FailureReason errors.KubeadmControlPlaneStatusError `json:"failureReason,omitempty"`

// ErrorMessage indicates that there is a terminal problem reconciling the
// state, and will be set to a descriptive error message.
// +optional
FailureMessage *string `json:"failureMessage,omitempty"`

// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// Conditions defines current service state of the KubeadmControlPlane.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=controlplanes,shortName=cp,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector

// KubeadmControlPlane is the Schema for the KubeadmControlPlane API.
type KubeadmControlPlane struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KubeadmControlPlaneSpec `json:"spec,omitempty"`
Status KubeadmControlPlaneStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// KubeadmControlPlaneList contains a list of KubeadmControlPlane.
type KubeadmControlPlaneList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KubeadmControlPlane `json:"items"`
}

func init() {
SchemeBuilder.Register(&KubeadmControlPlane{}, &KubeadmControlPlaneList{})
}

type KubeadmControlPlaneStatusError string

// A more descriptive kind of error that represents an error condition that
// should be set in the KubeadmControlPlane.Status. The "Reason" field is meant for short,
// enum-style constants meant to be interpreted by control planes. The "Message"
// field is meant to be read by humans.
type KubeadmControlPlaneError struct {
Reason KubeadmControlPlaneStatusError
Message string
}

func (e *KubeadmControlPlaneError) Error() string {
return e.Message
}

const (
// InvalidConfigurationKubeadmControlPlaneError indicates that the kubeadm control plane
// configuration is invalid.
InvalidConfigurationKubeadmControlPlaneError KubeadmControlPlaneStatusError = "InvalidConfiguration"

// UnsupportedChangeKubeadmControlPlaneError indicates that the kubeadm control plane
// spec has been updated in an unsupported way that cannot be
// reconciled.
UnsupportedChangeKubeadmControlPlaneError KubeadmControlPlaneStatusError = "UnsupportedChange"

// CreateKubeadmControlPlaneError indicates that an error was encountered
// when trying to create the kubeadm control plane.
CreateKubeadmControlPlaneError KubeadmControlPlaneStatusError = "CreateError"

// UpdateKubeadmControlPlaneError indicates that an error was encountered
// when trying to update the kubeadm control plane.
UpdateKubeadmControlPlaneError KubeadmControlPlaneStatusError = "UpdateError"

// DeleteKubeadmControlPlaneError indicates that an error was encountered
// when trying to delete the kubeadm control plane.
DeleteKubeadmControlPlaneError KubeadmControlPlaneStatusError = "DeleteError"
)
```
See [kubeadm_control_plane_types.go](https://github.com/kubernetes-sigs/cluster-api/blob/master/controlplane/kubeadm/api/v1alpha3/kubeadm_control_plane_types.go)

With the following validations:

Expand Down Expand Up @@ -516,7 +352,7 @@ spec:
- See [Health checks](#Health checks) below.

- The rollout algorithm is the following:
- Find Machines that need rollout
- Find Machines that have an outdated spec
- If there is a machine requiring rollout
- Scale up control plane creating a machine with the new spec
- Scale down control plane by removing one of the machine that needs rollout (the oldest out-of date machine in the failure domain that has the most out-of-date control-plane machines on it).
Expand Down

0 comments on commit 11792f8

Please sign in to comment.