sigs.k8s.io/cluster-api-provider-aws@v1.5.5/exp/api/v1alpha3/awsfargateprofile_types.go (about) 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 ( 20 "fmt" 21 22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 24 infrav1alpha3 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha3" 25 iamv1 "sigs.k8s.io/cluster-api-provider-aws/iam/api/v1beta1" 26 clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" 27 "sigs.k8s.io/cluster-api/errors" 28 ) 29 30 const ( 31 // FargateProfileFinalizer allows the controller to clean up resources on delete. 32 FargateProfileFinalizer = "awsfargateprofile.infrastructure.cluster.x-k8s.io" 33 ) 34 35 var ( 36 // DefaultEKSFargateRole is the name of the default IAM role to use for fargate 37 // profiles if no other role is supplied in the spec and if iam role creation 38 // is not enabled. The default can be created using clusterawsadm or created manually. 39 DefaultEKSFargateRole = fmt.Sprintf("eks-fargate%s", iamv1.DefaultNameSuffix) 40 ) 41 42 // FargateProfileSpec defines the desired state of FargateProfile 43 type FargateProfileSpec struct { 44 // ClusterName is the name of the Cluster this object belongs to. 45 // +kubebuilder:validation:MinLength=1 46 ClusterName string `json:"clusterName"` 47 48 // ProfileName specifies the profile name. 49 ProfileName string `json:"profileName,omitempty"` 50 51 // SubnetIDs specifies which subnets are used for the 52 // auto scaling group of this nodegroup. 53 // +optional 54 SubnetIDs []string `json:"subnetIDs,omitempty"` 55 56 // AdditionalTags is an optional set of tags to add to AWS resources managed by the AWS provider, in addition to the 57 // ones added by default. 58 // +optional 59 AdditionalTags infrav1alpha3.Tags `json:"additionalTags,omitempty"` 60 61 // RoleName specifies the name of IAM role for this fargate pool 62 // If the role is pre-existing we will treat it as unmanaged 63 // and not delete it on deletion. If the EKSEnableIAM feature 64 // flag is true and no name is supplied then a role is created. 65 // +optional 66 RoleName string `json:"roleName,omitempty"` 67 68 // Selectors specify fargate pod selectors. 69 Selectors []FargateSelector `json:"selectors,omitempty"` 70 } 71 72 // FargateSelector specifies a selector for pods that should run on this fargate 73 // pool 74 type FargateSelector struct { 75 // Labels specifies which pod labels this selector should match. 76 Labels map[string]string `json:"labels,omitempty"` 77 78 // Namespace specifies which namespace this selector should match. 79 Namespace string `json:"namespace,omitempty"` 80 } 81 82 // FargateProfileStatus defines the observed state of FargateProfile 83 type FargateProfileStatus struct { 84 // Ready denotes that the FargateProfile is available. 85 // +kubebuilder:default=false 86 Ready bool `json:"ready"` 87 88 // FailureReason will be set in the event that there is a terminal problem 89 // reconciling the FargateProfile and will contain a succinct value suitable 90 // for machine interpretation. 91 // 92 // This field should not be set for transitive errors that a controller 93 // faces that are expected to be fixed automatically over 94 // time (like service outages), but instead indicate that something is 95 // fundamentally wrong with the FargateProfile's spec or the configuration of 96 // the controller, and that manual intervention is required. Examples 97 // of terminal errors would be invalid combinations of settings in the 98 // spec, values that are unsupported by the controller, or the 99 // responsible controller itself being critically misconfigured. 100 // 101 // Any transient errors that occur during the reconciliation of 102 // FargateProfiles can be added as events to the FargateProfile object 103 // and/or logged in the controller's output. 104 // +optional 105 FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` 106 107 // FailureMessage will be set in the event that there is a terminal problem 108 // reconciling the FargateProfile and will contain a more verbose string suitable 109 // for logging and human consumption. 110 // 111 // This field should not be set for transitive errors that a controller 112 // faces that are expected to be fixed automatically over 113 // time (like service outages), but instead indicate that something is 114 // fundamentally wrong with the FargateProfile's spec or the configuration of 115 // the controller, and that manual intervention is required. Examples 116 // of terminal errors would be invalid combinations of settings in the 117 // spec, values that are unsupported by the controller, or the 118 // responsible controller itself being critically misconfigured. 119 // 120 // Any transient errors that occur during the reconciliation of 121 // FargateProfiles can be added as events to the FargateProfile 122 // object and/or logged in the controller's output. 123 // +optional 124 FailureMessage *string `json:"failureMessage,omitempty"` 125 126 // Conditions defines current state of the Fargate profile. 127 // +optional 128 Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` 129 } 130 131 // +kubebuilder:object:root=true 132 // +kubebuilder:resource:path=awsfargateprofiles,scope=Namespaced,categories=cluster-api,shortName=awsfp 133 // +kubebuilder:subresource:status 134 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="AWSFargateProfile ready status" 135 // +kubebuilder:printcolumn:name="ProfileName",type="string",JSONPath=".spec.profileName",description="EKS Fargate profile name" 136 // +kubebuilder:printcolumn:name="FailureReason",type="string",JSONPath=".status.failureReason",description="Failure reason" 137 138 // AWSFargateProfile is the Schema for the awsfargateprofiles API 139 type AWSFargateProfile struct { 140 metav1.TypeMeta `json:",inline"` 141 metav1.ObjectMeta `json:"metadata,omitempty"` 142 143 Spec FargateProfileSpec `json:"spec,omitempty"` 144 Status FargateProfileStatus `json:"status,omitempty"` 145 } 146 147 // GetConditions returns the observations of the operational state of the AWSFargateProfile resource. 148 func (r *AWSFargateProfile) GetConditions() clusterv1alpha3.Conditions { 149 return r.Status.Conditions 150 } 151 152 // SetConditions sets the underlying service state of the AWSFargateProfile to the predescribed clusterv1alpha3.Conditions. 153 func (r *AWSFargateProfile) SetConditions(conditions clusterv1alpha3.Conditions) { 154 r.Status.Conditions = conditions 155 } 156 157 // +kubebuilder:object:root=true 158 159 // AWSFargateProfileList contains a list of FargateProfiles. 160 type AWSFargateProfileList struct { 161 metav1.TypeMeta `json:",inline"` 162 metav1.ListMeta `json:"metadata,omitempty"` 163 Items []AWSFargateProfile `json:"items"` 164 } 165 166 func init() { 167 SchemeBuilder.Register(&AWSFargateProfile{}, &AWSFargateProfileList{}) 168 }