-
Notifications
You must be signed in to change notification settings - Fork 303
Description
Description of the bug:
When using cdk8s import
, if there are multiple versions of the CRD like v1alpha1
& v1beta1
, cdk8s uses v1alpha1 for main class name. Because of this, a lot of users are unknowingly using the v1alpha1 resource besides there is a newer version available.
Reproduction Steps:
In this example,
cdk8s generates 2 different versions for ExternalSecret
CRD. However v1alpha1
becomes the main class.
export class ExternalSecret extends ApiObject {
/**
* Returns the apiVersion and kind for "ExternalSecret"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'external-secrets.io/v1alpha1',
kind: 'ExternalSecret',
}
}
...
export class ExternalSecretV1Beta1 extends ApiObject {
/**
* Returns the apiVersion and kind for "ExternalSecretV1Beta1"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'external-secrets.io/v1beta1',
kind: 'ExternalSecret',
}
}
Or in this example, cdk8s generates
export class HttpRoute extends ApiObject {
/**
* Returns the apiVersion and kind for "HTTPRoute"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'gateway.networking.k8s.io/v1',
kind: 'HTTPRoute',
}
}
...
export class HttpRouteV1Beta1 extends ApiObject {
/**
* Returns the apiVersion and kind for "HTTPRouteV1Beta1"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'gateway.networking.k8s.io/v1beta1',
kind: 'HTTPRoute',
}
}
In this case v1 class is the main class, much better.
There are other cases where it gets inconsistent. For example, when there are v1
and v2
CRDs, v1
becomes the main class and v2
gets prefix like Somethingv2
. However if there are v2
and v3
CRDs, v2
CRD becomes main class with no prefix.
export class Host extends ApiObject {
/**
* Returns the apiVersion and kind for "Host"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'getambassador.io/v2',
kind: 'Host',
}
}
...
export class HostV3Alpha1 extends ApiObject {
/**
* Returns the apiVersion and kind for "HostV3Alpha1"
*/
public static readonly GVK: GroupVersionKind = {
apiVersion: 'getambassador.io/v3alpha1',
kind: 'Host',
}
}
Error Log:
Environment:
- Framework Version:
"cdk8s-cli": "2.198.105", "cdk8s": "^2.68.69",
- OS:
Other:
Perhaps cdk8s can follow Terraform k8s provider's approach to version everything and remove unversioned class names.
This is 🐛 Bug Report