diff --git a/.gitignore b/.gitignore index 896565e606..80b0b6b292 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ kubeconfig # Ignore output manifests examples/out examples/provider-components-base.yaml +config/samples diff --git a/Dockerfile b/Dockerfile index 19e3dc7aa1..991031e5d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,20 +13,23 @@ # limitations under the License. # Build the manager binary -FROM golang:1.12.6 as builder +FROM golang:1.12.7 as builder # Copy in the go src WORKDIR ${GOPATH}/src/sigs.k8s.io/cluster-api-provider-aws COPY pkg/ pkg/ COPY cmd/ cmd/ COPY vendor/ vendor/ +COPY api/ api/ +COPY controllers/ controllers/ +COPY main.go main.go COPY go.mod go.mod COPY go.sum go.sum # Build RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOFLAGS="-mod=vendor" \ go build -a -ldflags '-extldflags "-static"' \ - -o manager sigs.k8s.io/cluster-api-provider-aws/cmd/manager + -o manager sigs.k8s.io/cluster-api-provider-aws # Copy the controller-manager into a thin image FROM gcr.io/distroless/static:latest diff --git a/PROJECT b/PROJECT index 4f1ff6865c..c462ca8448 100644 --- a/PROJECT +++ b/PROJECT @@ -1,3 +1,13 @@ -version: "1" +version: "2" domain: cluster.x-k8s.io repo: sigs.k8s.io/cluster-api-provider-aws +resources: +- group: infrastructure + version: v1alpha2 + kind: AWSMachine +- group: infrastructure + version: v1alpha2 + kind: AWSCluster +- group: infrastructure + version: v1alpha2 + kind: AWSMachineTemplate diff --git a/api/v1alpha2/BUILD.bazel b/api/v1alpha2/BUILD.bazel new file mode 100644 index 0000000000..12f5979428 --- /dev/null +++ b/api/v1alpha2/BUILD.bazel @@ -0,0 +1,25 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "awscluster_types.go", + "awsmachine_types.go", + "awsmachinetemplate_types.go", + "groupversion_info.go", + "tags.go", + "types.go", + "zz_generated.deepcopy.go", + ], + importpath = "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2", + visibility = ["//visibility:public"], + deps = [ + "//vendor/k8s.io/api/core/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + "//vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2:go_default_library", + "//vendor/sigs.k8s.io/cluster-api/pkg/errors:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/scheme:go_default_library", + ], +) diff --git a/api/v1alpha2/awscluster_types.go b/api/v1alpha2/awscluster_types.go new file mode 100644 index 0000000000..304e56996e --- /dev/null +++ b/api/v1alpha2/awscluster_types.go @@ -0,0 +1,76 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // ClusterFinalizer allows ReconcileAWSCluster to clean up AWS resources associated with AWSCluster before + // removing it from the apiserver. + ClusterFinalizer = "awscluster.infrastructure.cluster.x-k8s.io" +) + +// AWSClusterSpec defines the desired state of AWSCluster +type AWSClusterSpec struct { + // NetworkSpec encapsulates all things related to AWS network. + NetworkSpec NetworkSpec `json:"networkSpec,omitempty"` + + // The AWS Region the cluster lives in. + Region string `json:"region,omitempty"` + + // SSHKeyName is the name of the ssh key to attach to the bastion host. + SSHKeyName string `json:"sshKeyName,omitempty"` +} + +// AWSClusterStatus defines the observed state of AWSCluster +type AWSClusterStatus struct { + Network Network `json:"network,omitempty"` + Bastion Instance `json:"bastion,omitempty"` + Ready bool `json:"ready"` + // APIEndpoints represents the endpoints to communicate with the control plane. + // +optional + APIEndpoints []APIEndpoint `json:"apiEndpoints,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=awsclusters,scope=Namespaced +// +kubebuilder:storageversion +// +kubebuilder:subresource:status + +// AWSCluster is the Schema for the awsclusters API +type AWSCluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AWSClusterSpec `json:"spec,omitempty"` + Status AWSClusterStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// AWSClusterList contains a list of AWSCluster +type AWSClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AWSCluster `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AWSCluster{}, &AWSClusterList{}) +} diff --git a/api/v1alpha2/awsmachine_types.go b/api/v1alpha2/awsmachine_types.go new file mode 100644 index 0000000000..5c59e51a5b --- /dev/null +++ b/api/v1alpha2/awsmachine_types.go @@ -0,0 +1,166 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/cluster-api/pkg/errors" +) + +const ( + // MachineFinalizer allows ReconcileAWSMachine to clean up AWS resources associated with AWSMachine before + // removing it from the apiserver. + MachineFinalizer = "awsmachine.infrastructure.cluster.x-k8s.io" +) + +// AWSMachineSpec defines the desired state of AWSMachine +type AWSMachineSpec struct { + // ProviderID is the unique identifier as specified by the cloud provider. + ProviderID *string `json:"providerID,omitempty"` + + // AMI is the reference to the AMI from which to create the machine instance. + AMI AWSResourceReference `json:"ami,omitempty"` + + // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. + ImageLookupOrg string `json:"imageLookupOrg,omitempty"` + + // InstanceType is the type of instance to create. Example: m4.xlarge + InstanceType string `json:"instanceType,omitempty"` + + // AdditionalTags is the set of tags to add to an instance, in addition to the ones + // added by default by the actuator. These tags are additive. The actuator will ensure + // these tags are present, but will not remove any other tags that may exist on the + // instance. + // +optional + AdditionalTags map[string]string `json:"additionalTags,omitempty"` + + // IAMInstanceProfile is a name of an IAM instance profile to assign to the instance + // +optional + IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"` + + // PublicIP specifies whether the instance should get a public IP. + // Precedence for this setting is as follows: + // 1. This field if set + // 2. Cluster/flavor setting + // 3. Subnet default + // +optional + PublicIP *bool `json:"publicIP,omitempty"` + + // AdditionalSecurityGroups is an array of references to security groups that should be applied to the + // instance. These security groups would be set in addition to any security groups defined + // at the cluster level or in the actuator. + // +optional + AdditionalSecurityGroups []AWSResourceReference `json:"additionalSecurityGroups,omitempty"` + + // AvailabilityZone is references the AWS availability zone to use for this instance. + // If multiple subnets are matched for the availability zone, the first one return is picked. + // +optional + AvailabilityZone *string `json:"availabilityZone,omitempty"` + + // Subnet is a reference to the subnet to use for this instance. If not specified, + // the cluster subnet will be used. + // +optional + Subnet *AWSResourceReference `json:"subnet,omitempty"` + + // KeyName is the name of the SSH key to install on the instance. + // +optional + KeyName string `json:"keyName,omitempty"` + + // RootDeviceSize is the size of the root volume. + // +optional + RootDeviceSize int64 `json:"rootDeviceSize,omitempty"` +} + +// AWSMachineStatus defines the observed state of AWSMachine +type AWSMachineStatus struct { + // Ready is true when the provider resource is ready. + // +optional + Ready bool `json:"ready"` + + // Addresses contains the AWS instance associated addresses. + Addresses []v1.NodeAddress `json:"addresses,omitempty"` + + // InstanceState is the state of the AWS instance for this machine. + // +optional + InstanceState *InstanceState `json:"instanceState,omitempty"` + + // ErrorReason 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 + ErrorReason *errors.MachineStatusError `json:"errorReason,omitempty"` + + // ErrorMessage 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 + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=awsmachines,scope=Namespaced +// +kubebuilder:storageversion +// +kubebuilder:subresource:status + +// AWSMachine is the Schema for the awsmachines API +type AWSMachine struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AWSMachineSpec `json:"spec,omitempty"` + Status AWSMachineStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// AWSMachineList contains a list of AWSMachine +type AWSMachineList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AWSMachine `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AWSMachine{}, &AWSMachineList{}) +} diff --git a/api/v1alpha2/awsmachinetemplate_types.go b/api/v1alpha2/awsmachinetemplate_types.go new file mode 100644 index 0000000000..00f816d688 --- /dev/null +++ b/api/v1alpha2/awsmachinetemplate_types.go @@ -0,0 +1,51 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate +type AWSMachineTemplateSpec struct { + Template AWSMachineTemplateResource `json:"template"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=awsmachinetemplates,scope=Namespaced +// +kubebuilder:storageversion + +// AWSMachineTemplate is the Schema for the awsmachinetemplates API +type AWSMachineTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AWSMachineTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// AWSMachineTemplateList contains a list of AWSMachineTemplate +type AWSMachineTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AWSMachineTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AWSMachineTemplate{}, &AWSMachineTemplateList{}) +} diff --git a/api/v1alpha2/groupversion_info.go b/api/v1alpha2/groupversion_info.go new file mode 100644 index 0000000000..524a6cefb3 --- /dev/null +++ b/api/v1alpha2/groupversion_info.go @@ -0,0 +1,36 @@ +/* +Copyright 2019 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 v1alpha2 contains API Schema definitions for the infrastructure v1alpha2 API group +// +kubebuilder:object:generate=true +// +groupName=infrastructure.cluster.x-k8s.io +package v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha2"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/api/v1alpha2/tags.go b/api/v1alpha2/tags.go new file mode 100644 index 0000000000..69c9c1ba02 --- /dev/null +++ b/api/v1alpha2/tags.go @@ -0,0 +1,167 @@ +/* +Copyright 2019 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 v1alpha2 + +import ( + "fmt" + "reflect" +) + +// Tags defines a map of tags. +type Tags map[string]string + +// Equals returns true if the tags are equal. +func (t Tags) Equals(other Tags) bool { + return reflect.DeepEqual(t, other) +} + +// HasOwned returns true if the tags contains a tag that marks the resource as owned by the cluster from the perspective of this management tooling. +func (t Tags) HasOwned(cluster string) bool { + value, ok := t[ClusterTagKey(cluster)] + return ok && ResourceLifecycle(value) == ResourceLifecycleOwned +} + +// HasOwned returns true if the tags contains a tag that marks the resource as owned by the cluster from the perspective of the in-tree cloud provider. +func (t Tags) HasAWSCloudProviderOwned(cluster string) bool { + value, ok := t[ClusterAWSCloudProviderTagKey(cluster)] + return ok && ResourceLifecycle(value) == ResourceLifecycleOwned +} + +// GetRole returns the Cluster API role for the tagged resource +func (t Tags) GetRole() string { + return t[NameAWSClusterAPIRole] +} + +// Difference returns the difference between this map of tags and the other map of tags. +// Items are considered equals if key and value are equals. +func (t Tags) Difference(other Tags) Tags { + res := make(Tags, len(t)) + + for key, value := range t { + if otherValue, ok := other[key]; ok && value == otherValue { + continue + } + res[key] = value + } + + return res +} + +// ResourceLifecycle configures the lifecycle of a resource +type ResourceLifecycle string + +const ( + // ResourceLifecycleOwned is the value we use when tagging resources to indicate + // that the resource is considered owned and managed by the cluster, + // and in particular that the lifecycle is tied to the lifecycle of the cluster. + ResourceLifecycleOwned = ResourceLifecycle("owned") + + // ResourceLifecycleShared is the value we use when tagging resources to indicate + // that the resource is shared between multiple clusters, and should not be destroyed + // if the cluster is destroyed. + ResourceLifecycleShared = ResourceLifecycle("shared") + + // NameKubernetesClusterPrefix is the tag name used by the cloud provider to logically + // separate independent cluster resources. We use it to identify which resources we expect + // to be permissive about state changes. + // logically independent clusters running in the same AZ. + // The tag key = NameKubernetesAWSCloudProviderPrefix + clusterID + // The tag value is an ownership value + NameKubernetesAWSCloudProviderPrefix = "kubernetes.io/cluster/" + + // NameAWSProviderPrefix is the tag prefix we use to differentiate + // cluster-api-provider-aws owned components from other tooling that + // uses NameKubernetesClusterPrefix + NameAWSProviderPrefix = "sigs.k8s.io/cluster-api-provider-aws/" + + // NameAWSProviderOwned is the tag name we use to differentiate + // cluster-api-provider-aws owned components from other tooling that + // uses NameKubernetesClusterPrefix + NameAWSProviderOwned = NameAWSProviderPrefix + "cluster/" + + // NameAWSClusterAPIRole is the tag name we use to mark roles for resources + // dedicated to this cluster api provider implementation. + NameAWSClusterAPIRole = NameAWSProviderPrefix + "role" + + // APIServerRoleTagValue describes the value for the apiserver role + APIServerRoleTagValue = "apiserver" + + // BastionRoleTagValue describes the value for the bastion role + BastionRoleTagValue = "bastion" + + // CommonRoleTagValue describes the value for the common role + CommonRoleTagValue = "common" + + // PublicRoleTagValue describes the value for the public role + PublicRoleTagValue = "public" + + // PrivateRoleTagValue describes the value for the private role + PrivateRoleTagValue = "private" +) + +// ClusterTagKey generates the key for resources associated with a cluster. +func ClusterTagKey(name string) string { + return fmt.Sprintf("%s%s", NameAWSProviderOwned, name) +} + +// ClusterAWSCloudProviderTagKey generates the key for resources associated a cluster's AWS cloud provider. +func ClusterAWSCloudProviderTagKey(name string) string { + return fmt.Sprintf("%s%s", NameKubernetesAWSCloudProviderPrefix, name) +} + +// BuildParams is used to build tags around an aws resource. +type BuildParams struct { + // Lifecycle determines the resource lifecycle. + Lifecycle ResourceLifecycle + + // ClusterName is the cluster associated with the resource. + ClusterName string + + // ResourceID is the unique identifier of the resource to be tagged. + ResourceID string + + // Name is the name of the resource, it's applied as the tag "Name" on AWS. + // +optional + Name *string + + // Role is the role associated to the resource. + // +optional + Role *string + + // Any additional tags to be added to the resource. + // +optional + Additional Tags +} + +// Build builds tags including the cluster tag and returns them in map form. +func Build(params BuildParams) Tags { + tags := make(Tags) + for k, v := range params.Additional { + tags[k] = v + } + + tags[ClusterTagKey(params.ClusterName)] = string(params.Lifecycle) + if params.Role != nil { + tags[NameAWSClusterAPIRole] = *params.Role + } + + if params.Name != nil { + tags["Name"] = *params.Name + } + + return tags +} diff --git a/api/v1alpha2/types.go b/api/v1alpha2/types.go new file mode 100644 index 0000000000..90a3b96f79 --- /dev/null +++ b/api/v1alpha2/types.go @@ -0,0 +1,536 @@ +/* +Copyright 2018 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 v1alpha2 + +import ( + "fmt" + "sort" + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2" +) + +const ( + AnnotationClusterInfrastructureReady = "aws.infrastructure.cluster.x-k8s.io/infrastructure-ready" + AnnotationControlPlaneReady = "aws.infrastructure.cluster.x-k8s.io/control-plane-ready" + ValueReady = "true" +) + +// AWSResourceReference is a reference to a specific AWS resource by ID, ARN, or filters. +// Only one of ID, ARN or Filters may be specified. Specifying more than one will result in +// a validation error. +type AWSResourceReference struct { + // ID of resource + // +optional + ID *string `json:"id,omitempty"` + + // ARN of resource + // +optional + ARN *string `json:"arn,omitempty"` + + // Filters is a set of key/value pairs used to identify a resource + // They are applied according to the rules defined by the AWS API: + // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html + // +optional + Filters []Filter `json:"filters,omitempty"` +} + +// AWSMachineTemplateResource describes the data needed to create am AWSMachine from a template +type AWSMachineTemplateResource struct { + metav1.TypeMeta `json:",inline"` + + // Standard object's metadata. + clusterv1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the specification of the desired behavior of the machine. + Spec AWSMachineSpec `json:"spec"` +} + +// Filter is a filter used to identify an AWS resource +type Filter struct { + // Name of the filter. Filter names are case-sensitive. + Name string `json:"name"` + + // Values includes one or more filter values. Filter values are case-sensitive. + Values []string `json:"values"` +} + +// AWSMachineProviderConditionType is a valid value for AWSMachineProviderCondition.Type +type AWSMachineProviderConditionType string + +// Valid conditions for an AWS machine instance +const ( + // MachineCreated indicates whether the machine has been created or not. If not, + // it should include a reason and message for the failure. + MachineCreated AWSMachineProviderConditionType = "MachineCreated" +) + +// Network encapsulates AWS networking resources. +type Network struct { + // SecurityGroups is a map from the role/kind of the security group to its unique name, if any. + SecurityGroups map[SecurityGroupRole]SecurityGroup `json:"securityGroups,omitempty"` + + // APIServerELB is the Kubernetes api server classic load balancer. + APIServerELB ClassicELB `json:"apiServerElb,omitempty"` +} + +// ClassicELBScheme defines the scheme of a classic load balancer. +type ClassicELBScheme string + +var ( + // ClassicELBSchemeInternetFacing defines an internet-facing, publicly + // accessible AWS Classic ELB scheme + ClassicELBSchemeInternetFacing = ClassicELBScheme("Internet-facing") + + // ClassicELBSchemeInternal defines an internal-only facing + // load balancer internal to an ELB. + ClassicELBSchemeInternal = ClassicELBScheme("internal") +) + +// ClassicELBProtocol defines listener protocols for a classic load balancer. +type ClassicELBProtocol string + +var ( + // ClassicELBProtocolTCP defines the ELB API string representing the TCP protocol + ClassicELBProtocolTCP = ClassicELBProtocol("TCP") + + // ClassicELBProtocolSSL defines the ELB API string representing the TLS protocol + ClassicELBProtocolSSL = ClassicELBProtocol("SSL") + + // ClassicELBProtocolHTTP defines the ELB API string representing the HTTP protocol at L7 + ClassicELBProtocolHTTP = ClassicELBProtocol("HTTP") + + // ClassicELBProtocolHTTPS defines the ELB API string representing the HTTP protocol at L7 + ClassicELBProtocolHTTPS = ClassicELBProtocol("HTTPS") +) + +// ClassicELB defines an AWS classic load balancer. +type ClassicELB struct { + // The name of the load balancer. It must be unique within the set of load balancers + // defined in the region. It also serves as identifier. + Name string `json:"name,omitempty"` + + // DNSName is the dns name of the load balancer. + DNSName string `json:"dnsName,omitempty"` + + // Scheme is the load balancer scheme, either internet-facing or private. + Scheme ClassicELBScheme `json:"scheme,omitempty"` + + // SubnetIDs is an array of subnets in the VPC attached to the load balancer. + SubnetIDs []string `json:"subnetIds,omitempty"` + + // SecurityGroupIDs is an array of security groups assigned to the load balancer. + SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` + + // Listeners is an array of classic elb listeners associated with the load balancer. There must be at least one. + Listeners []*ClassicELBListener `json:"listeners,omitempty"` + + // HealthCheck is the classic elb health check associated with the load balancer. + HealthCheck *ClassicELBHealthCheck `json:"healthChecks,omitempty"` + + // Attributes defines extra attributes associated with the load balancer. + Attributes ClassicELBAttributes `json:"attributes,omitempty"` + + // Tags is a map of tags associated with the load balancer. + Tags map[string]string `json:"tags,omitempty"` +} + +// ClassicELBAttributes defines extra attributes associated with a classic load balancer. +type ClassicELBAttributes struct { + // IdleTimeout is time that the connection is allowed to be idle (no data + // has been sent over the connection) before it is closed by the load balancer. + IdleTimeout time.Duration `json:"idleTimeout,omitempty"` +} + +// ClassicELBListener defines an AWS classic load balancer listener. +type ClassicELBListener struct { + Protocol ClassicELBProtocol `json:"protocol"` + Port int64 `json:"port"` + InstanceProtocol ClassicELBProtocol `json:"instanceProtocol"` + InstancePort int64 `json:"instancePort"` +} + +// ClassicELBHealthCheck defines an AWS classic load balancer health check. +type ClassicELBHealthCheck struct { + Target string `json:"target"` + Interval time.Duration `json:"interval"` + Timeout time.Duration `json:"timeout"` + HealthyThreshold int64 `json:"healthyThreshold"` + UnhealthyThreshold int64 `json:"unhealthyThreshold"` +} + +// NetworkSpec encapsulates all things related to AWS network. +type NetworkSpec struct { + // VPC configuration. + // +optional + VPC VPCSpec `json:"vpc,omitempty"` + + // Subnets configuration. + // +optional + Subnets Subnets `json:"subnets,omitempty"` +} + +// APIEndpoint represents a reachable Kubernetes API endpoint. +type APIEndpoint struct { + // The hostname on which the API server is serving. + Host string `json:"host"` + + // The port on which the API server is serving. + Port int `json:"port"` +} + +// VPCSpec configures an AWS VPC. +type VPCSpec struct { + // ID is the vpc-id of the VPC this provider should use to create resources. + ID string `json:"id,omitempty"` + + // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. + // Defaults to 10.0.0.0/16. + CidrBlock string `json:"cidrBlock,omitempty"` + + // InternetGatewayID is the id of the internet gateway associated with the VPC. + // +optional + InternetGatewayID *string `json:"internetGatewayId,omitempty"` + + // Tags is a collection of tags describing the resource. + Tags Tags `json:"tags,omitempty"` +} + +// String returns a string representation of the VPC. +func (v *VPCSpec) String() string { + return fmt.Sprintf("id=%s", v.ID) +} + +// IsUnmanaged returns true if the VPC is unmanaged. +func (v *VPCSpec) IsUnmanaged(clusterName string) bool { + return v.ID != "" && !v.Tags.HasOwned(clusterName) +} + +// SubnetSpec configures an AWS Subnet. +type SubnetSpec struct { + // ID defines a unique identifier to reference this resource. + ID string `json:"id,omitempty"` + + // CidrBlock is the CIDR block to be used when the provider creates a managed VPC. + CidrBlock string `json:"cidrBlock,omitempty"` + + // AvailabilityZone defines the availability zone to use for this subnet in the cluster's region. + AvailabilityZone string `json:"availabilityZone,omitempty"` + + // IsPublic defines the subnet as a public subnet. A subnet is public when it is associated with a route table that has a route to an internet gateway. + // +optional + IsPublic bool `json:"isPublic"` + + // RouteTableID is the routing table id associated with the subnet. + // +optional + RouteTableID *string `json:"routeTableId"` + + // NatGatewayID is the NAT gateway id associated with the subnet. + // Ignored unless the subnet is managed by the provider, in which case this is set on the public subnet where the NAT gateway resides. It is then used to determine routes for private subnets in the same AZ as the public subnet. + // +optional + NatGatewayID *string `json:"natGatewayId,omitempty"` + + // Tags is a collection of tags describing the resource. + Tags Tags `json:"tags,omitempty"` +} + +// String returns a string representation of the subnet. +func (s *SubnetSpec) String() string { + return fmt.Sprintf("id=%s/az=%s/public=%v", s.ID, s.AvailabilityZone, s.IsPublic) +} + +// Subnets is a slice of Subnet. +type Subnets []*SubnetSpec + +// ToMap returns a map from id to subnet. +func (s Subnets) ToMap() map[string]*SubnetSpec { + res := make(map[string]*SubnetSpec) + for _, x := range s { + res[x.ID] = x + } + return res +} + +// FindByID returns a single subnet matching the given id or nil. +func (s Subnets) FindByID(id string) *SubnetSpec { + for _, x := range s { + if x.ID == id { + return x + } + } + + return nil +} + +// FilterPrivate returns a slice containing all subnets marked as private. +func (s Subnets) FilterPrivate() (res Subnets) { + for _, x := range s { + if !x.IsPublic { + res = append(res, x) + } + } + return +} + +// FilterPublic returns a slice containing all subnets marked as public. +func (s Subnets) FilterPublic() (res Subnets) { + for _, x := range s { + if x.IsPublic { + res = append(res, x) + } + } + return +} + +// FilterByZone returns a slice containing all subnets that live in the availability zone specified. +func (s Subnets) FilterByZone(zone string) (res Subnets) { + for _, x := range s { + if x.AvailabilityZone == zone { + res = append(res, x) + } + } + return +} + +// RouteTable defines an AWS routing table. +type RouteTable struct { + ID string `json:"id"` +} + +// SecurityGroupRole defines the unique role of a security group. +type SecurityGroupRole string + +var ( + // SecurityGroupBastion defines an SSH bastion role + SecurityGroupBastion = SecurityGroupRole("bastion") + + // SecurityGroupNode defines a Kubernetes workload node role + SecurityGroupNode = SecurityGroupRole("node") + + // SecurityGroupControlPlane defines a Kubernetes control plane node role + SecurityGroupControlPlane = SecurityGroupRole("controlplane") + + // SecurityGroupLB defines a container for the cloud provider to inject its load balancer ingress rules + SecurityGroupLB = SecurityGroupRole("lb") +) + +// SecurityGroup defines an AWS security group. +type SecurityGroup struct { + // ID is a unique identifier. + ID string `json:"id"` + + // Name is the security group name. + Name string `json:"name"` + + // IngressRules is the inbound rules associated with the security group. + // +optional + IngressRules IngressRules `json:"ingressRule"` + + // Tags is a map of tags associated with the security group. + Tags Tags `json:"tags,omitempty"` +} + +// String returns a string representation of the security group. +func (s *SecurityGroup) String() string { + return fmt.Sprintf("id=%s/name=%s", s.ID, s.Name) +} + +// SecurityGroupProtocol defines the protocol type for a security group rule. +type SecurityGroupProtocol string + +var ( + // SecurityGroupProtocolAll is a wildcard for all IP protocols + SecurityGroupProtocolAll = SecurityGroupProtocol("-1") + + // SecurityGroupProtocolIPinIP represents the IP in IP protocol in ingress rules + SecurityGroupProtocolIPinIP = SecurityGroupProtocol("4") + + // SecurityGroupProtocolTCP represents the TCP protocol in ingress rules + SecurityGroupProtocolTCP = SecurityGroupProtocol("tcp") + + // SecurityGroupProtocolUDP represents the UDP protocol in ingress rules + SecurityGroupProtocolUDP = SecurityGroupProtocol("udp") + + // SecurityGroupProtocolICMP represents the ICMP protocol in ingress rules + SecurityGroupProtocolICMP = SecurityGroupProtocol("icmp") + + // SecurityGroupProtocolICMPv6 represents the ICMPv6 protocol in ingress rules + SecurityGroupProtocolICMPv6 = SecurityGroupProtocol("58") +) + +// IngressRule defines an AWS ingress rule for security groups. +type IngressRule struct { + Description string `json:"description"` + Protocol SecurityGroupProtocol `json:"protocol"` + FromPort int64 `json:"fromPort"` + ToPort int64 `json:"toPort"` + + // List of CIDR blocks to allow access from. Cannot be specified with SourceSecurityGroupID. + // +optional + CidrBlocks []string `json:"cidrBlocks"` + + // The security group id to allow access from. Cannot be specified with CidrBlocks. + // +optional + SourceSecurityGroupIDs []string `json:"sourceSecurityGroupIds"` +} + +// String returns a string representation of the ingress rule. +func (i *IngressRule) String() string { + return fmt.Sprintf("protocol=%s/range=[%d-%d]/description=%s", i.Protocol, i.FromPort, i.ToPort, i.Description) +} + +// IngressRules is a slice of AWS ingress rules for security groups. +type IngressRules []*IngressRule + +// Difference returns the difference between this slice and the other slice. +func (i IngressRules) Difference(o IngressRules) (out IngressRules) { + for _, x := range i { + found := false + for _, y := range o { + if x.Equals(y) { + found = true + break + } + } + + if !found { + out = append(out, x) + } + } + + return +} + +// Equals returns true if two IngressRule are equal +func (i *IngressRule) Equals(o *IngressRule) bool { + if len(i.CidrBlocks) != len(o.CidrBlocks) { + return false + } + + sort.Strings(i.CidrBlocks) + sort.Strings(o.CidrBlocks) + + for i, v := range i.CidrBlocks { + if v != o.CidrBlocks[i] { + return false + } + } + + if len(i.SourceSecurityGroupIDs) != len(o.SourceSecurityGroupIDs) { + return false + } + + sort.Strings(i.SourceSecurityGroupIDs) + sort.Strings(o.SourceSecurityGroupIDs) + + for i, v := range i.SourceSecurityGroupIDs { + if v != o.SourceSecurityGroupIDs[i] { + return false + } + } + + if i.Description != o.Description || i.Protocol != o.Protocol { + return false + } + + // AWS seems to ignore the From/To port when set on protocols where it doesn't apply, but + // we avoid serializing it out for clarity's sake. + // See: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_IpPermission.html + switch i.Protocol { + case SecurityGroupProtocolTCP, + SecurityGroupProtocolUDP, + SecurityGroupProtocolICMP, + SecurityGroupProtocolICMPv6: + return i.FromPort == o.FromPort && i.ToPort == o.ToPort + } + + return true +} + +// InstanceState describes the state of an AWS instance. +type InstanceState string + +var ( + // InstanceStatePending is the string representing an instance in a pending state + InstanceStatePending = InstanceState("pending") + + // InstanceStateRunning is the string representing an instance in a pending state + InstanceStateRunning = InstanceState("running") + + // InstanceStateShuttingDown is the string representing an instance shutting down + InstanceStateShuttingDown = InstanceState("shutting-down") + + // InstanceStateTerminated is the string representing an instance that has been terminated + InstanceStateTerminated = InstanceState("terminated") + + // InstanceStateStopping is the string representing an instance + // that is in the process of being stopped and can be restarted + InstanceStateStopping = InstanceState("stopping") + + // InstanceStateStopped is the string representing an instance + // that has been stopped and can be restarted + InstanceStateStopped = InstanceState("stopped") +) + +// Instance describes an AWS instance. +type Instance struct { + ID string `json:"id"` + + // The current state of the instance. + State InstanceState `json:"instanceState,omitempty"` + + // The instance type. + Type string `json:"type,omitempty"` + + // The ID of the subnet of the instance. + SubnetID string `json:"subnetId,omitempty"` + + // The ID of the AMI used to launch the instance. + ImageID string `json:"imageId,omitempty"` + + // The name of the SSH key pair. + KeyName *string `json:"keyName,omitempty"` + + // SecurityGroupIDs are one or more security group IDs this instance belongs to. + SecurityGroupIDs []string `json:"securityGroupIds,omitempty"` + + // UserData is the raw data script passed to the instance which is run upon bootstrap. + // This field must not be base64 encoded and should only be used when running a new instance. + UserData *string `json:"userData,omitempty"` + + // The name of the IAM instance profile associated with the instance, if applicable. + IAMProfile string `json:"iamProfile,omitempty"` + + // The private IPv4 address assigned to the instance. + PrivateIP *string `json:"privateIp,omitempty"` + + // The public IPv4 address assigned to the instance, if applicable. + PublicIP *string `json:"publicIp,omitempty"` + + // Specifies whether enhanced networking with ENA is enabled. + ENASupport *bool `json:"enaSupport,omitempty"` + + // Indicates whether the instance is optimized for Amazon EBS I/O. + EBSOptimized *bool `json:"ebsOptimized,omitempty"` + + // Specifies size (in Gi) of the root storage device + RootDeviceSize int64 `json:"rootDeviceSize,omitempty"` + + // The tags associated with the instance. + Tags map[string]string `json:"tags,omitempty"` +} diff --git a/api/v1alpha2/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go new file mode 100644 index 0000000000..3cee01e467 --- /dev/null +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -0,0 +1,863 @@ +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// autogenerated by controller-gen object, do not modify manually; DO NOT EDIT + +package v1alpha2 + +import ( + "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cluster-api/pkg/errors" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIEndpoint) DeepCopyInto(out *APIEndpoint) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIEndpoint. +func (in *APIEndpoint) DeepCopy() *APIEndpoint { + if in == nil { + return nil + } + out := new(APIEndpoint) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSCluster) DeepCopyInto(out *AWSCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSCluster. +func (in *AWSCluster) DeepCopy() *AWSCluster { + if in == nil { + return nil + } + out := new(AWSCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSClusterList) DeepCopyInto(out *AWSClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AWSCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterList. +func (in *AWSClusterList) DeepCopy() *AWSClusterList { + if in == nil { + return nil + } + out := new(AWSClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSClusterSpec) DeepCopyInto(out *AWSClusterSpec) { + *out = *in + in.NetworkSpec.DeepCopyInto(&out.NetworkSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterSpec. +func (in *AWSClusterSpec) DeepCopy() *AWSClusterSpec { + if in == nil { + return nil + } + out := new(AWSClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSClusterStatus) DeepCopyInto(out *AWSClusterStatus) { + *out = *in + in.Network.DeepCopyInto(&out.Network) + in.Bastion.DeepCopyInto(&out.Bastion) + if in.APIEndpoints != nil { + in, out := &in.APIEndpoints, &out.APIEndpoints + *out = make([]APIEndpoint, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSClusterStatus. +func (in *AWSClusterStatus) DeepCopy() *AWSClusterStatus { + if in == nil { + return nil + } + out := new(AWSClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachine) DeepCopyInto(out *AWSMachine) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachine. +func (in *AWSMachine) DeepCopy() *AWSMachine { + if in == nil { + return nil + } + out := new(AWSMachine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSMachine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineList) DeepCopyInto(out *AWSMachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AWSMachine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineList. +func (in *AWSMachineList) DeepCopy() *AWSMachineList { + if in == nil { + return nil + } + out := new(AWSMachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSMachineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineSpec) DeepCopyInto(out *AWSMachineSpec) { + *out = *in + if in.ProviderID != nil { + in, out := &in.ProviderID, &out.ProviderID + *out = new(string) + **out = **in + } + in.AMI.DeepCopyInto(&out.AMI) + if in.AdditionalTags != nil { + in, out := &in.AdditionalTags, &out.AdditionalTags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.PublicIP != nil { + in, out := &in.PublicIP, &out.PublicIP + *out = new(bool) + **out = **in + } + if in.AdditionalSecurityGroups != nil { + in, out := &in.AdditionalSecurityGroups, &out.AdditionalSecurityGroups + *out = make([]AWSResourceReference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.AvailabilityZone != nil { + in, out := &in.AvailabilityZone, &out.AvailabilityZone + *out = new(string) + **out = **in + } + if in.Subnet != nil { + in, out := &in.Subnet, &out.Subnet + *out = new(AWSResourceReference) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineSpec. +func (in *AWSMachineSpec) DeepCopy() *AWSMachineSpec { + if in == nil { + return nil + } + out := new(AWSMachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineStatus) DeepCopyInto(out *AWSMachineStatus) { + *out = *in + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make([]v1.NodeAddress, len(*in)) + copy(*out, *in) + } + if in.InstanceState != nil { + in, out := &in.InstanceState, &out.InstanceState + *out = new(InstanceState) + **out = **in + } + if in.ErrorReason != nil { + in, out := &in.ErrorReason, &out.ErrorReason + *out = new(errors.MachineStatusError) + **out = **in + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineStatus. +func (in *AWSMachineStatus) DeepCopy() *AWSMachineStatus { + if in == nil { + return nil + } + out := new(AWSMachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineTemplate) DeepCopyInto(out *AWSMachineTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineTemplate. +func (in *AWSMachineTemplate) DeepCopy() *AWSMachineTemplate { + if in == nil { + return nil + } + out := new(AWSMachineTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSMachineTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineTemplateList) DeepCopyInto(out *AWSMachineTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AWSMachineTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineTemplateList. +func (in *AWSMachineTemplateList) DeepCopy() *AWSMachineTemplateList { + if in == nil { + return nil + } + out := new(AWSMachineTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AWSMachineTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineTemplateResource) DeepCopyInto(out *AWSMachineTemplateResource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineTemplateResource. +func (in *AWSMachineTemplateResource) DeepCopy() *AWSMachineTemplateResource { + if in == nil { + return nil + } + out := new(AWSMachineTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSMachineTemplateSpec) DeepCopyInto(out *AWSMachineTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineTemplateSpec. +func (in *AWSMachineTemplateSpec) DeepCopy() *AWSMachineTemplateSpec { + if in == nil { + return nil + } + out := new(AWSMachineTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AWSResourceReference) DeepCopyInto(out *AWSResourceReference) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.ARN != nil { + in, out := &in.ARN, &out.ARN + *out = new(string) + **out = **in + } + if in.Filters != nil { + in, out := &in.Filters, &out.Filters + *out = make([]Filter, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSResourceReference. +func (in *AWSResourceReference) DeepCopy() *AWSResourceReference { + if in == nil { + return nil + } + out := new(AWSResourceReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildParams) DeepCopyInto(out *BuildParams) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.Role != nil { + in, out := &in.Role, &out.Role + *out = new(string) + **out = **in + } + if in.Additional != nil { + in, out := &in.Additional, &out.Additional + *out = make(Tags, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildParams. +func (in *BuildParams) DeepCopy() *BuildParams { + if in == nil { + return nil + } + out := new(BuildParams) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassicELB) DeepCopyInto(out *ClassicELB) { + *out = *in + if in.SubnetIDs != nil { + in, out := &in.SubnetIDs, &out.SubnetIDs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.SecurityGroupIDs != nil { + in, out := &in.SecurityGroupIDs, &out.SecurityGroupIDs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Listeners != nil { + in, out := &in.Listeners, &out.Listeners + *out = make([]*ClassicELBListener, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(ClassicELBListener) + **out = **in + } + } + } + if in.HealthCheck != nil { + in, out := &in.HealthCheck, &out.HealthCheck + *out = new(ClassicELBHealthCheck) + **out = **in + } + out.Attributes = in.Attributes + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassicELB. +func (in *ClassicELB) DeepCopy() *ClassicELB { + if in == nil { + return nil + } + out := new(ClassicELB) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassicELBAttributes) DeepCopyInto(out *ClassicELBAttributes) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassicELBAttributes. +func (in *ClassicELBAttributes) DeepCopy() *ClassicELBAttributes { + if in == nil { + return nil + } + out := new(ClassicELBAttributes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassicELBHealthCheck) DeepCopyInto(out *ClassicELBHealthCheck) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassicELBHealthCheck. +func (in *ClassicELBHealthCheck) DeepCopy() *ClassicELBHealthCheck { + if in == nil { + return nil + } + out := new(ClassicELBHealthCheck) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClassicELBListener) DeepCopyInto(out *ClassicELBListener) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClassicELBListener. +func (in *ClassicELBListener) DeepCopy() *ClassicELBListener { + if in == nil { + return nil + } + out := new(ClassicELBListener) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Filter) DeepCopyInto(out *Filter) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Filter. +func (in *Filter) DeepCopy() *Filter { + if in == nil { + return nil + } + out := new(Filter) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressRule) DeepCopyInto(out *IngressRule) { + *out = *in + if in.CidrBlocks != nil { + in, out := &in.CidrBlocks, &out.CidrBlocks + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.SourceSecurityGroupIDs != nil { + in, out := &in.SourceSecurityGroupIDs, &out.SourceSecurityGroupIDs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressRule. +func (in *IngressRule) DeepCopy() *IngressRule { + if in == nil { + return nil + } + out := new(IngressRule) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in IngressRules) DeepCopyInto(out *IngressRules) { + { + in := &in + *out = make(IngressRules, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(IngressRule) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressRules. +func (in IngressRules) DeepCopy() IngressRules { + if in == nil { + return nil + } + out := new(IngressRules) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Instance) DeepCopyInto(out *Instance) { + *out = *in + if in.KeyName != nil { + in, out := &in.KeyName, &out.KeyName + *out = new(string) + **out = **in + } + if in.SecurityGroupIDs != nil { + in, out := &in.SecurityGroupIDs, &out.SecurityGroupIDs + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.UserData != nil { + in, out := &in.UserData, &out.UserData + *out = new(string) + **out = **in + } + if in.PrivateIP != nil { + in, out := &in.PrivateIP, &out.PrivateIP + *out = new(string) + **out = **in + } + if in.PublicIP != nil { + in, out := &in.PublicIP, &out.PublicIP + *out = new(string) + **out = **in + } + if in.ENASupport != nil { + in, out := &in.ENASupport, &out.ENASupport + *out = new(bool) + **out = **in + } + if in.EBSOptimized != nil { + in, out := &in.EBSOptimized, &out.EBSOptimized + *out = new(bool) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instance. +func (in *Instance) DeepCopy() *Instance { + if in == nil { + return nil + } + out := new(Instance) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Network) DeepCopyInto(out *Network) { + *out = *in + if in.SecurityGroups != nil { + in, out := &in.SecurityGroups, &out.SecurityGroups + *out = make(map[SecurityGroupRole]SecurityGroup, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + in.APIServerELB.DeepCopyInto(&out.APIServerELB) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Network. +func (in *Network) DeepCopy() *Network { + if in == nil { + return nil + } + out := new(Network) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkSpec) DeepCopyInto(out *NetworkSpec) { + *out = *in + in.VPC.DeepCopyInto(&out.VPC) + if in.Subnets != nil { + in, out := &in.Subnets, &out.Subnets + *out = make(Subnets, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(SubnetSpec) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. +func (in *NetworkSpec) DeepCopy() *NetworkSpec { + if in == nil { + return nil + } + out := new(NetworkSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteTable) DeepCopyInto(out *RouteTable) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteTable. +func (in *RouteTable) DeepCopy() *RouteTable { + if in == nil { + return nil + } + out := new(RouteTable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecurityGroup) DeepCopyInto(out *SecurityGroup) { + *out = *in + if in.IngressRules != nil { + in, out := &in.IngressRules, &out.IngressRules + *out = make(IngressRules, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(IngressRule) + (*in).DeepCopyInto(*out) + } + } + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(Tags, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecurityGroup. +func (in *SecurityGroup) DeepCopy() *SecurityGroup { + if in == nil { + return nil + } + out := new(SecurityGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SubnetSpec) DeepCopyInto(out *SubnetSpec) { + *out = *in + if in.RouteTableID != nil { + in, out := &in.RouteTableID, &out.RouteTableID + *out = new(string) + **out = **in + } + if in.NatGatewayID != nil { + in, out := &in.NatGatewayID, &out.NatGatewayID + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(Tags, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubnetSpec. +func (in *SubnetSpec) DeepCopy() *SubnetSpec { + if in == nil { + return nil + } + out := new(SubnetSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Subnets) DeepCopyInto(out *Subnets) { + { + in := &in + *out = make(Subnets, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(SubnetSpec) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subnets. +func (in Subnets) DeepCopy() Subnets { + if in == nil { + return nil + } + out := new(Subnets) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Tags) DeepCopyInto(out *Tags) { + { + in := &in + *out = make(Tags, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tags. +func (in Tags) DeepCopy() Tags { + if in == nil { + return nil + } + out := new(Tags) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VPCSpec) DeepCopyInto(out *VPCSpec) { + *out = *in + if in.InternetGatewayID != nil { + in, out := &in.InternetGatewayID, &out.InternetGatewayID + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(Tags, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCSpec. +func (in *VPCSpec) DeepCopy() *VPCSpec { + if in == nil { + return nil + } + out := new(VPCSpec) + in.DeepCopyInto(out) + return out +} diff --git a/cmd/manager/BUILD.bazel b/cmd/manager/BUILD.bazel deleted file mode 100644 index b4ef37dc32..0000000000 --- a/cmd/manager/BUILD.bazel +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2019 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. - -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") -load("@io_bazel_rules_docker//go:image.bzl", "go_image") -load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") -load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") -load("//build:stateful_set_patch.bzl", "stateful_set_patch") - -go_library( - name = "go_default_library", - srcs = ["main.go"], - importpath = "sigs.k8s.io/cluster-api-provider-aws/cmd/manager", - visibility = ["//visibility:private"], - deps = [ - "//pkg/apis:go_default_library", - "//pkg/controller:go_default_library", - "//pkg/record:go_default_library", - "//vendor/k8s.io/klog:go_default_library", - "//vendor/k8s.io/klog/klogr:go_default_library", - "//vendor/sigs.k8s.io/cluster-api/api/v1alpha2:go_default_library", - "//vendor/sigs.k8s.io/controller-runtime/pkg/client/config:go_default_library", - "//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library", - "//vendor/sigs.k8s.io/controller-runtime/pkg/runtime/log:go_default_library", - "//vendor/sigs.k8s.io/controller-runtime/pkg/runtime/signals:go_default_library", - ], -) - -go_binary( - name = "manager", - embed = [":go_default_library"], - pure = "on", - visibility = ["//visibility:public"], -) - -go_image( - name = "manager-amd64", - embed = [":go_default_library"], - goarch = "amd64", - goos = "linux", - pure = "on", - visibility = ["//visibility:public"], -) - -tags = [ - "{GIT_VERSION}", - "$(MANAGER_IMAGE_TAG)", -] - -images = { - "{registry}/{name}:{tag}".format( - registry = "$(REGISTRY)", - name = "$(MANAGER_IMAGE_NAME)", - tag = tag, - ): ":manager-amd64" - for tag in tags -} - -container_bundle( - name = "manager-image", - images = images, - tags = ["manual"], - visibility = ["//visibility:public"], -) - -docker_push( - name = "manager-push", - bundle = "manager-image", - tags = ["manual"], -) - -stateful_set_patch( - name = "manager-version-patch", - pull_policy = "$(PULL_POLICY)", - registry = "$(REGISTRY)", - tags = ["generated"], - visibility = ["//visibility:public"], -) diff --git a/cmd/manager/main.go b/cmd/manager/main.go deleted file mode 100644 index 9871755fe4..0000000000 --- a/cmd/manager/main.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2018 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 main - -import ( - "flag" - "net/http" - _ "net/http/pprof" - "time" - - "k8s.io/klog" - "k8s.io/klog/klogr" - capa "sigs.k8s.io/cluster-api-provider-aws/pkg/apis" - "sigs.k8s.io/cluster-api-provider-aws/pkg/controller" - "sigs.k8s.io/cluster-api-provider-aws/pkg/record" - capi "sigs.k8s.io/cluster-api/api/v1alpha2" - "sigs.k8s.io/controller-runtime/pkg/client/config" - "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/runtime/log" - "sigs.k8s.io/controller-runtime/pkg/runtime/signals" -) - -func main() { - klog.InitFlags(nil) - flag.Set("logtostderr", "true") - - watchNamespace := flag.String("namespace", "", - "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") - - profilerAddress := flag.String("profiler-address", "", "Bind address to expose the pprof profiler (e.g. localhost:6060)") - - metricsAddress := flag.String("metrics-address", "", "Bind address to expose the metrics (e.g. localhost:8080)") - - flag.Parse() - if *watchNamespace != "" { - klog.Infof("Watching cluster-api objects only in namespace %q for reconciliation", *watchNamespace) - } - - if *profilerAddress != "" { - klog.Infof("Profiler listening for requests at %s", *profilerAddress) - go func() { - klog.Info(http.ListenAndServe(*profilerAddress, nil)) - }() - } - - // Setup a Manager - syncPeriod := 10 * time.Minute - - // Setup controller-runtime logger. - log.SetLogger(klogr.New()) - - // Get a config to talk to the api-server. - cfg := config.GetConfigOrDie() - mgr, err := manager.New(cfg, manager.Options{ - SyncPeriod: &syncPeriod, - Namespace: *watchNamespace, - MetricsBindAddress: *metricsAddress, - }) - if err != nil { - klog.Fatalf("Failed to set up overall controller manager: %v", err) - } - - // Initialize event recorder. - record.InitFromRecorder(mgr.GetEventRecorderFor("aws-controller")) - - if err := capi.AddToScheme(mgr.GetScheme()); err != nil { - klog.Fatal(err) - } - - if err := capa.AddToScheme(mgr.GetScheme()); err != nil { - klog.Fatal(err) - } - - // Setup all Controllers. - if err := controller.AddToManager(mgr); err != nil { - klog.Fatal(err) - } - - if err := mgr.Start(signals.SetupSignalHandler()); err != nil { - klog.Fatalf("Failed to run manager: %v", err) - } -} diff --git a/controllers/BUILD.bazel b/controllers/BUILD.bazel new file mode 100644 index 0000000000..b418df2e51 --- /dev/null +++ b/controllers/BUILD.bazel @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = [ + "awscluster_controller.go", + "awsmachine_controller.go", + ], + importpath = "sigs.k8s.io/cluster-api-provider-aws/controllers", + visibility = ["//visibility:public"], + deps = [ + "//api/v1alpha2:go_default_library", + "//vendor/github.com/go-logr/logr:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["suite_test.go"], + embed = [":go_default_library"], + deps = [ + "//api/v1alpha2:go_default_library", + "//vendor/github.com/onsi/ginkgo:go_default_library", + "//vendor/github.com/onsi/gomega:go_default_library", + "//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library", + "//vendor/k8s.io/client-go/rest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/log:go_default_library", + "//vendor/sigs.k8s.io/controller-runtime/pkg/log/zap:go_default_library", + ], +) diff --git a/controllers/awscluster_controller.go b/controllers/awscluster_controller.go new file mode 100644 index 0000000000..217d8479b9 --- /dev/null +++ b/controllers/awscluster_controller.go @@ -0,0 +1,50 @@ +/* +Copyright 2019 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 controllers + +import ( + "context" + + "github.com/go-logr/logr" + infrastructurev1alpha2 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// AWSClusterReconciler reconciles a AwsCluster object +type AWSClusterReconciler struct { + client.Client + Log logr.Logger +} + +// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters/status,verbs=get;update;patch + +func (r *AWSClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { + _ = context.Background() + _ = r.Log.WithValues("awscluster", req.NamespacedName) + + // your logic here + + return ctrl.Result{}, nil +} + +func (r *AWSClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&infrastructurev1alpha2.AWSCluster{}). + Complete(r) +} diff --git a/controllers/awsmachine_controller.go b/controllers/awsmachine_controller.go new file mode 100644 index 0000000000..8e9efdaf3c --- /dev/null +++ b/controllers/awsmachine_controller.go @@ -0,0 +1,50 @@ +/* +Copyright 2019 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 controllers + +import ( + "context" + + "github.com/go-logr/logr" + infrastructurev1alpha2 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// AWSMachineReconciler reconciles a AwsMachine object +type AWSMachineReconciler struct { + client.Client + Log logr.Logger +} + +// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsmachines,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsmachines/status,verbs=get;update;patch + +func (r *AWSMachineReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { + _ = context.Background() + _ = r.Log.WithValues("awsmachine", req.NamespacedName) + + // your logic here + + return ctrl.Result{}, nil +} + +func (r *AWSMachineReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&infrastructurev1alpha2.AWSMachine{}). + Complete(r) +} diff --git a/controllers/suite_test.go b/controllers/suite_test.go new file mode 100644 index 0000000000..d53b90c1b2 --- /dev/null +++ b/controllers/suite_test.go @@ -0,0 +1,80 @@ +/* +Copyright 2019 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 controllers + +import ( + "path/filepath" + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + infrastructurev1alpha2 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + // +kubebuilder:scaffold:imports +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var cfg *rest.Config +var k8sClient client.Client +var testEnv *envtest.Environment + +func TestAPIs(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecsWithDefaultAndCustomReporters(t, + "Controller Suite", + []Reporter{envtest.NewlineReporter{}}) +} + +var _ = BeforeSuite(func(done Done) { + logf.SetLogger(zap.LoggerTo(GinkgoWriter, true)) + + By("bootstrapping test environment") + testEnv = &envtest.Environment{ + CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + } + + var err error + cfg, err = testEnv.Start() + Expect(err).ToNot(HaveOccurred()) + Expect(cfg).ToNot(BeNil()) + + err = infrastructurev1alpha2.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) + + // +kubebuilder:scaffold:scheme + + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).ToNot(HaveOccurred()) + Expect(k8sClient).ToNot(BeNil()) + + close(done) +}, 60) + +var _ = AfterSuite(func() { + By("tearing down the test environment") + err := testEnv.Stop() + Expect(err).ToNot(HaveOccurred()) +}) diff --git a/go.sum b/go.sum index 42d4e8346f..89e032705b 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,18 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +contrib.go.opencensus.io/exporter/ocagent v0.4.12 h1:jGFvw3l57ViIVEPKKEUXPcLYIXJmQxLUh6ey1eJhwyc= contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA= +github.com/Azure/go-autorest/autorest v0.2.0 h1:zBtSTOQTtjzHVRe+mhkiHvHwRTKHhjBEyo1m6DfI3So= github.com/Azure/go-autorest/autorest v0.2.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg= +github.com/Azure/go-autorest/autorest/adal v0.1.0 h1:RSw/7EAullliqwkZvgIGDYZWQm1PGKXI8c4aY/87yuU= github.com/Azure/go-autorest/autorest/adal v0.1.0/go.mod h1:MeS4XhScH55IST095THyTxElntu7WqB7pNbZo8Q5G3E= +github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.1.0 h1:TRBxC5Pj/fIuh4Qob0ZpkggbfT8RC0SubHbpV3p4/Vc= github.com/Azure/go-autorest/tracing v0.1.0/go.mod h1:ROEEAFwXycQw7Sn3DXNtEedEvdeRAgDr0izn4z5Ij88= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -19,11 +26,13 @@ github.com/awslabs/goformation v0.0.0-20190310235947-776555df5a6d h1:1y3J+mle+xA github.com/awslabs/goformation v0.0.0-20190310235947-776555df5a6d/go.mod h1:HezUyH08DSwwGn3GioVXWZYUhkdvC+oGJ7ya7vBRm7k= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXGM30YZL1WW/M337pXml+GrcZ4= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= @@ -65,9 +74,11 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeq github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.2.0 h1:lD2Bce2xBAMNNcFZ0dObTpXkGLlVIb33RPVUNVpw6ic= github.com/gophercloud/gophercloud v0.2.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/grpc-ecosystem/grpc-gateway v1.8.5 h1:2+KSC78XiO6Qy0hIjfc1OD9H+hsaJdJlb8Kqsd41CTE= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/golang-lru v0.0.0-20180201235237-0fb14efe8c47/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -166,6 +177,7 @@ github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c/go.mod h1: github.com/xeipuuv/gojsonschema v0.0.0-20181112162635-ac52e6811b56 h1:yhqBHs09SmmUoNOHc9jgK4a60T3XFRtPAkYxVnqgY50= github.com/xeipuuv/gojsonschema v0.0.0-20181112162635-ac52e6811b56/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2 h1:NAfh7zF0/3/HqtMvJNZ/RFrSlCE6ZTlHmKfhL/Dm1Jk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -204,6 +216,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170814044513-c84c1ab9fd18/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -234,14 +247,17 @@ golang.org/x/tools v0.0.0-20190501045030-23463209683d h1:D7DVZUZEUgsSIDTivnUtVeG golang.org/x/tools v0.0.0-20190501045030-23463209683d/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= gomodules.xyz/jsonpatch/v2 v2.0.0 h1:lHNQverf0+Gm1TbSbVIDWVXOhZ2FpZopxRqpr2uIjs4= gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= +google.golang.org/api v0.3.1 h1:oJra/lMfmtm13/rgY/8i3MzjFWYXvQIAKjQ3HqofMk8= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.19.1 h1:TrBcJ1yqAl1G++wO39nD/qtgpsW9/1+QGrluyMGEYgM= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go new file mode 100644 index 0000000000..f27f9ff0f7 --- /dev/null +++ b/main.go @@ -0,0 +1,114 @@ +/* +Copyright 2018 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 main + +import ( + "flag" + "net/http" + "os" + "time" + + _ "net/http/pprof" + + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + "k8s.io/klog" + "k8s.io/klog/klogr" + infrastructurev1alpha2 "sigs.k8s.io/cluster-api-provider-aws/api/v1alpha2" + "sigs.k8s.io/cluster-api-provider-aws/controllers" + "sigs.k8s.io/cluster-api-provider-aws/pkg/record" + ctrl "sigs.k8s.io/controller-runtime" + // +kubebuilder:scaffold:imports +) + +var ( + scheme = runtime.NewScheme() + setupLog = ctrl.Log.WithName("setup") +) + +func init() { + _ = clientgoscheme.AddToScheme(scheme) + _ = infrastructurev1alpha2.AddToScheme(scheme) + // +kubebuilder:scaffold:scheme +} + +func main() { + klog.InitFlags(nil) + + var metricsAddr string + var enableLeaderElection bool + + flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") + flag.BoolVar(&enableLeaderElection, "enable-leader-election", false, + "Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.") + watchNamespace := flag.String("namespace", "", + "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") + profilerAddress := flag.String("profiler-address", "", "Bind address to expose the pprof profiler (e.g. localhost:6060)") + flag.Parse() + + if *watchNamespace != "" { + setupLog.Info("Watching cluster-api objects only in namespace for reconciliation", "namespace", *watchNamespace) + } + + if *profilerAddress != "" { + setupLog.Info("Profiler listening for requests", "profiler-address", *profilerAddress) + go func() { + setupLog.Error(http.ListenAndServe(*profilerAddress, nil), "listen and serve error") + }() + } + + syncPeriod := 10 * time.Minute + + ctrl.SetLogger(klogr.New()) + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ + Scheme: scheme, + MetricsBindAddress: metricsAddr, + LeaderElection: enableLeaderElection, + SyncPeriod: &syncPeriod, + Namespace: *watchNamespace, + }) + if err != nil { + setupLog.Error(err, "unable to start manager") + os.Exit(1) + } + + // Initialize event recorder. + record.InitFromRecorder(mgr.GetEventRecorderFor("aws-controller")) + + if err = (&controllers.AWSMachineReconciler{ + Client: mgr.GetClient(), + Log: ctrl.Log.WithName("controllers").WithName("AWSMachine"), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "AWSMachine") + os.Exit(1) + } + if err = (&controllers.AWSClusterReconciler{ + Client: mgr.GetClient(), + Log: ctrl.Log.WithName("controllers").WithName("AWSCluster"), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "AWSCluster") + os.Exit(1) + } + // +kubebuilder:scaffold:builder + + setupLog.Info("starting manager") + if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { + setupLog.Error(err, "problem running manager") + os.Exit(1) + } +}