-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added awsmachinepool controller and types
Co-authored-by: Nicole Yson <[email protected]> Co-authored-by: Andrew Rudoi <[email protected]> Co-authored-by: mnguyen <[email protected]> Co-authored-by: Naadir Jeewa <[email protected]>
- Loading branch information
1 parent
3048405
commit f05273a
Showing
35 changed files
with
6,994 additions
and
32 deletions.
There are no files selected for viewing
342 changes: 342 additions & 0 deletions
342
config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) | ||
name: awsmachinepools.infrastructure.cluster.x-k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# The following patch enables conversion webhook for CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: awsmachinepools.infrastructure.cluster.x-k8s.io | ||
spec: | ||
conversion: | ||
strategy: Webhook | ||
webhookClientConfig: | ||
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, | ||
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) | ||
caBundle: Cg== | ||
service: | ||
namespace: system | ||
name: webhook-service | ||
path: /convert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/* | ||
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 ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" | ||
"sigs.k8s.io/cluster-api/errors" | ||
) | ||
|
||
const ( | ||
MachinePoolFinalizer = "awsmachinepool.infrastructure.cluster.x-k8s.io" | ||
LaunchTemplateLatestVersion = "$Latest" | ||
) | ||
|
||
// AWSMachinePoolSpec defines the desired state of AWSMachinePool | ||
type AWSMachinePoolSpec struct { | ||
// ProviderID is the ARN of the associated ASG | ||
// +optional | ||
ProviderID string `json:"providerID,omitempty"` | ||
|
||
// The minimum size of the group. | ||
// +kubebuilder:default=1 | ||
// +kubebuilder:validation:Minimum=1 | ||
MinSize int32 `json:"minSize"` | ||
|
||
// The maximum size of the group. | ||
// +kubebuilder:default=1 | ||
// +kubebuilder:validation:Minimum=1 | ||
MaxSize int32 `json:"maxSize"` | ||
|
||
// AvailabilityZones is an array of availability zones instances can run in | ||
AvailabilityZones []string `json:"availabilityZones,omitempty"` | ||
|
||
// Subnets is an array of subnet configurations | ||
Subnets []infrav1.AWSResourceReference `json:"subnets,omitempty"` | ||
|
||
// AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the | ||
// AWS provider. | ||
// +optional | ||
AdditionalTags infrav1.Tags `json:"additionalTags,omitempty"` | ||
|
||
// AWSLaunchTemplate specifies the launch template and version to use when an instance is launched. | ||
// +kubebuilder:validation:Required | ||
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"` | ||
|
||
// MixedInstancesPolicy describes how multiple instance types will be used by the ASG. | ||
MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"` | ||
|
||
// ProviderIDList are the identification IDs of machine instances provided by the provider. | ||
// This field must match the provider IDs as seen on the node objects corresponding to a machine pool's machine instances. | ||
// +optional | ||
ProviderIDList []string `json:"providerIDList,omitempty"` | ||
} | ||
|
||
// AWSMachinePoolStatus defines the observed state of AWSMachinePool | ||
type AWSMachinePoolStatus struct { | ||
// Ready is true when the provider resource is ready. | ||
// +optional | ||
Ready bool `json:"ready"` | ||
|
||
// Replicas is the most recently observed number of replicas | ||
// +optional | ||
Replicas int32 `json:"replicas"` | ||
|
||
// Conditions defines current service state of the AWSMachinePool. | ||
// +optional | ||
Conditions clusterv1.Conditions `json:"conditions,omitempty"` | ||
|
||
// The ID of the launch template | ||
LaunchTemplateID string `json:"launchTemplateID,omitempty"` | ||
|
||
// FailureReason will be set in the event that there is a terminal problem | ||
// reconciling the Machine and will contain a succinct value suitable | ||
// for machine interpretation. | ||
// | ||
// This field should not be set for transitive errors that a controller | ||
// faces that are expected to be fixed automatically over | ||
// time (like service outages), but instead indicate that something is | ||
// fundamentally wrong with the Machine's spec or the configuration of | ||
// the controller, and that manual intervention is required. Examples | ||
// of terminal errors would be invalid combinations of settings in the | ||
// spec, values that are unsupported by the controller, or the | ||
// responsible controller itself being critically misconfigured. | ||
// | ||
// Any transient errors that occur during the reconciliation of Machines | ||
// can be added as events to the Machine object and/or logged in the | ||
// controller's output. | ||
// +optional | ||
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` | ||
|
||
// FailureMessage will be set in the event that there is a terminal problem | ||
// reconciling the Machine and will contain a more verbose string suitable | ||
// for logging and human consumption. | ||
// | ||
// This field should not be set for transitive errors that a controller | ||
// faces that are expected to be fixed automatically over | ||
// time (like service outages), but instead indicate that something is | ||
// fundamentally wrong with the Machine's spec or the configuration of | ||
// the controller, and that manual intervention is required. Examples | ||
// of terminal errors would be invalid combinations of settings in the | ||
// spec, values that are unsupported by the controller, or the | ||
// responsible controller itself being critically misconfigured. | ||
// | ||
// Any transient errors that occur during the reconciliation of Machines | ||
// can be added as events to the Machine object and/or logged in the | ||
// controller's output. | ||
// +optional | ||
FailureMessage *string `json:"failureMessage,omitempty"` | ||
|
||
ASGStatus *ASGStatus `json:"asgStatus,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:path=awsmachinepools,scope=Namespaced,categories=cluster-api | ||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status" | ||
// +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="Machine ready status" | ||
// +kubebuilder:printcolumn:name="MinSize",type="integer",JSONPath=".spec.minSize",description="Minimum instanes in ASG" | ||
// +kubebuilder:printcolumn:name="MaxSize",type="integer",JSONPath=".spec.maxSize",description="Maximum instanes in ASG" | ||
// +kubebuilder:printcolumn:name="LaunchTemplate ID",type="string",JSONPath=".status.launchTemplateID",description="Launch Template ID" | ||
|
||
// AWSMachinePool is the Schema for the awsmachinepools API | ||
type AWSMachinePool struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec AWSMachinePoolSpec `json:"spec,omitempty"` | ||
Status AWSMachinePoolStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// AWSMachinePoolList contains a list of AWSMachinePool | ||
type AWSMachinePoolList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []AWSMachinePool `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&AWSMachinePool{}, &AWSMachinePoolList{}) | ||
} | ||
|
||
func (r *AWSMachinePool) GetConditions() clusterv1.Conditions { | ||
return r.Status.Conditions | ||
} | ||
|
||
func (r *AWSMachinePool) SetConditions(conditions clusterv1.Conditions) { | ||
r.Status.Conditions = conditions | ||
} | ||
|
||
func (r *AWSMachinePool) GetObjectKind() schema.ObjectKind { | ||
return &r.TypeMeta | ||
} | ||
|
||
func (r *AWSMachinePoolList) GetObjectKind() schema.ObjectKind { | ||
return &r.TypeMeta | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
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" | ||
|
||
const ( | ||
// ASGReadyCondition reports on current status of the autoscaling group. Ready indicates the group is provisioned | ||
ASGReadyCondition clusterv1.ConditionType = "ASGReady" | ||
// ASGNotFoundReason used when the autoscaling group couldn't be retrieved. | ||
ASGNotFoundReason = "ASGNotFound" | ||
// ASGProvisionFailedReason used for failures during autoscaling group provisioning. | ||
ASGProvisionFailedReason = "ASGProvisionFailed" | ||
// ASGDeletionInProgress ASG is in a deletion in progress state. | ||
ASGDeletionInProgress = "ASGDeletionInProgress" | ||
|
||
// LaunchTemplateReadyCondition represents the status of an AWSMachinePool's associated Launch Template | ||
LaunchTemplateReadyCondition clusterv1.ConditionType = "LaunchTemplateReady" | ||
// LaunchTemplateNotFoundReason is used when an associated Launch Template can't be found | ||
LaunchTemplateNotFoundReason = "LaunchTemplateNotFound" | ||
// LaunchTemplateCreateFailedReason used for failures during Launch Template creation | ||
LaunchTemplateCreateFailedReason = "LaunchTemplateCreateFailed" | ||
) |
Oops, something went wrong.