Skip to content

Commit 3e41de6

Browse files
committed
Add KubeadmControlPlane types
1 parent 409448c commit 3e41de6

File tree

3 files changed

+1227
-0
lines changed

3 files changed

+1227
-0
lines changed
+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/*
2+
Copyright 2019 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 (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
cabpkv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha2"
23+
)
24+
25+
// KubeadmControlPlaneSpec defines the desired state of KubeadmControlPlane.
26+
type KubeadmControlPlaneSpec struct {
27+
// Number of desired machines. Defaults to 1. When stacked etcd is used only
28+
// odd numbers are permitted, as per [etcd best practice](https://etcd.io/docs/v3.3.12/faq/#why-an-odd-number-of-cluster-members).
29+
// This is a pointer to distinguish between explicit zero and not specified.
30+
// +optional
31+
Replicas *int32 `json:"replicas,omitempty"`
32+
33+
// Version defines the desired Kubernetes version.
34+
Version string `json:"version"`
35+
36+
// InfrastructureTemplate is a required reference to a custom resource
37+
// offered by an infrastructure provider.
38+
InfrastructureTemplate corev1.ObjectReference `json:"infrastructureTemplate"`
39+
40+
// KubeadmConfigSpec is a KubeadmConfigSpec
41+
// to use for initializing and joining machines to the control plane.
42+
KubeadmConfigSpec cabpkv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"`
43+
}
44+
45+
// KubeadmControlPlaneStatus defines the observed state of KubeadmControlPlane.
46+
type KubeadmControlPlaneStatus struct {
47+
// Selector is the label selector in string format to avoid introspection
48+
// by clients, and is used to provide the CRD-based integration for the
49+
// scale subresource and additional integrations for things like kubectl
50+
// describe.. The string will be in the same format as the query-param syntax.
51+
// More info about label selectors: http://kubernetes.io/docs/user-guide/labels#label-selectors
52+
// +optional
53+
Selector string `json:"selector,omitempty"`
54+
55+
// Total number of non-terminated machines targeted by this control plane
56+
// (their labels match the selector).
57+
// +optional
58+
Replicas int32 `json:"replicas,omitempty"`
59+
60+
// Total number of non-terminated machines targeted by this control plane
61+
// that have the desired template spec.
62+
// +optional
63+
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
64+
65+
// Total number of fully running and ready control plane machines.
66+
// +optional
67+
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
68+
69+
// Total number of unavailable machines targeted by this control plane.
70+
// This is the total number of machines that are still required for
71+
// the deployment to have 100% available capacity. They may either
72+
// be machines that are running but not yet ready or machines
73+
// that still have not been created.
74+
// +optional
75+
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`
76+
77+
// Initialized denotes whether or not the control plane has the
78+
// uploaded kubeadm-config configmap.
79+
// +optional
80+
Initialized bool `json:"initialized,omitempty"`
81+
82+
// Ready denotes that the KubeadmControlPlane API Server is ready to
83+
// receive requests.
84+
// +optional
85+
Ready bool `json:"ready,omitempty"`
86+
87+
// ErrorReason indicates that there is a problem reconciling the
88+
// state, and will be set to a token value suitable for
89+
// programmatic interpretation.
90+
// +optional
91+
ErrorReason KubeadmControlPlaneStatusError `json:"errorReason,omitempty"`
92+
93+
// ErrorMessage indicates that there is a problem reconciling the
94+
// state, and will be set to a descriptive error message.
95+
// +optional
96+
ErrorMessage *string `json:"errorMessage,omitempty"`
97+
}
98+
99+
// +kubebuilder:object:root=true
100+
// +kubebuilder:resource:path=kubeadmcontrolplanes,shortName=kcp,scope=Namespaced,categories=cluster-api
101+
// +kubebuilder:storageversion
102+
// +kubebuilder:subresource:status
103+
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
104+
105+
// KubeadmControlPlane is the Schema for the KubeadmControlPlane API.
106+
type KubeadmControlPlane struct {
107+
metav1.TypeMeta `json:",inline"`
108+
metav1.ObjectMeta `json:"metadata,omitempty"`
109+
110+
Spec KubeadmControlPlaneSpec `json:"spec,omitempty"`
111+
Status KubeadmControlPlaneStatus `json:"status,omitempty"`
112+
}
113+
114+
// +kubebuilder:object:root=true
115+
116+
// KubeadmControlPlaneList contains a list of KubeadmControlPlane.
117+
type KubeadmControlPlaneList struct {
118+
metav1.TypeMeta `json:",inline"`
119+
metav1.ListMeta `json:"metadata,omitempty"`
120+
Items []KubeadmControlPlane `json:"items"`
121+
}
122+
123+
func init() {
124+
SchemeBuilder.Register(&KubeadmControlPlane{}, &KubeadmControlPlaneList{})
125+
}
126+
127+
type KubeadmControlPlaneStatusError string
128+
129+
// A more descriptive kind of error that represents an error condition that
130+
// should be set in the KubeadmControlPlane.Status. The "Reason" field is meant for short,
131+
// enum-style constants meant to be interpreted by control planes. The "Message"
132+
// field is meant to be read by humans.
133+
type KubeadmControlPlaneError struct {
134+
Reason KubeadmControlPlaneStatusError
135+
Message string
136+
}
137+
138+
func (e *KubeadmControlPlaneError) Error() string {
139+
return e.Message
140+
}
141+
142+
const (
143+
// InvalidConfigurationKubeadmControlPlaneError indicates that the kubeadm control plane
144+
// configuration is invalid.
145+
InvalidConfigurationKubeadmControlPlaneError KubeadmControlPlaneStatusError = "InvalidConfiguration"
146+
147+
// UnsupportedChangeKubeadmControlPlaneError indicates that the kubeadm control plane
148+
// spec has been updated in an unsupported way. That cannot be
149+
// reconciled.
150+
UnsupportedChangeKubeadmControlPlaneError KubeadmControlPlaneStatusError = "UnsupportedChange"
151+
152+
// CreateKubeadmControlPlaneError indicates that an error was encountered
153+
// when trying to create the kubeadm control plane.
154+
CreateKubeadmControlPlaneError KubeadmControlPlaneStatusError = "CreateError"
155+
156+
// UpdateKubeadmControlPlaneError indicates that an error was encountered
157+
// when trying to update the kubeadm control plane.
158+
UpdateKubeadmControlPlaneError KubeadmControlPlaneStatusError = "UpdateError"
159+
160+
// DeleteKubeadmControlPlaneError indicates that an error was encountered
161+
// when trying to delete the kubeadm control plane.
162+
DeleteKubeadmControlPlaneError KubeadmControlPlaneStatusError = "DeleteError"
163+
)

api/v1alpha3/zz_generated.deepcopy.go

+116
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)