From 0bf9d3cd406f23c61b5ba1f66c9b8c30cc7f46cf Mon Sep 17 00:00:00 2001 From: Rahul Ganesh <31204974+rahulbabu95@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:15:45 -0800 Subject: [PATCH] Copy over CAPT APIs to local package (#9114) * Copy over CAPT apis to local package Signed-off-by: Rahul Ganesh --- .../controlplaneupgrade_controller_test.go | 2 +- go.mod | 1 - go.sum | 2 - .../internal/auth/smithy/v4signer_adapter.go | 3 +- .../internal/endpoints/v2/endpoints.go | 3 +- internal/test/e2e/packages.go | 4 +- internal/test/envtest/config/capt-crds.yaml | 734 ++++++++++++++++++ internal/test/envtest/environment.go | 7 +- manager/main.go | 2 +- .../thirdparty/tinkerbell/capt/v1beta1/doc.go | 18 + .../capt/v1beta1/groupversion_info.go | 37 + .../capt/v1beta1/tinkerbellcluster_types.go | 110 +++ .../capt/v1beta1/tinkerbellcluster_webhook.go | 74 ++ .../capt/v1beta1/tinkerbellmachine_types.go | 211 +++++ .../capt/v1beta1/tinkerbellmachine_webhook.go | 82 ++ .../v1beta1/tinkerbellmachine_webhook_test.go | 137 ++++ .../tinkerbellmachinetemplate_types.go | 52 ++ .../tinkerbellmachinetemplate_webhook.go | 70 ++ .../tinkerbell/capt/v1beta1/types.go | 35 + .../tinkerbell/capt/v1beta1/webhooks.go | 35 + .../capt/v1beta1/zz_generated.deepcopy.go | 397 ++++++++++ pkg/clients/kubernetes/scheme.go | 2 +- pkg/providers/nutanix/template.go | 3 +- pkg/providers/tinkerbell/assert.go | 2 +- pkg/providers/tinkerbell/assert_test.go | 6 +- pkg/providers/tinkerbell/controlplane.go | 2 +- pkg/providers/tinkerbell/controlplane_test.go | 3 +- pkg/providers/tinkerbell/machinetemplate.go | 2 +- .../tinkerbell/reconciler/reconciler.go | 2 +- .../tinkerbell/reconciler/reconciler_test.go | 5 +- pkg/providers/tinkerbell/workers.go | 2 +- pkg/providers/tinkerbell/workers_test.go | 3 +- release/cli/pkg/assets/archives/archives.go | 2 +- release/cli/pkg/assets/assets.go | 2 +- release/cli/pkg/bundles/bundles.go | 2 +- 35 files changed, 2022 insertions(+), 32 deletions(-) create mode 100644 internal/test/envtest/config/capt-crds.yaml create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/doc.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/groupversion_info.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_types.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_webhook.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_types.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook_test.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_types.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_webhook.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/types.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/webhooks.go create mode 100644 pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/zz_generated.deepcopy.go diff --git a/controllers/controlplaneupgrade_controller_test.go b/controllers/controlplaneupgrade_controller_test.go index c377fcce7ab7..d330b64d4798 100644 --- a/controllers/controlplaneupgrade_controller_test.go +++ b/controllers/controlplaneupgrade_controller_test.go @@ -9,7 +9,6 @@ import ( "github.com/golang/mock/gomock" . "github.com/onsi/gomega" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -25,6 +24,7 @@ import ( "github.com/aws/eks-anywhere/controllers" "github.com/aws/eks-anywhere/controllers/mocks" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/constants" ) diff --git a/go.mod b/go.mod index 914f19af3414..3ad5c6df2abb 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,6 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 - github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288 github.com/tinkerbell/tink v0.8.0 github.com/vmware/govmomi v0.37.2 go.uber.org/zap v1.26.0 diff --git a/go.sum b/go.sum index a2bd5f0ae70e..888f5cc4c6fb 100644 --- a/go.sum +++ b/go.sum @@ -862,8 +862,6 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288 h1:HkBPnM4/DdLKJvcUNsFePYuTAFOHPMSzr3DvH7ZKBds= -github.com/tinkerbell/cluster-api-provider-tinkerbell v0.1.1-0.20220615214617-9e9c2a397288/go.mod h1:IjRbGnQtoplJEW5UgKHsCp1WukkAyjhIdDBsxjYq2dM= github.com/tinkerbell/tink v0.8.0 h1:qgl/rglpO5Rvq6UKZd29O6X9mDgZZYgf841+Y0IYWak= github.com/tinkerbell/tink v0.8.0/go.mod h1:bfAkSH7J/QQYIyqZRR6IQp8w78aac6l8Z2Lws5uXz6A= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/internal/aws-sdk-go-v2/internal/auth/smithy/v4signer_adapter.go b/internal/aws-sdk-go-v2/internal/auth/smithy/v4signer_adapter.go index 833f619e2333..179f23a433bc 100644 --- a/internal/aws-sdk-go-v2/internal/auth/smithy/v4signer_adapter.go +++ b/internal/aws-sdk-go-v2/internal/auth/smithy/v4signer_adapter.go @@ -5,11 +5,12 @@ import ( "fmt" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "github.com/aws/eks-anywhere/internal/aws-sdk-go-v2/internal/sdk" "github.com/aws/smithy-go" "github.com/aws/smithy-go/auth" "github.com/aws/smithy-go/logging" smithyhttp "github.com/aws/smithy-go/transport/http" + + "github.com/aws/eks-anywhere/internal/aws-sdk-go-v2/internal/sdk" ) // V4SignerAdapter adapts v4.HTTPSigner to smithy http.Signer. diff --git a/internal/aws-sdk-go-v2/internal/endpoints/v2/endpoints.go b/internal/aws-sdk-go-v2/internal/endpoints/v2/endpoints.go index 68f4b5737911..46ff1b451576 100644 --- a/internal/aws-sdk-go-v2/internal/endpoints/v2/endpoints.go +++ b/internal/aws-sdk-go-v2/internal/endpoints/v2/endpoints.go @@ -5,9 +5,8 @@ import ( "regexp" "strings" - "github.com/aws/smithy-go/logging" - "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/smithy-go/logging" ) // DefaultKey is a compound map key of a variant and other values. diff --git a/internal/test/e2e/packages.go b/internal/test/e2e/packages.go index cd6cf7a2c184..39e3217cf8b3 100644 --- a/internal/test/e2e/packages.go +++ b/internal/test/e2e/packages.go @@ -8,9 +8,9 @@ import ( ) const ( - packagesRegex = `^.*CuratedPackages.*$` + packagesRegex = `^.*CuratedPackages.*$` nonRegionalPackagesRegex = `^.*NonRegionalCuratedPackages.*$` - certManagerRegex = "^.*CuratedPackagesCertManager.*$" + certManagerRegex = "^.*CuratedPackagesCertManager.*$" ) func (e *E2ESession) setupPackagesEnv(testRegex string) error { diff --git a/internal/test/envtest/config/capt-crds.yaml b/internal/test/envtest/config/capt-crds.yaml new file mode 100644 index 000000000000..eda5b53cac67 --- /dev/null +++ b/internal/test/envtest/config/capt-crds.yaml @@ -0,0 +1,734 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: capt-system/capt-serving-cert + controller-gen.kubebuilder.io/version: v0.16.2 + labels: + cluster.x-k8s.io/provider: infrastructure-tinkerbell + cluster.x-k8s.io/v1beta1: v1beta1 + name: tinkerbellclusters.infrastructure.cluster.x-k8s.io +spec: + group: infrastructure.cluster.x-k8s.io + names: + categories: + - cluster-api + kind: TinkerbellCluster + listKind: TinkerbellClusterList + plural: tinkerbellclusters + singular: tinkerbellcluster + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Cluster to which this TinkerbellCluster belongs + jsonPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name + name: Cluster + type: string + - description: TinkerbellCluster ready status + jsonPath: .status.ready + name: Ready + type: string + name: v1beta1 + schema: + openAPIV3Schema: + description: TinkerbellCluster is the Schema for the tinkerbellclusters API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: TinkerbellClusterSpec defines the desired state of TinkerbellCluster. + properties: + controlPlaneEndpoint: + description: |- + ControlPlaneEndpoint is a required field by ClusterAPI v1beta1. + + See https://cluster-api.sigs.k8s.io/developer/architecture/controllers/cluster.html + for more details. + properties: + host: + description: The hostname on which the API server is serving. + type: string + port: + description: The port on which the API server is serving. + format: int32 + type: integer + required: + - host + - port + type: object + imageLookupBaseRegistry: + default: ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + description: |- + ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, + if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. + type: string + imageLookupFormat: + description: |- + ImageLookupFormat is the URL naming format to use for machine images when + a machine does not specify. When set, this will be used for all cluster machines + unless a machine specifies a different ImageLookupFormat. Supports substitutions + for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with + the basse URL, OS distribution, OS version, and kubernetes version, respectively. + BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), + OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro + (if known), and the kubernetes version as defined by the packages produced by + kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default + image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will + attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ + type: string + imageLookupOSDistro: + default: ubuntu + description: |- + ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, + if not set it will default to ubuntu. + type: string + imageLookupOSVersion: + description: |- + ImageLookupOSVersion is the version of the OS distribution to use when fetching machine + images. If not set it will default based on ImageLookupOSDistro. + type: string + type: object + status: + description: TinkerbellClusterStatus defines the observed state of TinkerbellCluster. + properties: + ready: + description: Ready denotes that the cluster (infrastructure) is ready. + type: boolean + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: capt-system/capt-serving-cert + controller-gen.kubebuilder.io/version: v0.16.2 + labels: + cluster.x-k8s.io/provider: infrastructure-tinkerbell + cluster.x-k8s.io/v1beta1: v1beta1 + name: tinkerbellmachines.infrastructure.cluster.x-k8s.io +spec: + group: infrastructure.cluster.x-k8s.io + names: + categories: + - cluster-api + kind: TinkerbellMachine + listKind: TinkerbellMachineList + plural: tinkerbellmachines + singular: tinkerbellmachine + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Cluster to which this TinkerbellMachine belongs + jsonPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name + name: Cluster + type: string + - description: Tinkerbell instance state + jsonPath: .status.instanceState + name: State + type: string + - description: Machine ready status + jsonPath: .status.ready + name: Ready + type: string + - description: Tinkerbell instance ID + jsonPath: .spec.providerID + name: InstanceID + type: string + - description: Machine object which owns with this TinkerbellMachine + jsonPath: .metadata.ownerReferences[?(@.kind=="Machine")].name + name: Machine + type: string + name: v1beta1 + schema: + openAPIV3Schema: + description: TinkerbellMachine is the Schema for the tinkerbellmachines API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: TinkerbellMachineSpec defines the desired state of TinkerbellMachine. + properties: + bootOptions: + description: BootOptions are options that control the booting of Hardware. + properties: + bootMode: + description: |- + BootMode is the type of booting that will be done. + Must be one of "none", "netboot", or "iso". + enum: + - none + - netboot + - iso + type: string + isoURL: + description: |- + ISOURL is the URL of the ISO that will be one-time booted. + When this field is set, the controller will create a job.bmc.tinkerbell.org object + for getting the associated hardware into a CDROM booting state. + A HardwareRef that contains a spec.BmcRef must be provided. + + The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso + The name of the ISO file must have the .iso extension, but the name can be anything. + The $IP and $Port should generally point to the IP and Port of the Smee server + as this is where the ISO patching endpoint lives. + The ":macAddress" is a placeholder for the MAC address of the hardware and + should be provided exactly as is: ":macAddress". + format: url + type: string + type: object + hardwareAffinity: + description: HardwareAffinity allows filtering for hardware. + properties: + preferred: + description: |- + Preferred are the preferred hardware affinity terms. Hardware matching these terms are preferred according to the + weights provided, but are not required. + items: + description: |- + WeightedHardwareAffinityTerm is a HardwareAffinityTerm with an associated weight. The weights of all the matched + WeightedHardwareAffinityTerm fields are added per-hardware to find the most preferred hardware. + properties: + hardwareAffinityTerm: + description: HardwareAffinityTerm is the term associated + with the corresponding weight. + properties: + labelSelector: + description: LabelSelector is used to select for particular + hardware by label. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - labelSelector + type: object + weight: + description: Weight associated with matching the corresponding + hardwareAffinityTerm, in the range 1-100. + format: int32 + maximum: 100 + minimum: 1 + type: integer + required: + - hardwareAffinityTerm + - weight + type: object + type: array + required: + description: |- + Required are the required hardware affinity terms. The terms are OR'd together, hardware must match one term to + be considered. + items: + description: HardwareAffinityTerm is used to select for a particular + existing hardware resource. + properties: + labelSelector: + description: LabelSelector is used to select for particular + hardware by label. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - labelSelector + type: object + type: array + type: object + hardwareName: + description: |- + Those fields are set programmatically, but they cannot be re-constructed from "state of the world", so + we put them in spec instead of status. + type: string + imageLookupBaseRegistry: + description: |- + ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, + if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. + type: string + imageLookupFormat: + description: |- + ImageLookupFormat is the URL naming format to use for machine images when + a machine does not specify. When set, this will be used for all cluster machines + unless a machine specifies a different ImageLookupFormat. Supports substitutions + for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with + the basse URL, OS distribution, OS version, and kubernetes version, respectively. + BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), + OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro + (if known), and the kubernetes version as defined by the packages produced by + kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default + image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will + attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ + type: string + imageLookupOSDistro: + description: |- + ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, + if not set it will default to ubuntu. + type: string + imageLookupOSVersion: + description: |- + ImageLookupOSVersion is the version of the OS distribution to use when fetching machine + images. If not set it will default based on ImageLookupOSDistro. + type: string + providerID: + type: string + templateOverride: + description: |- + TemplateOverride overrides the default Tinkerbell template used by CAPT. + You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/ + type: string + type: object + status: + description: TinkerbellMachineStatus defines the observed state of TinkerbellMachine. + properties: + addresses: + description: Addresses contains the Tinkerbell device associated addresses. + items: + description: NodeAddress contains information for the node's address. + properties: + address: + description: The node address. + type: string + type: + description: Node address type, one of Hostname, ExternalIP + or InternalIP. + type: string + required: + - address + - type + type: object + type: array + errorMessage: + description: |- + 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. + type: string + errorReason: + description: |- + 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. + type: string + instanceStatus: + description: InstanceStatus is the status of the Tinkerbell device + instance for this machine. + type: integer + ready: + description: Ready is true when the provider resource is ready. + type: boolean + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: capt-system/capt-serving-cert + controller-gen.kubebuilder.io/version: v0.16.2 + labels: + cluster.x-k8s.io/provider: infrastructure-tinkerbell + cluster.x-k8s.io/v1beta1: v1beta1 + name: tinkerbellmachinetemplates.infrastructure.cluster.x-k8s.io +spec: + group: infrastructure.cluster.x-k8s.io + names: + categories: + - cluster-api + kind: TinkerbellMachineTemplate + listKind: TinkerbellMachineTemplateList + plural: tinkerbellmachinetemplates + singular: tinkerbellmachinetemplate + scope: Namespaced + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: TinkerbellMachineTemplate is the Schema for the tinkerbellmachinetemplates + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: TinkerbellMachineTemplateSpec defines the desired state of + TinkerbellMachineTemplate. + properties: + template: + description: TinkerbellMachineTemplateResource describes the data + needed to create am TinkerbellMachine from a template. + properties: + spec: + description: Spec is the specification of the desired behavior + of the machine. + properties: + bootOptions: + description: BootOptions are options that control the booting + of Hardware. + properties: + bootMode: + description: |- + BootMode is the type of booting that will be done. + Must be one of "none", "netboot", or "iso". + enum: + - none + - netboot + - iso + type: string + isoURL: + description: |- + ISOURL is the URL of the ISO that will be one-time booted. + When this field is set, the controller will create a job.bmc.tinkerbell.org object + for getting the associated hardware into a CDROM booting state. + A HardwareRef that contains a spec.BmcRef must be provided. + + The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso + The name of the ISO file must have the .iso extension, but the name can be anything. + The $IP and $Port should generally point to the IP and Port of the Smee server + as this is where the ISO patching endpoint lives. + The ":macAddress" is a placeholder for the MAC address of the hardware and + should be provided exactly as is: ":macAddress". + format: url + type: string + type: object + hardwareAffinity: + description: HardwareAffinity allows filtering for hardware. + properties: + preferred: + description: |- + Preferred are the preferred hardware affinity terms. Hardware matching these terms are preferred according to the + weights provided, but are not required. + items: + description: |- + WeightedHardwareAffinityTerm is a HardwareAffinityTerm with an associated weight. The weights of all the matched + WeightedHardwareAffinityTerm fields are added per-hardware to find the most preferred hardware. + properties: + hardwareAffinityTerm: + description: HardwareAffinityTerm is the term associated + with the corresponding weight. + properties: + labelSelector: + description: LabelSelector is used to select + for particular hardware by label. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - labelSelector + type: object + weight: + description: Weight associated with matching the + corresponding hardwareAffinityTerm, in the range + 1-100. + format: int32 + maximum: 100 + minimum: 1 + type: integer + required: + - hardwareAffinityTerm + - weight + type: object + type: array + required: + description: |- + Required are the required hardware affinity terms. The terms are OR'd together, hardware must match one term to + be considered. + items: + description: HardwareAffinityTerm is used to select + for a particular existing hardware resource. + properties: + labelSelector: + description: LabelSelector is used to select for + particular hardware by label. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + required: + - labelSelector + type: object + type: array + type: object + hardwareName: + description: |- + Those fields are set programmatically, but they cannot be re-constructed from "state of the world", so + we put them in spec instead of status. + type: string + imageLookupBaseRegistry: + description: |- + ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, + if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. + type: string + imageLookupFormat: + description: |- + ImageLookupFormat is the URL naming format to use for machine images when + a machine does not specify. When set, this will be used for all cluster machines + unless a machine specifies a different ImageLookupFormat. Supports substitutions + for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with + the basse URL, OS distribution, OS version, and kubernetes version, respectively. + BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), + OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro + (if known), and the kubernetes version as defined by the packages produced by + kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default + image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will + attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ + type: string + imageLookupOSDistro: + description: |- + ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, + if not set it will default to ubuntu. + type: string + imageLookupOSVersion: + description: |- + ImageLookupOSVersion is the version of the OS distribution to use when fetching machine + images. If not set it will default based on ImageLookupOSDistro. + type: string + providerID: + type: string + templateOverride: + description: |- + TemplateOverride overrides the default Tinkerbell template used by CAPT. + You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/ + type: string + type: object + required: + - spec + type: object + required: + - template + type: object + type: object + served: true + storage: true +--- \ No newline at end of file diff --git a/internal/test/envtest/environment.go b/internal/test/envtest/environment.go index e5fa94054623..f372ba85bc9c 100644 --- a/internal/test/envtest/environment.go +++ b/internal/test/envtest/environment.go @@ -14,7 +14,6 @@ import ( eksdv1alpha1 "github.com/aws/eks-distro-build-tooling/release/api/v1alpha1" etcdv1 "github.com/aws/etcdadm-controller/api/v1beta1" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" tinkv1alpha1 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1" admissionv1beta1 "k8s.io/api/admission/v1beta1" corev1 "k8s.io/api/core/v1" @@ -39,6 +38,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio" snowv1 "github.com/aws/eks-anywhere/pkg/providers/snow/api/v1beta1" releasev1 "github.com/aws/eks-anywhere/release/api/v1alpha1" @@ -48,7 +48,6 @@ const ( capiPackage = "sigs.k8s.io/cluster-api" capdPackage = "sigs.k8s.io/cluster-api/test" capvPackage = "sigs.k8s.io/cluster-api-provider-vsphere" - captPackage = "github.com/tinkerbell/cluster-api-provider-tinkerbell" tinkerbellPackage = "github.com/tinkerbell/tink" etcdProviderPackage = "github.com/aws/etcdadm-controller" capcPackage = "sigs.k8s.io/cluster-api-provider-cloudstack" @@ -83,9 +82,6 @@ var packages = []moduleWithCRD{ withAdditionalCustomCRDPath("bootstrap/kubeadm/config/crd/bases"), withAdditionalCustomCRDPath("controlplane/kubeadm/config/crd/bases"), ), - mustBuildModuleWithCRDs(captPackage, - withMainCustomCRDPath("config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellclusters.yaml"), - withAdditionalCustomCRDPath("config/crd/bases/infrastructure.cluster.x-k8s.io_tinkerbellmachinetemplates.yaml")), mustBuildModuleWithCRDs(tinkerbellPackage), mustBuildModuleWithCRDs(capvPackage, withMainCustomCRDPath("config/default/crd/bases"), @@ -153,6 +149,7 @@ func newEnvironment(ctx context.Context) (*Environment, error) { filepath.Join(currentDir, "config", "eks-d-crds.yaml"), filepath.Join(currentDir, "config", "snow-crds.yaml"), filepath.Join(currentDir, "config", "rufio-crds.yaml"), + filepath.Join(currentDir, "config", "capt-crds.yaml"), filepath.Join(root, "internal", "thirdparty", "capc", "config", "crd", "bases"), ) extraCRDPaths, err := getPathsToPackagesCRDs(root, packages...) diff --git a/manager/main.go b/manager/main.go index 1a76fd6c17ef..2a83bc8a4286 100644 --- a/manager/main.go +++ b/manager/main.go @@ -10,7 +10,6 @@ import ( "github.com/go-logr/logr" nutanixv1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1" "github.com/spf13/pflag" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" tinkv1alpha1 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -34,6 +33,7 @@ import ( "github.com/aws/eks-anywhere/controllers" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/controller/clientutil" diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/doc.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/doc.go new file mode 100644 index 000000000000..a02b65385140 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/doc.go @@ -0,0 +1,18 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 contains API Schema definitions for the infrastructure v1beta1 API group. +package v1beta1 diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/groupversion_info.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/groupversion_info.go new file mode 100644 index 000000000000..6068ef13c655 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/groupversion_info.go @@ -0,0 +1,37 @@ +/* +Copyright 2022 The Tinkerbell 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. +*/ + +// +kubebuilder:object:generate=true +// +groupName=infrastructure.cluster.x-k8s.io + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +//nolint:gochecknoglobals +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta1"} + + // 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/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_types.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_types.go new file mode 100644 index 000000000000..4a4ac92716e8 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_types.go @@ -0,0 +1,110 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +const ( + // ClusterFinalizer allows ReconcileTinkerbellCluster to clean up Tinkerbell resources before + // removing it from the apiserver. + ClusterFinalizer = "tinkerbellcluster.infrastructure.cluster.x-k8s.io" +) + +// TinkerbellClusterSpec defines the desired state of TinkerbellCluster. +type TinkerbellClusterSpec struct { + // ControlPlaneEndpoint is a required field by ClusterAPI v1beta1. + // + // See https://cluster-api.sigs.k8s.io/developer/architecture/controllers/cluster.html + // for more details. + // + // +optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty"` + + // ImageLookupFormat is the URL naming format to use for machine images when + // a machine does not specify. When set, this will be used for all cluster machines + // unless a machine specifies a different ImageLookupFormat. Supports substitutions + // for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with + // the basse URL, OS distribution, OS version, and kubernetes version, respectively. + // BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + // (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), + // OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro + // (if known), and the kubernetes version as defined by the packages produced by + // kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default + // image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will + // attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ + // +optional + ImageLookupFormat string `json:"imageLookupFormat,omitempty"` + + // ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, + // if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. + // +optional + // +kubebuilder:default=ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + ImageLookupBaseRegistry string `json:"imageLookupBaseRegistry,omitempty"` + + // ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, + // if not set it will default to ubuntu. + // +optional + // +kubebuilder:default=ubuntu + ImageLookupOSDistro string `json:"imageLookupOSDistro,omitempty"` + + // ImageLookupOSVersion is the version of the OS distribution to use when fetching machine + // images. If not set it will default based on ImageLookupOSDistro. + // +optional + ImageLookupOSVersion string `json:"imageLookupOSVersion,omitempty"` +} + +// TinkerbellClusterStatus defines the observed state of TinkerbellCluster. +type TinkerbellClusterStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file. + + // Ready denotes that the cluster (infrastructure) is ready. + // +optional + Ready bool `json:"ready"` +} + +// +kubebuilder:subresource:status +// +kubebuilder:resource:path=tinkerbellclusters,scope=Namespaced,categories=cluster-api +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this TinkerbellCluster belongs" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="TinkerbellCluster ready status" + +// TinkerbellCluster is the Schema for the tinkerbellclusters API. +type TinkerbellCluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TinkerbellClusterSpec `json:"spec,omitempty"` + Status TinkerbellClusterStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// TinkerbellClusterList contains a list of TinkerbellCluster. +type TinkerbellClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []TinkerbellCluster `json:"items"` +} + +//nolint:gochecknoinits +func init() { + SchemeBuilder.Register(&TinkerbellCluster{}, &TinkerbellClusterList{}) +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_webhook.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_webhook.go new file mode 100644 index 000000000000..cd43631f2cd2 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellcluster_webhook.go @@ -0,0 +1,74 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + "strings" + + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +const ( + osUbuntu = "ubuntu" + defaultUbuntuVersion = "20.04" +) + +var _ admission.Validator = &TinkerbellCluster{} + +// SetupWebhookWithManager sets up and registers the webhook with the manager. +func (c *TinkerbellCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr).For(c).Complete() //nolint:wrapcheck +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellcluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellclusters,versions=v1beta1,name=validation.tinkerbellcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellcluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellclusters,versions=v1beta1,name=default.tinkerbellcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *TinkerbellCluster) ValidateCreate() (admission.Warnings, error) { + return nil, nil +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *TinkerbellCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *TinkerbellCluster) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func defaultVersionForOSDistro(distro string) string { + if strings.ToLower(distro) == osUbuntu { + return defaultUbuntuVersion + } + + return "" +} + +// Default implements webhookutil.defaulter so a webhook will be registered for the type. +func (c *TinkerbellCluster) Default() { + if c.Spec.ImageLookupFormat == "" { + c.Spec.ImageLookupFormat = "{{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz" + } + + if c.Spec.ImageLookupOSVersion == "" { + c.Spec.ImageLookupOSVersion = defaultVersionForOSDistro(c.Spec.ImageLookupOSDistro) + } +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_types.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_types.go new file mode 100644 index 000000000000..256f54971b6b --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_types.go @@ -0,0 +1,211 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + capierrors "sigs.k8s.io/cluster-api/errors" +) + +const ( + // MachineFinalizer allows ReconcileTinkerbellMachine to clean up Tinkerbell resources before + // removing it from the apiserver. + MachineFinalizer = "tinkerbellmachine.infrastructure.cluster.x-k8s.io" +) + +// BootMode defines the type of booting that will be done. i.e. netboot, iso, etc. +type BootMode string + +// TinkerbellMachineSpec defines the desired state of TinkerbellMachine. +type TinkerbellMachineSpec struct { + // ImageLookupFormat is the URL naming format to use for machine images when + // a machine does not specify. When set, this will be used for all cluster machines + // unless a machine specifies a different ImageLookupFormat. Supports substitutions + // for {{.BaseRegistry}}, {{.OSDistro}}, {{.OSVersion}} and {{.KubernetesVersion}} with + // the basse URL, OS distribution, OS version, and kubernetes version, respectively. + // BaseRegistry will be the value in ImageLookupBaseRegistry or ghcr.io/tinkerbell/cluster-api-provider-tinkerbell + // (the default), OSDistro will be the value in ImageLookupOSDistro or ubuntu (the default), + // OSVersion will be the value in ImageLookupOSVersion or default based on the OSDistro + // (if known), and the kubernetes version as defined by the packages produced by + // kubernetes/release: v1.13.0, v1.12.5-mybuild.1, or v1.17.3. For example, the default + // image format of {{.BaseRegistry}}/{{.OSDistro}}-{{.OSVersion}}:{{.KubernetesVersion}}.gz will + // attempt to pull the image from that location. See also: https://golang.org/pkg/text/template/ + // +optional + ImageLookupFormat string `json:"imageLookupFormat,omitempty"` + + // ImageLookupBaseRegistry is the base Registry URL that is used for pulling images, + // if not set, the default will be to use ghcr.io/tinkerbell/cluster-api-provider-tinkerbell. + // +optional + ImageLookupBaseRegistry string `json:"imageLookupBaseRegistry,omitempty"` + + // ImageLookupOSDistro is the name of the OS distro to use when fetching machine images, + // if not set it will default to ubuntu. + // +optional + ImageLookupOSDistro string `json:"imageLookupOSDistro,omitempty"` + + // ImageLookupOSVersion is the version of the OS distribution to use when fetching machine + // images. If not set it will default based on ImageLookupOSDistro. + // +optional + ImageLookupOSVersion string `json:"imageLookupOSVersion,omitempty"` + + // TemplateOverride overrides the default Tinkerbell template used by CAPT. + // You can learn more about Tinkerbell templates here: https://tinkerbell.org/docs/concepts/templates/ + // +optional + TemplateOverride string `json:"templateOverride,omitempty"` + + // HardwareAffinity allows filtering for hardware. + // +optional + HardwareAffinity *HardwareAffinity `json:"hardwareAffinity,omitempty"` + + // BootOptions are options that control the booting of Hardware. + // +optional + BootOptions BootOptions `json:"bootOptions,omitempty"` + + // Those fields are set programmatically, but they cannot be re-constructed from "state of the world", so + // we put them in spec instead of status. + HardwareName string `json:"hardwareName,omitempty"` + ProviderID string `json:"providerID,omitempty"` +} + +// BootOptions are options that control the booting of Hardware. +type BootOptions struct { + // ISOURL is the URL of the ISO that will be one-time booted. + // When this field is set, the controller will create a job.bmc.tinkerbell.org object + // for getting the associated hardware into a CDROM booting state. + // A HardwareRef that contains a spec.BmcRef must be provided. + // + // The format of the ISOURL must be http://$IP:$Port/iso/:macAddress/hook.iso + // The name of the ISO file must have the .iso extension, but the name can be anything. + // The $IP and $Port should generally point to the IP and Port of the Smee server + // as this is where the ISO patching endpoint lives. + // The ":macAddress" is a placeholder for the MAC address of the hardware and + // should be provided exactly as is: ":macAddress". + // +optional + // +kubebuilder:validation:Format=url + ISOURL string `json:"isoURL,omitempty"` + + // BootMode is the type of booting that will be done. + // Must be one of "none", "netboot", or "iso". + // +optional + // +kubebuilder:validation:Enum=none;netboot;iso + BootMode BootMode `json:"bootMode,omitempty"` +} + +// HardwareAffinity defines the required and preferred hardware affinities. +type HardwareAffinity struct { + // Required are the required hardware affinity terms. The terms are OR'd together, hardware must match one term to + // be considered. + // +optional + Required []HardwareAffinityTerm `json:"required,omitempty"` + // Preferred are the preferred hardware affinity terms. Hardware matching these terms are preferred according to the + // weights provided, but are not required. + // +optional + Preferred []WeightedHardwareAffinityTerm `json:"preferred,omitempty"` +} + +// HardwareAffinityTerm is used to select for a particular existing hardware resource. +type HardwareAffinityTerm struct { + // LabelSelector is used to select for particular hardware by label. + LabelSelector metav1.LabelSelector `json:"labelSelector"` +} + +// WeightedHardwareAffinityTerm is a HardwareAffinityTerm with an associated weight. The weights of all the matched +// WeightedHardwareAffinityTerm fields are added per-hardware to find the most preferred hardware. +type WeightedHardwareAffinityTerm struct { + // Weight associated with matching the corresponding hardwareAffinityTerm, in the range 1-100. + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=100 + Weight int32 `json:"weight"` + // HardwareAffinityTerm is the term associated with the corresponding weight. + HardwareAffinityTerm HardwareAffinityTerm `json:"hardwareAffinityTerm"` +} + +// TinkerbellMachineStatus defines the observed state of TinkerbellMachine. +type TinkerbellMachineStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Ready is true when the provider resource is ready. + // +optional + Ready bool `json:"ready"` + + // Addresses contains the Tinkerbell device associated addresses. + Addresses []corev1.NodeAddress `json:"addresses,omitempty"` + + // InstanceStatus is the status of the Tinkerbell device instance for this machine. + // +optional + InstanceStatus *TinkerbellResourceStatus `json:"instanceStatus,omitempty"` + + // 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 *capierrors.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:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=tinkerbellmachines,scope=Namespaced,categories=cluster-api +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this TinkerbellMachine belongs" +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.instanceState",description="Tinkerbell instance state" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status" +// +kubebuilder:printcolumn:name="InstanceID",type="string",JSONPath=".spec.providerID",description="Tinkerbell instance ID" +// +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this TinkerbellMachine" + +// TinkerbellMachine is the Schema for the tinkerbellmachines API. +type TinkerbellMachine struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TinkerbellMachineSpec `json:"spec,omitempty"` + Status TinkerbellMachineStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// TinkerbellMachineList contains a list of TinkerbellMachine. +type TinkerbellMachineList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []TinkerbellMachine `json:"items"` +} + +//nolint:gochecknoinits +func init() { + SchemeBuilder.Register(&TinkerbellMachine{}, &TinkerbellMachineList{}) +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook.go new file mode 100644 index 000000000000..3d490c534ec6 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook.go @@ -0,0 +1,82 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +var _ admission.Validator = &TinkerbellMachine{} + +// SetupWebhookWithManager sets up and registers the webhook with the manager. +func (m *TinkerbellMachine) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr).For(m).Complete() //nolint:wrapcheck +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellmachine,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellmachines,versions=v1beta1,name=validation.tinkerbellmachine.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachine) ValidateCreate() (admission.Warnings, error) { + allErrs := m.validateSpec() + + return nil, aggregateObjErrors(m.GroupVersionKind().GroupKind(), m.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachine) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { + allErrs := m.validateSpec() + + old, _ := oldRaw.(*TinkerbellMachine) + + if old.Spec.HardwareName != "" && m.Spec.HardwareName != old.Spec.HardwareName { + allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "hardwareName"), "is immutable once set")) + } + + if old.Spec.ProviderID != "" && m.Spec.ProviderID != old.Spec.ProviderID { + allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "providerID"), "is immutable once set")) + } + + return nil, aggregateObjErrors(m.GroupVersionKind().GroupKind(), m.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachine) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (m *TinkerbellMachine) validateSpec() field.ErrorList { + var allErrs field.ErrorList + + fieldBasePath := field.NewPath("spec") + + // TODO: there are probably more fields that have requirements + + if spec := m.Spec; spec.HardwareAffinity != nil { + for i, term := range spec.HardwareAffinity.Preferred { + if term.Weight < 1 || term.Weight > 100 { + allErrs = append(allErrs, + field.Invalid(fieldBasePath.Child("HardwareAffinity", "Preferred").Index(i), + term.Weight, "must be in the range [1,100]")) + } + } + } + + return allErrs +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook_test.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook_test.go new file mode 100644 index 000000000000..acae9521446a --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachine_webhook_test.go @@ -0,0 +1,137 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1_test + +import ( + "testing" + + . "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" +) + +func Test_valid_tinkerbell_machine(t *testing.T) { + t.Parallel() + g := NewWithT(t) + existingValidMachine := &v1beta1.TinkerbellMachine{} + + for _, machine := range []v1beta1.TinkerbellMachine{ + // preferred affinity weight ranges + { + Spec: v1beta1.TinkerbellMachineSpec{ + HardwareAffinity: &v1beta1.HardwareAffinity{ + Preferred: []v1beta1.WeightedHardwareAffinityTerm{ + { + Weight: 1, + HardwareAffinityTerm: v1beta1.HardwareAffinityTerm{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + }, + }, + }, + }, + }, + { + Spec: v1beta1.TinkerbellMachineSpec{ + HardwareAffinity: &v1beta1.HardwareAffinity{ + Preferred: []v1beta1.WeightedHardwareAffinityTerm{ + { + Weight: 50, + HardwareAffinityTerm: v1beta1.HardwareAffinityTerm{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + }, + }, + }, + }, + }, + { + Spec: v1beta1.TinkerbellMachineSpec{ + HardwareAffinity: &v1beta1.HardwareAffinity{ + Preferred: []v1beta1.WeightedHardwareAffinityTerm{ + { + Weight: 100, + HardwareAffinityTerm: v1beta1.HardwareAffinityTerm{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + }, + }, + }, + }, + }, + } { + _, err := machine.ValidateCreate() + g.Expect(err).ToNot(HaveOccurred()) + _, err = machine.ValidateUpdate(existingValidMachine) + g.Expect(err).ToNot(HaveOccurred()) + } +} + +func Test_invalid_tinkerbell_machine(t *testing.T) { + t.Parallel() + g := NewWithT(t) + + existingValidMachine := &v1beta1.TinkerbellMachine{} + + for _, machine := range []v1beta1.TinkerbellMachine{ + // invalid preferred affinity weight values + { + Spec: v1beta1.TinkerbellMachineSpec{ + HardwareAffinity: &v1beta1.HardwareAffinity{ + Preferred: []v1beta1.WeightedHardwareAffinityTerm{ + { + Weight: -1, + HardwareAffinityTerm: v1beta1.HardwareAffinityTerm{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + }, + }, + }, + }, + }, + { + Spec: v1beta1.TinkerbellMachineSpec{ + HardwareAffinity: &v1beta1.HardwareAffinity{ + Preferred: []v1beta1.WeightedHardwareAffinityTerm{ + { + Weight: 101, + HardwareAffinityTerm: v1beta1.HardwareAffinityTerm{ + LabelSelector: metav1.LabelSelector{ + MatchLabels: map[string]string{"foo": "bar"}, + }, + }, + }, + }, + }, + }, + }, + } { + _, err := machine.ValidateCreate() + g.Expect(err).To(HaveOccurred()) + _, err = machine.ValidateUpdate(existingValidMachine) + g.Expect(err).To(HaveOccurred()) + } +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_types.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_types.go new file mode 100644 index 000000000000..b455d94291fe --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_types.go @@ -0,0 +1,52 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// TinkerbellMachineTemplateSpec defines the desired state of TinkerbellMachineTemplate. +type TinkerbellMachineTemplateSpec struct { + Template TinkerbellMachineTemplateResource `json:"template"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=tinkerbellmachinetemplates,scope=Namespaced,categories=cluster-api +// +kubebuilder:storageversion + +// TinkerbellMachineTemplate is the Schema for the tinkerbellmachinetemplates API. +type TinkerbellMachineTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TinkerbellMachineTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// TinkerbellMachineTemplateList contains a list of TinkerbellMachineTemplate. +type TinkerbellMachineTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []TinkerbellMachineTemplate `json:"items"` +} + +//nolint:gochecknoinits +func init() { + SchemeBuilder.Register(&TinkerbellMachineTemplate{}, &TinkerbellMachineTemplateList{}) +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_webhook.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_webhook.go new file mode 100644 index 000000000000..80d7e2e6b3b0 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/tinkerbellmachinetemplate_webhook.go @@ -0,0 +1,70 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + "reflect" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +var _ admission.Validator = &TinkerbellMachineTemplate{} + +// SetupWebhookWithManager sets up and registers the webhook with the manager. +func (m *TinkerbellMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr).For(m).Complete() //nolint:wrapcheck +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-tinkerbellmachinetemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=tinkerbellmachinetemplates,versions=v1beta1,name=validation.tinkerbellmachinetemplate.infrastructure.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachineTemplate) ValidateCreate() (admission.Warnings, error) { + var allErrs field.ErrorList + + spec := m.Spec.Template.Spec + fieldBasePath := field.NewPath("spec", "template", "spec") + + if spec.ProviderID != "" { + allErrs = append(allErrs, field.Forbidden(fieldBasePath.Child("providerID"), "cannot be set in templates")) + } + + if spec.HardwareName != "" { + allErrs = append(allErrs, field.Forbidden(fieldBasePath.Child("hardwareName"), "cannot be set in templates")) + } + + return nil, aggregateObjErrors(m.GroupVersionKind().GroupKind(), m.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachineTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + oldTinkerbellMachineTemplate, _ := old.(*TinkerbellMachineTemplate) + + if !reflect.DeepEqual(m.Spec, oldTinkerbellMachineTemplate.Spec) { + return nil, apierrors.NewBadRequest("TinkerbellMachineTemplate.Spec is immutable") + } + + return nil, nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (m *TinkerbellMachineTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/types.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/types.go new file mode 100644 index 000000000000..95525575db3f --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/types.go @@ -0,0 +1,35 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +// TinkerbellResourceStatus describes the status of a Tinkerbell resource. +type TinkerbellResourceStatus int + +//nolint:gomnd,gochecknoglobals +var ( + TinkerbellResourceStatusPending = TinkerbellResourceStatus(0) + TinkerbellResourceStatusRunning = TinkerbellResourceStatus(1) + TinkerbellResourceStatusFailed = TinkerbellResourceStatus(2) + TinkerbellResourceStatusTimeout = TinkerbellResourceStatus(3) + TinkerbellResourceStatusSuccess = TinkerbellResourceStatus(4) +) + +// TinkerbellMachineTemplateResource describes the data needed to create am TinkerbellMachine from a template. +type TinkerbellMachineTemplateResource struct { + // Spec is the specification of the desired behavior of the machine. + Spec TinkerbellMachineSpec `json:"spec"` +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/webhooks.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/webhooks.go new file mode 100644 index 000000000000..fd6c36faa097 --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/webhooks.go @@ -0,0 +1,35 @@ +/* +Copyright 2022 The Tinkerbell 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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +func aggregateObjErrors(gk schema.GroupKind, name string, allErrs field.ErrorList) error { + if len(allErrs) == 0 { + return nil + } + + return apierrors.NewInvalid( + gk, + name, + allErrs, + ) +} diff --git a/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 000000000000..c3b3b30064fc --- /dev/null +++ b/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,397 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +// +// 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. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/cluster-api/errors" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BootOptions) DeepCopyInto(out *BootOptions) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootOptions. +func (in *BootOptions) DeepCopy() *BootOptions { + if in == nil { + return nil + } + out := new(BootOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HardwareAffinity) DeepCopyInto(out *HardwareAffinity) { + *out = *in + if in.Required != nil { + in, out := &in.Required, &out.Required + *out = make([]HardwareAffinityTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Preferred != nil { + in, out := &in.Preferred, &out.Preferred + *out = make([]WeightedHardwareAffinityTerm, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HardwareAffinity. +func (in *HardwareAffinity) DeepCopy() *HardwareAffinity { + if in == nil { + return nil + } + out := new(HardwareAffinity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HardwareAffinityTerm) DeepCopyInto(out *HardwareAffinityTerm) { + *out = *in + in.LabelSelector.DeepCopyInto(&out.LabelSelector) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HardwareAffinityTerm. +func (in *HardwareAffinityTerm) DeepCopy() *HardwareAffinityTerm { + if in == nil { + return nil + } + out := new(HardwareAffinityTerm) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellCluster) DeepCopyInto(out *TinkerbellCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellCluster. +func (in *TinkerbellCluster) DeepCopy() *TinkerbellCluster { + if in == nil { + return nil + } + out := new(TinkerbellCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellCluster) 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 *TinkerbellClusterList) DeepCopyInto(out *TinkerbellClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TinkerbellCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellClusterList. +func (in *TinkerbellClusterList) DeepCopy() *TinkerbellClusterList { + if in == nil { + return nil + } + out := new(TinkerbellClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellClusterList) 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 *TinkerbellClusterSpec) DeepCopyInto(out *TinkerbellClusterSpec) { + *out = *in + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellClusterSpec. +func (in *TinkerbellClusterSpec) DeepCopy() *TinkerbellClusterSpec { + if in == nil { + return nil + } + out := new(TinkerbellClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellClusterStatus) DeepCopyInto(out *TinkerbellClusterStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellClusterStatus. +func (in *TinkerbellClusterStatus) DeepCopy() *TinkerbellClusterStatus { + if in == nil { + return nil + } + out := new(TinkerbellClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellMachine) DeepCopyInto(out *TinkerbellMachine) { + *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 TinkerbellMachine. +func (in *TinkerbellMachine) DeepCopy() *TinkerbellMachine { + if in == nil { + return nil + } + out := new(TinkerbellMachine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellMachine) 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 *TinkerbellMachineList) DeepCopyInto(out *TinkerbellMachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TinkerbellMachine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellMachineList. +func (in *TinkerbellMachineList) DeepCopy() *TinkerbellMachineList { + if in == nil { + return nil + } + out := new(TinkerbellMachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellMachineList) 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 *TinkerbellMachineSpec) DeepCopyInto(out *TinkerbellMachineSpec) { + *out = *in + if in.HardwareAffinity != nil { + in, out := &in.HardwareAffinity, &out.HardwareAffinity + *out = new(HardwareAffinity) + (*in).DeepCopyInto(*out) + } + out.BootOptions = in.BootOptions +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellMachineSpec. +func (in *TinkerbellMachineSpec) DeepCopy() *TinkerbellMachineSpec { + if in == nil { + return nil + } + out := new(TinkerbellMachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellMachineStatus) DeepCopyInto(out *TinkerbellMachineStatus) { + *out = *in + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make([]v1.NodeAddress, len(*in)) + copy(*out, *in) + } + if in.InstanceStatus != nil { + in, out := &in.InstanceStatus, &out.InstanceStatus + *out = new(TinkerbellResourceStatus) + **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 TinkerbellMachineStatus. +func (in *TinkerbellMachineStatus) DeepCopy() *TinkerbellMachineStatus { + if in == nil { + return nil + } + out := new(TinkerbellMachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellMachineTemplate) DeepCopyInto(out *TinkerbellMachineTemplate) { + *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 TinkerbellMachineTemplate. +func (in *TinkerbellMachineTemplate) DeepCopy() *TinkerbellMachineTemplate { + if in == nil { + return nil + } + out := new(TinkerbellMachineTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellMachineTemplate) 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 *TinkerbellMachineTemplateList) DeepCopyInto(out *TinkerbellMachineTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TinkerbellMachineTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellMachineTemplateList. +func (in *TinkerbellMachineTemplateList) DeepCopy() *TinkerbellMachineTemplateList { + if in == nil { + return nil + } + out := new(TinkerbellMachineTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TinkerbellMachineTemplateList) 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 *TinkerbellMachineTemplateResource) DeepCopyInto(out *TinkerbellMachineTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellMachineTemplateResource. +func (in *TinkerbellMachineTemplateResource) DeepCopy() *TinkerbellMachineTemplateResource { + if in == nil { + return nil + } + out := new(TinkerbellMachineTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TinkerbellMachineTemplateSpec) DeepCopyInto(out *TinkerbellMachineTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TinkerbellMachineTemplateSpec. +func (in *TinkerbellMachineTemplateSpec) DeepCopy() *TinkerbellMachineTemplateSpec { + if in == nil { + return nil + } + out := new(TinkerbellMachineTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WeightedHardwareAffinityTerm) DeepCopyInto(out *WeightedHardwareAffinityTerm) { + *out = *in + in.HardwareAffinityTerm.DeepCopyInto(&out.HardwareAffinityTerm) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WeightedHardwareAffinityTerm. +func (in *WeightedHardwareAffinityTerm) DeepCopy() *WeightedHardwareAffinityTerm { + if in == nil { + return nil + } + out := new(WeightedHardwareAffinityTerm) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/clients/kubernetes/scheme.go b/pkg/clients/kubernetes/scheme.go index 32423d8a5386..3c150bcc83a1 100644 --- a/pkg/clients/kubernetes/scheme.go +++ b/pkg/clients/kubernetes/scheme.go @@ -3,7 +3,6 @@ package kubernetes import ( eksdv1alpha1 "github.com/aws/eks-distro-build-tooling/release/api/v1alpha1" etcdv1 "github.com/aws/etcdadm-controller/api/v1beta1" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" cloudstackv1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3" @@ -15,6 +14,7 @@ import ( dockerv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" snowv1 "github.com/aws/eks-anywhere/pkg/providers/snow/api/v1beta1" releasev1 "github.com/aws/eks-anywhere/release/api/v1alpha1" ) diff --git a/pkg/providers/nutanix/template.go b/pkg/providers/nutanix/template.go index 240b8472f952..7d2287f033f7 100644 --- a/pkg/providers/nutanix/template.go +++ b/pkg/providers/nutanix/template.go @@ -7,10 +7,9 @@ import ( "net" "strings" - "sigs.k8s.io/yaml" - capxv1beta1 "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/api/v1beta1" "github.com/nutanix-cloud-native/prism-go-client/environment/credentials" + "sigs.k8s.io/yaml" "github.com/aws/eks-anywhere/pkg/api/v1alpha1" "github.com/aws/eks-anywhere/pkg/cluster" diff --git a/pkg/providers/tinkerbell/assert.go b/pkg/providers/tinkerbell/assert.go index 454548228f8f..4dd4ba48b9bc 100644 --- a/pkg/providers/tinkerbell/assert.go +++ b/pkg/providers/tinkerbell/assert.go @@ -5,10 +5,10 @@ import ( "fmt" "net/http" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/networkutils" "github.com/aws/eks-anywhere/pkg/providers/tinkerbell/hardware" diff --git a/pkg/providers/tinkerbell/assert_test.go b/pkg/providers/tinkerbell/assert_test.go index 1fd9b092b3ab..c78fa18c2158 100644 --- a/pkg/providers/tinkerbell/assert_test.go +++ b/pkg/providers/tinkerbell/assert_test.go @@ -9,7 +9,6 @@ import ( "github.com/golang/mock/gomock" "github.com/onsi/gomega" - "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -18,6 +17,7 @@ import ( "github.com/aws/eks-anywhere/internal/test" eksav1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/networkutils/mocks" "github.com/aws/eks-anywhere/pkg/providers/tinkerbell" @@ -1189,8 +1189,8 @@ func validatableTinkerbellCAPI() *tinkerbell.ValidatableTinkerbellCAPI { } } -func workerGroups() []*clusterapi.WorkerGroup[*v1beta1.TinkerbellMachineTemplate] { - return []*clusterapi.WorkerGroup[*v1beta1.TinkerbellMachineTemplate]{ +func workerGroups() []*clusterapi.WorkerGroup[*tinkerbellv1.TinkerbellMachineTemplate] { + return []*clusterapi.WorkerGroup[*tinkerbellv1.TinkerbellMachineTemplate]{ { MachineDeployment: machineDeployment(func(md *clusterv1.MachineDeployment) { md.Name = "cluster-worker-node-group-0" diff --git a/pkg/providers/tinkerbell/controlplane.go b/pkg/providers/tinkerbell/controlplane.go index f44a8ff23701..9e4bbd093e7f 100644 --- a/pkg/providers/tinkerbell/controlplane.go +++ b/pkg/providers/tinkerbell/controlplane.go @@ -5,9 +5,9 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" corev1 "k8s.io/api/core/v1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clients/kubernetes" "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" diff --git a/pkg/providers/tinkerbell/controlplane_test.go b/pkg/providers/tinkerbell/controlplane_test.go index b79de6e8e5f2..eb74d98ac689 100644 --- a/pkg/providers/tinkerbell/controlplane_test.go +++ b/pkg/providers/tinkerbell/controlplane_test.go @@ -5,7 +5,6 @@ import ( "testing" . "github.com/onsi/gomega" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -15,6 +14,7 @@ import ( "github.com/aws/eks-anywhere/internal/test" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clients/kubernetes" "github.com/aws/eks-anywhere/pkg/constants" ) @@ -1035,6 +1035,7 @@ func tinkerbellMachineTemplate(name string) *tinkerbellv1.TinkerbellMachineTempl Spec: tinkerbellv1.TinkerbellMachineTemplateSpec{ Template: tinkerbellv1.TinkerbellMachineTemplateResource{ Spec: tinkerbellv1.TinkerbellMachineSpec{ + BootOptions: tinkerbellv1.BootOptions{BootMode: tinkerbellv1.BootMode("netboot")}, TemplateOverride: testTemplateOverride, HardwareAffinity: &tinkerbellv1.HardwareAffinity{ Required: []tinkerbellv1.HardwareAffinityTerm{ diff --git a/pkg/providers/tinkerbell/machinetemplate.go b/pkg/providers/tinkerbell/machinetemplate.go index 1664eabcfcde..47161e1430b3 100644 --- a/pkg/providers/tinkerbell/machinetemplate.go +++ b/pkg/providers/tinkerbell/machinetemplate.go @@ -4,9 +4,9 @@ import ( "context" "github.com/pkg/errors" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" "k8s.io/apimachinery/pkg/api/equality" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clients/kubernetes" ) diff --git a/pkg/providers/tinkerbell/reconciler/reconciler.go b/pkg/providers/tinkerbell/reconciler/reconciler.go index 8670979f6c28..0146e2e17669 100644 --- a/pkg/providers/tinkerbell/reconciler/reconciler.go +++ b/pkg/providers/tinkerbell/reconciler/reconciler.go @@ -7,13 +7,13 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio" c "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" diff --git a/pkg/providers/tinkerbell/reconciler/reconciler_test.go b/pkg/providers/tinkerbell/reconciler/reconciler_test.go index 648d990ff7b9..4e5f3931561e 100644 --- a/pkg/providers/tinkerbell/reconciler/reconciler_test.go +++ b/pkg/providers/tinkerbell/reconciler/reconciler_test.go @@ -9,7 +9,6 @@ import ( "github.com/golang/mock/gomock" . "github.com/onsi/gomega" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" tinkv1alpha1 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -24,6 +23,7 @@ import ( "github.com/aws/eks-anywhere/internal/test" "github.com/aws/eks-anywhere/internal/test/envtest" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" rufiov1alpha1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/rufio" clusterspec "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" @@ -1154,6 +1154,7 @@ func controlPlaneMachineTemplate() *tinkerbellv1.TinkerbellMachineTemplate { Spec: tinkerbellv1.TinkerbellMachineTemplateSpec{ Template: tinkerbellv1.TinkerbellMachineTemplateResource{ Spec: tinkerbellv1.TinkerbellMachineSpec{ + BootOptions: tinkerbellv1.BootOptions{BootMode: tinkerbellv1.BootMode("netboot")}, HardwareAffinity: &tinkerbellv1.HardwareAffinity{ Required: []tinkerbellv1.HardwareAffinityTerm{ { @@ -1619,6 +1620,7 @@ rules: Spec: tinkerbellv1.TinkerbellMachineTemplateSpec{ Template: tinkerbellv1.TinkerbellMachineTemplateResource{ Spec: tinkerbellv1.TinkerbellMachineSpec{ + BootOptions: tinkerbellv1.BootOptions{BootMode: tinkerbellv1.BootMode("netboot")}, TemplateOverride: testTemplateOverride, HardwareAffinity: &tinkerbellv1.HardwareAffinity{ Required: []tinkerbellv1.HardwareAffinityTerm{ @@ -1759,6 +1761,7 @@ func tinkWorker(clusterName string, opts ...workerOpt) *tinkerbell.Workers { }, Spec: tinkerbellv1.TinkerbellMachineTemplateSpec{ Template: tinkerbellv1.TinkerbellMachineTemplateResource{Spec: tinkerbellv1.TinkerbellMachineSpec{ + BootOptions: tinkerbellv1.BootOptions{BootMode: tinkerbellv1.BootMode("netboot")}, TemplateOverride: testTemplateOverride, HardwareAffinity: &tinkerbellv1.HardwareAffinity{ Required: []tinkerbellv1.HardwareAffinityTerm{ diff --git a/pkg/providers/tinkerbell/workers.go b/pkg/providers/tinkerbell/workers.go index f3d5686f67ba..adde5fa4b0ca 100644 --- a/pkg/providers/tinkerbell/workers.go +++ b/pkg/providers/tinkerbell/workers.go @@ -5,8 +5,8 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clients/kubernetes" "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/clusterapi" diff --git a/pkg/providers/tinkerbell/workers_test.go b/pkg/providers/tinkerbell/workers_test.go index 74319e342764..4a187f02bd50 100644 --- a/pkg/providers/tinkerbell/workers_test.go +++ b/pkg/providers/tinkerbell/workers_test.go @@ -6,7 +6,6 @@ import ( "time" . "github.com/onsi/gomega" - tinkerbellv1 "github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -15,6 +14,7 @@ import ( "github.com/aws/eks-anywhere/internal/test" anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1" + tinkerbellv1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1/thirdparty/tinkerbell/capt/v1beta1" "github.com/aws/eks-anywhere/pkg/clusterapi" "github.com/aws/eks-anywhere/pkg/providers/tinkerbell" "github.com/aws/eks-anywhere/pkg/utils/ptr" @@ -500,6 +500,7 @@ func machineTemplate(opts ...func(*tinkerbellv1.TinkerbellMachineTemplate)) *tin Spec: tinkerbellv1.TinkerbellMachineTemplateSpec{ Template: tinkerbellv1.TinkerbellMachineTemplateResource{ Spec: tinkerbellv1.TinkerbellMachineSpec{ + BootOptions: tinkerbellv1.BootOptions{BootMode: tinkerbellv1.BootMode("netboot")}, TemplateOverride: testTemplateOverride, HardwareAffinity: &tinkerbellv1.HardwareAffinity{ Required: []tinkerbellv1.HardwareAffinityTerm{ diff --git a/release/cli/pkg/assets/archives/archives.go b/release/cli/pkg/assets/archives/archives.go index f0e92cda792e..3597de7d66cb 100644 --- a/release/cli/pkg/assets/archives/archives.go +++ b/release/cli/pkg/assets/archives/archives.go @@ -17,9 +17,9 @@ package archives import ( "fmt" "path/filepath" - "slices" "github.com/pkg/errors" + "slices" assettypes "github.com/aws/eks-anywhere/release/cli/pkg/assets/types" "github.com/aws/eks-anywhere/release/cli/pkg/filereader" diff --git a/release/cli/pkg/assets/assets.go b/release/cli/pkg/assets/assets.go index c8fee066b612..3d60ad4ffe84 100644 --- a/release/cli/pkg/assets/assets.go +++ b/release/cli/pkg/assets/assets.go @@ -18,11 +18,11 @@ import ( "context" "fmt" "path/filepath" - "slices" "strconv" "github.com/pkg/errors" "golang.org/x/sync/errgroup" + "slices" "github.com/aws/eks-anywhere/release/cli/pkg/assets/archives" assetconfig "github.com/aws/eks-anywhere/release/cli/pkg/assets/config" diff --git a/release/cli/pkg/bundles/bundles.go b/release/cli/pkg/bundles/bundles.go index ed025394bbe7..13a4050c4be3 100644 --- a/release/cli/pkg/bundles/bundles.go +++ b/release/cli/pkg/bundles/bundles.go @@ -16,12 +16,12 @@ package bundles import ( "fmt" - "slices" "strconv" "strings" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "slices" anywherev1alpha1 "github.com/aws/eks-anywhere/release/api/v1alpha1" "github.com/aws/eks-anywhere/release/cli/pkg/constants"