Skip to content

Commit f70fa6c

Browse files
committed
feat: re-introduce awsmanagedcluster
Adding the `AWSMananagedCluster` back into CAPA. This is to ensure that we have separate API kinds for control plane and infrastructure references. This is so that we can enable ClusterClass for EKS in a future change. Signed-off-by: Richard Case <[email protected]>
1 parent d770132 commit f70fa6c

24 files changed

+665
-112
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
Copyright 2022 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 v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23+
)
24+
25+
// AWSManagedClusterSpec defines the desired state of AWSManagedCluster
26+
type AWSManagedClusterSpec struct {
27+
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
28+
// +optional
29+
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
30+
}
31+
32+
// AWSManagedClusterStatus defines the observed state of AWSManagedCluster
33+
type AWSManagedClusterStatus struct {
34+
// Ready is when the AWSManagedControlPlane has a API server URL.
35+
// +optional
36+
Ready bool `json:"ready,omitempty"`
37+
38+
// FailureDomains specifies a list fo available availability zones that can be used
39+
// +optional
40+
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
41+
42+
// Conditions provide observations of the operational state of AWSManagedCluster.
43+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
44+
}
45+
46+
// +kubebuilder:object:root=true
47+
// +kubebuilder:resource:path=awsmanagedclusters,scope=Namespaced,categories=cluster-api,shortName=awsmc
48+
// +kubebuilder:storageversion
49+
// +kubebuilder:subresource:status
50+
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSManagedControl belongs"
51+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Control plane infrastructure is ready for worker nodes"
52+
// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.controlPlaneEndpoint.host",description="API Endpoint",priority=1
53+
54+
// AWSManagedCluster is the Schema for the awsmanagedclusters API
55+
type AWSManagedCluster struct {
56+
metav1.TypeMeta `json:",inline"`
57+
metav1.ObjectMeta `json:"metadata,omitempty"`
58+
59+
Spec AWSManagedClusterSpec `json:"spec,omitempty"`
60+
Status AWSManagedClusterStatus `json:"status,omitempty"`
61+
}
62+
63+
// +kubebuilder:object:root=true
64+
65+
// AWSManagedClusterList contains a list of AWSManagedCluster.
66+
type AWSManagedClusterList struct {
67+
metav1.TypeMeta `json:",inline"`
68+
metav1.ListMeta `json:"metadata,omitempty"`
69+
Items []AWSManagedCluster `json:"items"`
70+
}
71+
72+
// GetConditions returns the observations of the operational state of the AWSManagedCluster resource.
73+
func (r *AWSManagedCluster) GetConditions() clusterv1.Conditions {
74+
return r.Status.Conditions
75+
}
76+
77+
// SetConditions sets the underlying service state of the AWSManagedCluster to the predescribed clusterv1.Conditions.
78+
func (r *AWSManagedCluster) SetConditions(conditions clusterv1.Conditions) {
79+
r.Status.Conditions = conditions
80+
}
81+
82+
func init() {
83+
SchemeBuilder.Register(&AWSManagedCluster{}, &AWSManagedClusterList{})
84+
}

api/v1beta2/zz_generated.deepcopy.go

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

config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedclusters.yaml

Lines changed: 46 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.9.2
6+
controller-gen.kubebuilder.io/version: v0.10.0
77
creationTimestamp: null
88
name: awsmanagedclusters.infrastructure.cluster.x-k8s.io
99
spec:
@@ -28,16 +28,12 @@ spec:
2828
jsonPath: .status.ready
2929
name: Ready
3030
type: string
31-
- description: AWS VPC the control plane is using
32-
jsonPath: .spec.networkSpec.vpc.id
33-
name: VPC
34-
type: string
3531
- description: API Endpoint
3632
jsonPath: .spec.controlPlaneEndpoint.host
3733
name: Endpoint
3834
priority: 1
3935
type: string
40-
name: v1beta1
36+
name: v1beta2
4137
schema:
4238
openAPIV3Schema:
4339
description: AWSManagedCluster is the Schema for the awsmanagedclusters API
@@ -76,71 +72,52 @@ spec:
7672
status:
7773
description: AWSManagedClusterStatus defines the observed state of AWSManagedCluster
7874
properties:
79-
failureDomains:
80-
additionalProperties:
81-
description: FailureDomainSpec is the Schema for Cluster API failure
82-
domains. It allows controllers to understand how many failure
83-
domains a cluster can optionally span across.
75+
conditions:
76+
description: Conditions provide observations of the operational state
77+
of AWSManagedCluster.
78+
items:
79+
description: Condition defines an observation of a Cluster API resource
80+
operational state.
8481
properties:
85-
attributes:
86-
additionalProperties:
87-
type: string
88-
description: Attributes is a free form map of attributes an
89-
infrastructure provider might use or require.
90-
type: object
91-
controlPlane:
92-
description: ControlPlane determines if this failure domain
93-
is suitable for use by control plane machines.
94-
type: boolean
82+
lastTransitionTime:
83+
description: Last time the condition transitioned from one status
84+
to another. This should be when the underlying condition changed.
85+
If that is not known, then using the time when the API field
86+
changed is acceptable.
87+
format: date-time
88+
type: string
89+
message:
90+
description: A human readable message indicating details about
91+
the transition. This field may be empty.
92+
type: string
93+
reason:
94+
description: The reason for the condition's last transition
95+
in CamelCase. The specific API may choose whether or not this
96+
field is considered a guaranteed API. This field may not be
97+
empty.
98+
type: string
99+
severity:
100+
description: Severity provides an explicit classification of
101+
Reason code, so the users or machines can immediately understand
102+
the current situation and act accordingly. The Severity field
103+
MUST be set only when Status=False.
104+
type: string
105+
status:
106+
description: Status of the condition, one of True, False, Unknown.
107+
type: string
108+
type:
109+
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
110+
Many .condition.type values are consistent across resources
111+
like Available, but because arbitrary conditions can be useful
112+
(see .node.status.conditions), the ability to deconflict is
113+
important.
114+
type: string
115+
required:
116+
- lastTransitionTime
117+
- status
118+
- type
95119
type: object
96-
description: FailureDomains specifies a list fo available availability
97-
zones that can be used
98-
type: object
99-
ready:
100-
description: Ready is when the AWSManagedControlPlane has a API server
101-
URL.
102-
type: boolean
103-
type: object
104-
type: object
105-
name: v1beta2
106-
schema:
107-
openAPIV3Schema:
108-
description: AWSManagedCluster is the Schema for the awsmanagedclusters API
109-
properties:
110-
apiVersion:
111-
description: 'APIVersion defines the versioned schema of this representation
112-
of an object. Servers should convert recognized schemas to the latest
113-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
114-
type: string
115-
kind:
116-
description: 'Kind is a string value representing the REST resource this
117-
object represents. Servers may infer this from the endpoint the client
118-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
119-
type: string
120-
metadata:
121-
type: object
122-
spec:
123-
description: AWSManagedClusterSpec defines the desired state of AWSManagedCluster
124-
properties:
125-
controlPlaneEndpoint:
126-
description: ControlPlaneEndpoint represents the endpoint used to
127-
communicate with the control plane.
128-
properties:
129-
host:
130-
description: The hostname on which the API server is serving.
131-
type: string
132-
port:
133-
description: The port on which the API server is serving.
134-
format: int32
135-
type: integer
136-
required:
137-
- host
138-
- port
139-
type: object
140-
type: object
141-
status:
142-
description: AWSManagedClusterStatus defines the observed state of AWSManagedCluster
143-
properties:
120+
type: array
144121
failureDomains:
145122
additionalProperties:
146123
description: FailureDomainSpec is the Schema for Cluster API failure

config/crd/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resources:
1818
- bases/infrastructure.cluster.x-k8s.io_awsclustercontrolleridentities.yaml
1919
- bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml
2020
- bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml
21+
- bases/infrastructure.cluster.x-k8s.io_awsmanagedclusters.yaml
2122
- bases/bootstrap.cluster.x-k8s.io_eksconfigs.yaml
2223
- bases/bootstrap.cluster.x-k8s.io_eksconfigtemplates.yaml
2324
# +kubebuilder:scaffold:crdkustomizeresource
@@ -45,6 +46,7 @@ patchesStrategicMerge:
4546
- patches/cainjection_in_awsclusterroleidentities.yaml
4647
- patches/cainjection_in_awsclustertemplates.yaml
4748
- patches/cainjection_in_awsmanagedcontrolplanes.yaml
49+
- patches/cainjection_in_awsmanagedclusters.yaml
4850
- patches/cainjection_in_eksconfigs.yaml
4951
- patches/cainjection_in_eksconfigtemplates.yaml
5052
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
8+
name: awsmanagedclusters.infrastructure.cluster.x-k8s.io

config/rbac/role.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,35 @@ rules:
266266
- get
267267
- patch
268268
- update
269+
- apiGroups:
270+
- infrastructure.cluster.x-k8s.io
271+
resources:
272+
- awsmanagedclusters
273+
verbs:
274+
- create
275+
- delete
276+
- get
277+
- list
278+
- patch
279+
- update
280+
- watch
281+
- apiGroups:
282+
- infrastructure.cluster.x-k8s.io
283+
resources:
284+
- awsmanagedclusters
285+
- awsmanagedclusters/status
286+
verbs:
287+
- get
288+
- list
289+
- watch
290+
- apiGroups:
291+
- infrastructure.cluster.x-k8s.io
292+
resources:
293+
- awsmanagedclusters/status
294+
verbs:
295+
- get
296+
- patch
297+
- update
269298
- apiGroups:
270299
- infrastructure.cluster.x-k8s.io
271300
resources:

0 commit comments

Comments
 (0)