Skip to content

Commit 8cb28c4

Browse files
Add conditions to the KubeadmConfig object
1 parent 6e16013 commit 8cb28c4

8 files changed

+230
-38
lines changed

bootstrap/kubeadm/api/v1alpha2/conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (src *KubeadmConfig) ConvertTo(dstRaw conversion.Hub) error {
4343
dst.Spec.DiskSetup = restored.Spec.DiskSetup
4444
dst.Spec.Mounts = restored.Spec.Mounts
4545
dst.Spec.Files = restored.Spec.Files
46+
dst.Status.Conditions = restored.Status.Conditions
4647

4748
// Track files successfully up-converted. We need this to dedupe
4849
// restored files from user-updated files on up-conversion. We store

bootstrap/kubeadm/api/v1alpha2/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha3
18+
19+
import clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
20+
21+
// Conditions and condition Reasons for the KubeadmConfig object
22+
23+
const (
24+
// DataSecretAvailableCondition documents the status of the bootstrap secret generation process.
25+
//
26+
// NOTE: When the DataSecret generation starts the process completes immediately and within the
27+
// same reconciliation, so the user will always see a transition from Wait to Generated without having
28+
// evidence that BootstrapSecret generation is started/in progress.
29+
DataSecretAvailableCondition clusterv1.ConditionType = "DataSecretAvailable"
30+
31+
// WaitingForClusterInfrastructureReason (Severity=Info) document a bootstrap secret generation process
32+
// waiting for the cluster infrastructure to be ready.
33+
//
34+
// NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines;
35+
// the KubeadmConfig controller ensure this pre-condition is satisfied.
36+
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"
37+
38+
// WaitingForControlPlaneAvailableReason (Severity=Info) document a bootstrap secret generation process
39+
// waiting for the control plane machine to be available.
40+
//
41+
// NOTE: Having the control plane machine available is a pre-condition for joining additional control planes
42+
// or workers nodes.
43+
WaitingForControlPlaneAvailableReason = "WaitingForControlPlaneAvailable"
44+
45+
// DataSecretGenerationFailedReason (Severity=Warning) documents a KubeadmConfig controller detecting
46+
// an error while generating a data secret; those kind of errors are usually due to misconfigurations
47+
// and user intervention is required to get them fixed.
48+
DataSecretGenerationFailedReason = "DataSecretGenerationFailed"
49+
)
50+
51+
const (
52+
// CertificatesAvailableCondition documents that cluster certificates are available.
53+
//
54+
// NOTE: Cluster certificates are generated only for the KubeadmConfig object linked to the initial control plane
55+
// machine, if the cluster is not using a control plane ref object, if the certificates are not provided
56+
// by the users.
57+
// IMPORTANT: This condition won't be re-created after clusterctl move.
58+
CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable"
59+
60+
// CertificatesGenerationFailedReason (Severity=Warning) documents a KubeadmConfig controller detecting
61+
// an error while generating certificates; those kind of errors are usually temporary and the controller
62+
// automatically recover from them.
63+
CertificatesGenerationFailedReason = "CertificatesGenerationFailed"
64+
65+
// CertificatesCorruptedReason (Severity=Error) documents a KubeadmConfig controller detecting
66+
// an error while while retrieving certificates for a joining node.
67+
CertificatesCorruptedReason = "CertificatesCorrupted"
68+
)

bootstrap/kubeadm/api/v1alpha3/kubeadmbootstrapconfig_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1alpha3
1818

1919
import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
2122
kubeadmv1beta1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/types/v1beta1"
2223
)
2324

@@ -124,6 +125,10 @@ type KubeadmConfigStatus struct {
124125
// ObservedGeneration is the latest generation observed by the controller.
125126
// +optional
126127
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
128+
129+
// Conditions defines current service state of the KubeadmConfig.
130+
// +optional
131+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
127132
}
128133

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

148+
func (c *KubeadmConfig) GetConditions() clusterv1.Conditions {
149+
return c.Status.Conditions
150+
}
151+
152+
func (c *KubeadmConfig) SetConditions(conditions clusterv1.Conditions) {
153+
c.Status.Conditions = conditions
154+
}
155+
143156
// +kubebuilder:object:root=true
144157

145158
// KubeadmConfigList contains a list of KubeadmConfig

bootstrap/kubeadm/api/v1alpha3/zz_generated.deepcopy.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,50 @@ spec:
17381738
be removed in a future version. Switch to DataSecretName."
17391739
format: byte
17401740
type: string
1741+
conditions:
1742+
description: Conditions defines current service state of the KubeadmConfig.
1743+
items:
1744+
description: Condition defines an observation of a Cluster API resource
1745+
operational state.
1746+
properties:
1747+
lastTransitionTime:
1748+
description: Last time the condition transitioned from one status
1749+
to another. This should be when the underlying condition changed.
1750+
If that is not known, then using the time when the API field
1751+
changed is acceptable.
1752+
format: date-time
1753+
type: string
1754+
message:
1755+
description: A human readable message indicating details about
1756+
the transition. This field may be empty.
1757+
type: string
1758+
reason:
1759+
description: The reason for the condition's last transition
1760+
in CamelCase. The specific API may choose whether or not this
1761+
field is considered a guaranteed API. This field may not be
1762+
empty.
1763+
type: string
1764+
severity:
1765+
description: Severity provides an explicit classification of
1766+
Reason code, so the users or machines can immediately understand
1767+
the current situation and act accordingly. The Severity field
1768+
MUST be set only when Status=False.
1769+
type: string
1770+
status:
1771+
description: Status of the condition, one of True, False, Unknown.
1772+
type: string
1773+
type:
1774+
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
1775+
Many .condition.type values are consistent across resources
1776+
like Available, but because arbitrary conditions can be useful
1777+
(see .node.status.conditions), the ability to deconflict is
1778+
important.
1779+
type: string
1780+
required:
1781+
- status
1782+
- type
1783+
type: object
1784+
type: array
17411785
dataSecretName:
17421786
description: DataSecretName is the name of the secret that stores
17431787
the bootstrap data script.

0 commit comments

Comments
 (0)