Update CRDs from v1beta1
OpenShift 4.9 and Kubernetes 1.22 will drop support for CRD v1beta1 from the API entirely. You must convert your CRD's to v1 to continue uninterrupted support for your operator in versions 4.9 and onward. Please refer to this blog post which also covers API deprecation and required actions.
If your operator was removed from OpenShift v4.9 please also reference this blog post for additional actions that may be required.
The operator-sdk uses CustomResourceDefinition v1 by default for all automatically generated CRD's. However, v1beta1 CRD's were required for operator certification as recently as Q2 CY21 and are being deprecated as per the above warning. Thus, if your operator was certified prior to this timeframe and you haven't yet switched, then you should do so as soon as possible to so that your operator will be listed in OpenShift 4.9.
Edit each of your CRs as follows:
1
$ vi config/crd/bases/<your CRD filename>
Copied!
Here's a sample CRD shown before and after conversion. The apiVersion is changed to v1, and the schema is now defined per CR version (in v1beta1, you could only define per-version schemas if they were different).
Before:
my-crd.yaml
1
---
2
#change the apiVersion
3
apiVersion: apiextensions.k8s.io/v1beta1
4
kind: CustomResourceDefinition
5
metadata:
6
name: mongodbs.database.dhoover103.com
7
spec:
8
group: database.dhoover103.com
9
names:
10
kind: MongoDB
11
listKind: MongoDBList
12
plural: mongodbs
13
singular: mongodb
14
scope: Namespaced
15
versions:
16
- name: v1alpha1
17
served: true
18
storage: true
19
# Pull out the per-verison schema and define it globally instead
20
# Note that the "schema" line changes to "validation"
21
# Make sure the new section lines up correctly - one less indent (2 fewer spaces)
22
validation:
23
openAPIV3Schema:
24
description: MongoDB is the Schema for the mongodbs API
25
properties:
26
apiVersion:
27
description: 'APIVersion defines the versioned schema of this representation
28
of an object. Servers should convert recognized schemas to the latest
29
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
30
type: string
31
kind:
32
description: 'Kind is a string value representing the REST resource this
33
object represents. Servers may infer this from the endpoint the client
34
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
35
type: string
36
metadata:
37
type: object
38
spec:
39
description: Spec defines the desired state of MongoDB
40
type: object
41
x-kubernetes-preserve-unknown-fields: true
42
status:
43
description: Status defines the observed state of MongoDB
44
type: object
45
x-kubernetes-preserve-unknown-fields: true
46
type: object
47
# The subresources stay where they are
48
subresources:
49
status: {}
50
# Add a "version" section. This must match the name of your first listed version
51
version: v1alpha1
52
Copied!
After:
my-crd.yaml
1
---
2
apiVersion: apiextensions.k8s.io/v1
3
kind: CustomResourceDefinition
4
metadata:
5
name: mongodbs.database.dhoover103.com
6
spec:
7
group: database.dhoover103.com
8
names:
9
kind: MongoDB
10
listKind: MongoDBList
11
plural: mongodbs
12
singular: mongodb
13
scope: Namespaced
14
versions:
15
- name: v1alpha1
16
schema:
17
openAPIV3Schema:
18
description: MongoDB is the Schema for the mongodbs API
19
properties:
20
apiVersion:
21
description: 'APIVersion defines the versioned schema of this representation
22
of an object. Servers should convert recognized schemas to the latest
23
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24
type: string
25
kind:
26
description: 'Kind is a string value representing the REST resource this
27
object represents. Servers may infer this from the endpoint the client
28
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
29
type: string
30
metadata:
31
type: object
32
spec:
33
description: Spec defines the desired state of MongoDB
34
type: object
35
x-kubernetes-preserve-unknown-fields: true
36
status:
37
description: Status defines the observed state of MongoDB
38
type: object
39
x-kubernetes-preserve-unknown-fields: true
40
type: object
41
served: true
42
storage: true
43
subresources:
44
status: {}
45
Copied!
Copy link