gardener / gardener-extension-provider-aws

Gardener extension controller for the AWS cloud provider (https://aws.amazon.com).
https://gardener.cloud
Apache License 2.0
18 stars 96 forks source link

Update example CRDs to `apiextensions.k8s.io/v1` #430

Closed timebertt closed 2 years ago

timebertt commented 2 years ago

How to categorize this issue?

/area dev-productivity /kind enhancement /platform aws

What would you like to be added:

Update CRDs under example to apiextensions.k8s.io/v1, e.g. https://github.com/gardener/gardener-extension-provider-aws/blob/51d2a020b218c16d4dbc1f0a197c9a83bae9f48e/example/20-crd-backupbucket.yaml#L2-L3

Why is this needed:

With k8s v1.22, apiextensions.k8s.io/v1beta1 is no longer served: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#customresourcedefinition-v122 We should update the example CRDs to allow developers to easily test against a v1.22 cluster.

E.g. I hit the following when testing a PR:

$ k3d cluster create k3d
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-k3d' (9d237569e4ccdd5a65cd35d28166bd7d153fad77d29e41343996fceba1b00a08)
INFO[0000] Created volume 'k3d-k3d-images'
INFO[0001] Creating node 'k3d-k3d-server-0'
INFO[0001] Creating LoadBalancer 'k3d-k3d-serverlb'
INFO[0001] Starting cluster 'k3d'
INFO[0001] Starting servers...
INFO[0001] Starting Node 'k3d-k3d-server-0'
INFO[0009] Starting agents...
INFO[0009] Starting helpers...
INFO[0009] Starting Node 'k3d-k3d-serverlb'
INFO[0010] (Optional) Trying to get IP of the docker host and inject it into the cluster as 'host.k3d.internal' for easy access
INFO[0012] Successfully added host record to /etc/hosts in 2/2 nodes and to the CoreDNS ConfigMap
INFO[0012] Cluster 'k3d' created successfully!
INFO[0012] --kubeconfig-update-default=false --> sets --kubeconfig-switch-context=false
INFO[0012] You can now use it like this:
kubectl config use-context k3d-k3d
kubectl cluster-info

$ k version
...
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2+k3s2", GitCommit:"3f5774b41eb475eb10c93bb0ce58459a6f777c5f", GitTreeState:"clean", BuildDate:"2021-10-05T20:29:33Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}

$ ls example/20-crd-* | xargs -I {} kubectl apply -f {}
error: unable to recognize "example/20-crd-backupbucket.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
error: unable to recognize "example/20-crd-backupentry.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
error: unable to recognize "example/20-crd-bastion.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
error: unable to recognize "example/20-crd-cluster.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
error: unable to recognize "example/20-crd-controlplane.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
...
timebertt commented 2 years ago

I propose to generate the example CRDs from the API types using controller-gen on make generate similar to make generate-extensions-crds in g/g: https://github.com/gardener/gardener/blob/00859f107d55ca009f9f889f2c10993245f5411c/Makefile#L222-L225

timebertt commented 2 years ago

Once we vendor a new g/g version including https://github.com/gardener/gardener/pull/4854, this repo can simply auto-generate all CRDs under example, except the VPA CRD. I'm not sure if that one is actually needed or could simply be removed.

timebertt commented 2 years ago

/unassign for now, as @BeckerMax plans to revendor g/g in this extension. With that, https://github.com/gardener/gardener/pull/4854 can be reused to fix this issue.