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

🌱 Add conditions to the KubeadmConfig object #3125

Merged
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
1 change: 1 addition & 0 deletions bootstrap/kubeadm/api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.DiskSetup = restored.Spec.DiskSetup
dst.Spec.Mounts = restored.Spec.Mounts
dst.Spec.Files = restored.Spec.Files
dst.Status.Conditions = restored.Status.Conditions

// Track files successfully up-converted. We need this to dedupe
// restored files from user-updated files on up-conversion. We store
Expand Down
1 change: 1 addition & 0 deletions bootstrap/kubeadm/api/v1alpha2/zz_generated.conversion.go

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

68 changes: 68 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/condition_consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2020 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha3

import clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"

// Conditions and condition Reasons for the KubeadmConfig object

const (
// DataSecretAvailableCondition documents the status of the bootstrap secret generation process.
//
// NOTE: When the DataSecret generation starts the process completes immediately and within the
// same reconciliation, so the user will always see a transition from Wait to Generated without having
// evidence that BootstrapSecret generation is started/in progress.
DataSecretAvailableCondition clusterv1.ConditionType = "DataSecretAvailable"

// WaitingForClusterInfrastructureReason (Severity=Info) document a bootstrap secret generation process
// waiting for the cluster infrastructure to be ready.
//
// NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines;
// the KubeadmConfig controller ensure this pre-condition is satisfied.
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"

// WaitingForControlPlaneAvailableReason (Severity=Info) document a bootstrap secret generation process
// 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"

// DataSecretGenerationFailedReason (Severity=Warning) documents a KubeadmConfig controller detecting
// an error while generating a data secret; those kind of errors are usually due to misconfigurations
// and user intervention is required to get them fixed.
DataSecretGenerationFailedReason = "DataSecretGenerationFailed"
)

const (
// CertificatesAvailableCondition documents that cluster certificates are available.
//
// NOTE: Cluster certificates are generated only for the KubeadmConfig object linked to the initial control plane
// machine, if the cluster is not using a control plane ref object, if the certificates are not provided
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved
// by the users.
// IMPORTANT: This condition won't be re-created after clusterctl move.
CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable"

// CertificatesGenerationFailedReason (Severity=Warning) documents a KubeadmConfig controller detecting
// an error while generating certificates; those kind of errors are usually temporary and the controller
// automatically recover from them.
CertificatesGenerationFailedReason = "CertificatesGenerationFailed"

// CertificatesCorruptedReason (Severity=Error) documents a KubeadmConfig controller detecting
// an error while while retrieving certificates for a joining node.
CertificatesCorruptedReason = "CertificatesCorrupted"
)
13 changes: 13 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/kubeadmbootstrapconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
kubeadmv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/v1beta1"
)

Expand Down Expand Up @@ -124,6 +125,10 @@ type KubeadmConfigStatus struct {
// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

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

// +kubebuilder:object:root=true
Expand All @@ -140,6 +145,14 @@ type KubeadmConfig struct {
Status KubeadmConfigStatus `json:"status,omitempty"`
}

func (c *KubeadmConfig) GetConditions() clusterv1.Conditions {
return c.Status.Conditions
}

func (c *KubeadmConfig) SetConditions(conditions clusterv1.Conditions) {
c.Status.Conditions = conditions
}

// +kubebuilder:object:root=true

// KubeadmConfigList contains a list of KubeadmConfig
Expand Down
8 changes: 8 additions & 0 deletions bootstrap/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 @@ -1738,6 +1738,50 @@ spec:
be removed in a future version. Switch to DataSecretName."
format: byte
type: string
conditions:
description: Conditions defines current service state of the KubeadmConfig.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- status
- type
type: object
type: array
dataSecretName:
description: DataSecretName is the name of the secret that stores
the bootstrap data script.
Expand Down
Loading