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

feat: re-introduce awsmanagedcluster #3797

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
84 changes: 84 additions & 0 deletions api/v1beta2/awsmanagedcluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Copyright 2022 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 v1beta2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// AWSManagedClusterSpec defines the desired state of AWSManagedCluster
type AWSManagedClusterSpec struct {
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
}

// AWSManagedClusterStatus defines the observed state of AWSManagedCluster
type AWSManagedClusterStatus struct {
// Ready is when the AWSManagedControlPlane has a API server URL.
// +optional
Ready bool `json:"ready,omitempty"`

// FailureDomains specifies a list fo available availability zones that can be used
// +optional
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`

// Conditions provide observations of the operational state of AWSManagedCluster.
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
richardcase marked this conversation as resolved.
Show resolved Hide resolved
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=awsmanagedclusters,scope=Namespaced,categories=cluster-api,shortName=awsmc
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSManagedControl belongs"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Control plane infrastructure is ready for worker nodes"
// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.controlPlaneEndpoint.host",description="API Endpoint",priority=1

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

Spec AWSManagedClusterSpec `json:"spec,omitempty"`
Status AWSManagedClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

// GetConditions returns the observations of the operational state of the AWSManagedCluster resource.
func (r *AWSManagedCluster) GetConditions() clusterv1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the AWSManagedCluster to the predescribed clusterv1.Conditions.
func (r *AWSManagedCluster) SetConditions(conditions clusterv1.Conditions) {
r.Status.Conditions = conditions
}

func init() {
SchemeBuilder.Register(&AWSManagedCluster{}, &AWSManagedClusterList{})
}
104 changes: 104 additions & 0 deletions api/v1beta2/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 @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
name: awsmanagedclusters.infrastructure.cluster.x-k8s.io
spec:
Expand All @@ -28,16 +28,12 @@ spec:
jsonPath: .status.ready
name: Ready
type: string
- description: AWS VPC the control plane is using
jsonPath: .spec.networkSpec.vpc.id
name: VPC
type: string
- description: API Endpoint
jsonPath: .spec.controlPlaneEndpoint.host
name: Endpoint
priority: 1
type: string
name: v1beta1
name: v1beta2
schema:
openAPIV3Schema:
description: AWSManagedCluster is the Schema for the awsmanagedclusters API
Expand Down Expand Up @@ -76,71 +72,52 @@ spec:
status:
description: AWSManagedClusterStatus defines the observed state of AWSManagedCluster
properties:
failureDomains:
additionalProperties:
description: FailureDomainSpec is the Schema for Cluster API failure
domains. It allows controllers to understand how many failure
domains a cluster can optionally span across.
conditions:
description: Conditions provide observations of the operational state
of AWSManagedCluster.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
attributes:
additionalProperties:
type: string
description: Attributes is a free form map of attributes an
infrastructure provider might use or require.
type: object
controlPlane:
description: ControlPlane determines if this failure domain
is suitable for use by control plane machines.
type: boolean
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:
- lastTransitionTime
- status
- type
type: object
description: FailureDomains specifies a list fo available availability
zones that can be used
type: object
ready:
description: Ready is when the AWSManagedControlPlane has a API server
URL.
type: boolean
type: object
type: object
name: v1beta2
schema:
openAPIV3Schema:
description: AWSManagedCluster is the Schema for the awsmanagedclusters API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: AWSManagedClusterSpec defines the desired state of AWSManagedCluster
properties:
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
properties:
host:
description: The hostname on which the API server is serving.
type: string
port:
description: The port on which the API server is serving.
format: int32
type: integer
required:
- host
- port
type: object
type: object
status:
description: AWSManagedClusterStatus defines the observed state of AWSManagedCluster
properties:
type: array
failureDomains:
additionalProperties:
description: FailureDomainSpec is the Schema for Cluster API failure
Expand Down
2 changes: 2 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ resources:
- bases/infrastructure.cluster.x-k8s.io_awsclustercontrolleridentities.yaml
- bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml
- bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml
- bases/infrastructure.cluster.x-k8s.io_awsmanagedclusters.yaml
- bases/bootstrap.cluster.x-k8s.io_eksconfigs.yaml
- bases/bootstrap.cluster.x-k8s.io_eksconfigtemplates.yaml
# +kubebuilder:scaffold:crdkustomizeresource
Expand Down Expand Up @@ -45,6 +46,7 @@ patchesStrategicMerge:
- patches/cainjection_in_awsclusterroleidentities.yaml
- patches/cainjection_in_awsclustertemplates.yaml
- patches/cainjection_in_awsmanagedcontrolplanes.yaml
- patches/cainjection_in_awsmanagedclusters.yaml
- patches/cainjection_in_eksconfigs.yaml
- patches/cainjection_in_eksconfigtemplates.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_awsmanagedclusters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: awsmanagedclusters.infrastructure.cluster.x-k8s.io
29 changes: 29 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,35 @@ rules:
- get
- patch
- update
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- awsmanagedclusters
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- awsmanagedclusters
- awsmanagedclusters/status
verbs:
- get
- list
- watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
- awsmanagedclusters/status
verbs:
- get
- patch
- update
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
Expand Down
Loading