Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Commit

Permalink
Upgrade CRDs from v1beta1 to v1 for K8s 1.16+; keep remarks for K8s 1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
nolar committed May 8, 2020
1 parent d5b0d40 commit ed018a1
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 31 deletions.
41 changes: 41 additions & 0 deletions docs/walkthrough/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Custom Resource Definition

Let us define a CRD (custom resource definition) for our object.

For Kubernetes 1.15 and below:

.. code-block:: yaml
:caption: crd.yaml
:name: crd-yaml
Expand All @@ -18,17 +20,56 @@ Let us define a CRD (custom resource definition) for our object.
spec:
scope: Namespaced
group: zalando.org
names:
kind: EphemeralVolumeClaim
plural: ephemeralvolumeclaims
singular: ephemeralvolumeclaim
shortNames:
- evcs
- evc
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
For Kubernetes 1.16 and above:

.. code-block:: yaml
:caption: crd.yaml
:name: crd-yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: ephemeralvolumeclaims.zalando.org
spec:
scope: Namespaced
group: zalando.org
names:
kind: EphemeralVolumeClaim
plural: ephemeralvolumeclaims
singular: ephemeralvolumeclaim
shortNames:
- evcs
- evc
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
Note the short names: they can be used as the aliases on the command line,
when getting a list or an object of that kind.
Expand Down
39 changes: 39 additions & 0 deletions examples/crd-v1beta1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# A demo CRD for the Kopf example operators.
# Use it with Kubernetes 1.15 and below.
# For Kubernetes 1.16 and above, use crd.yaml.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: kopfexamples.zalando.org
spec:
scope: Namespaced
group: zalando.org
versions:
- name: v1
served: true
storage: true
names:
kind: KopfExample
plural: kopfexamples
singular: kopfexample
shortNames:
- kopfexes
- kopfex
- kexes
- kex
additionalPrinterColumns:
- name: Duration
type: string
priority: 0
JSONPath: .spec.duration
description: For how long the pod should sleep.
- name: Children
type: string
priority: 0
JSONPath: .status.create_fn.children
description: The children pods created.
- name: Message
type: string
priority: 0
JSONPath: .status.create_fn.message
description: As returned from the handler (sometimes).
51 changes: 30 additions & 21 deletions examples/crd.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# A demo CRD for the Kopf example operators.
apiVersion: apiextensions.k8s.io/v1beta1
# Use it with Kubernetes 1.16 and above.
# For Kubernetes 1.15 and below, use crd-v1beta1.yaml.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kopfexamples.zalando.org
spec:
scope: Namespaced
group: zalando.org
versions:
- name: v1
served: true
storage: true
names:
kind: KopfExample
plural: kopfexamples
Expand All @@ -19,19 +17,30 @@ spec:
- kopfex
- kexes
- kex
additionalPrinterColumns:
- name: Duration
type: string
priority: 0
JSONPath: .spec.duration
description: For how long the pod should sleep.
- name: Children
type: string
priority: 0
JSONPath: .status.create_fn.children
description: The children pods created.
- name: Message
type: string
priority: 0
JSONPath: .status.create_fn.message
description: As returned from the handler (sometimes).
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
additionalPrinterColumns:
- name: Duration
type: string
priority: 0
jsonPath: .spec.duration
description: For how long the pod should sleep.
- name: Children
type: string
priority: 0
jsonPath: .status.create_fn.children
description: The children pods created.
- name: Message
type: string
priority: 0
jsonPath: .status.create_fn.message
description: As returned from the handler (sometimes).
36 changes: 26 additions & 10 deletions peering.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
# This file is for Kubernetes >= 1.16.
# For Kubernetes <= 1.15, change "v1" to "v1beta1", and remove schemas.
---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clusterkopfpeerings.zalando.org
spec:
scope: Cluster
group: zalando.org
versions:
- name: v1
served: true
storage: true
names:
kind: ClusterKopfPeering
plural: clusterkopfpeerings
singular: clusterkopfpeering
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kopfpeerings.zalando.org
spec:
scope: Namespaced
group: zalando.org
versions:
- name: v1
served: true
storage: true
names:
kind: KopfPeering
plural: kopfpeerings
singular: kopfpeering
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
---
apiVersion: zalando.org/v1
kind: ClusterKopfPeering
Expand Down

0 comments on commit ed018a1

Please sign in to comment.