Prompt:
Explain this text code:

--requestheader-client-ca-file=<path to aggregator CA cert>
--requestheader-allowed-names=front-proxy-client
--requestheader-extra-headers-prefix=X-Remote-Extra-
--requestheader-group-headers=X-Remote-Group
--requestheader-username-headers=X-Remote-User
--proxy-client-cert-file=<path to aggregator proxy cert>
--proxy-client-key-file=<path to aggregator proxy key>

Response: This text code 11.1 - Configure the Aggregation Layer | The Kubernetes apiserver has two client CA options:


Prompt:
Complete this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: <name of the registration object>
spec:
  group: <API group name this extension apiserver hosts>

Response:
  version: <API version this extension apiserver hosts>
  groupPriorityMinimum: <priority this APIService for this group, see API documentation>
  versionPriority: <prioritizes ordering of this version within a group, see API documentation>
  service:
    namespace: <namespace of the extension apiserver service>
    name: <name of the extension apiserver service>
  caBundle: <pem encoded ca cert that signs the server cert used by the webhook>

Context: 11.1 - Configure the Aggregation Layer | The name of an APIService object must be a valid path segment name.


Prompt:
Explain this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: <name of the registration object>
spec:
  group: <API group name this extension apiserver hosts>
  version: <API version this extension apiserver hosts>
  groupPriorityMinimum: <priority this APIService for this group, see API documentation>
  versionPriority: <prioritizes ordering of this version within a group, see API documentation>
  service:
    namespace: <namespace of the extension apiserver service>
    name: <name of the extension apiserver service>
  caBundle: <pem encoded ca cert that signs the server cert used by the webhook>

Response: This yaml code 11.1 - Configure the Aggregation Layer | The name of an APIService object must be a valid path segment name.


Prompt:
Complete this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
...
spec:
  ...

Response:
  service:
    namespace: my-service-namespace
    name: my-service-name
    port: 1234
  caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Context: 11.1 - Configure the Aggregation Layer | This page shows how to install a custom resource into the Kubernetes API by creating a CustomResourceDefinition.


Prompt:
Explain this yaml code:

apiVersion: apiregistration.k8s.io/v1
kind: APIService
...
spec:
  ...
  service:
    namespace: my-service-namespace
    name: my-service-name
    port: 1234
  caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Response: This yaml code 11.1 - Configure the Aggregation Layer | This page shows how to install a custom resource into the Kubernetes API by creating a CustomResourceDefinition.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:

Response:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.stable.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: stable.example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this text code:

/apis/stable.example.com/v1/namespaces/*/crontabs/...

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This endpoint URL can then be used to create and manage custom objects. The kind of these objects will be CronTab from the spec of the CustomResourceDefinition object you created above.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This endpoint URL can then be used to create and manage custom objects. The kind of these objects will be CronTab from the spec of the CustomResourceDefinition object you created above.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:

Response:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Complete this yaml code:

apiVersion: v1
items:
- apiVersion: stable.example.com/v1
  kind: CronTab
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"stable.example.com/v1","kind":"CronTab","metadata":{"annotations":{},"name":"my-new-cron-object","namespace":"default"},"spec":{"cronSpec":"* * * * */5","image":"my-awesome-cron-image"}}
    creationTimestamp: "2021-06-20T07:35:27Z"
    generation: 1

Response:
    name: my-new-cron-object
    namespace: default
    resourceVersion: "1326"
    uid: 9aab1d66-628e-41bb-a422-57b8b3b1f5a9
  spec:
    cronSpec: '* * * * */5'
    image: my-awesome-cron-image
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint and delete all custom objects stored in it.


Prompt:
Explain this yaml code:

apiVersion: v1
items:
- apiVersion: stable.example.com/v1
  kind: CronTab
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"stable.example.com/v1","kind":"CronTab","metadata":{"annotations":{},"name":"my-new-cron-object","namespace":"default"},"spec":{"cronSpec":"* * * * */5","image":"my-awesome-cron-image"}}
    creationTimestamp: "2021-06-20T07:35:27Z"
    generation: 1
    name: my-new-cron-object
    namespace: default
    resourceVersion: "1326"
    uid: 9aab1d66-628e-41bb-a422-57b8b3b1f5a9
  spec:
    cronSpec: '* * * * */5'
    image: my-awesome-cron-image
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | When you delete a CustomResourceDefinition, the server will uninstall the RESTful API endpoint and delete all custom objects stored in it.


Prompt:
Explain this shell code:

kubectl delete -f resourcedefinition.yaml
kubectl get crontabs

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.


Prompt:
Explain this none code:

Error from server (NotFound): Unable to list {"stable.example.com" "v1" "crontabs"}: the server could not
find the requested resource (get crontabs.stable.example.com)

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you later recreate the same CustomResourceDefinition, it will start out empty.


Prompt:
Complete this yaml code:

properties:
  foo:
    # ...

Response:
allOf:
- properties:
    foo:
      # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 2:


Prompt:
Explain this yaml code:

properties:
  foo:
    # ...
allOf:
- properties:
    foo:
      # ...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 2:


Prompt:
Complete this yaml code:

allOf:
- items:

Response:
    properties:
      foo:
        # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | conflicts with rule 2. The following would be correct:


Prompt:
Explain this yaml code:

allOf:
- items:
    properties:
      foo:
        # ...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | conflicts with rule 2. The following would be correct:


Prompt:
Complete this yaml code:

items:
  properties:
    foo:
      # ...

Response:
allOf:
- items:
    properties:
      foo:
        # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 3:


Prompt:
Explain this yaml code:

items:
  properties:
    foo:
      # ...
allOf:
- items:
    properties:
      foo:
        # ...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Non-structural example 3:


Prompt:
Complete this yaml code:

properties:
  foo:
    pattern: "abc"
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
      finalizers:

Response:
        type: array
        items:
          type: string
          pattern: "my-finalizer"
anyOf:
- properties:
    bar:
      type: integer
      minimum: 42
  required: ["bar"]
  description: "foo bar object"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is not a structural schema because of the following violations:


Prompt:
Explain this yaml code:

properties:
  foo:
    pattern: "abc"
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
      finalizers:
        type: array
        items:
          type: string
          pattern: "my-finalizer"
anyOf:
- properties:
    bar:
      type: integer
      minimum: 42
  required: ["bar"]
  description: "foo bar object"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is not a structural schema because of the following violations:


Prompt:
Complete this yaml code:

type: object
description: "foo bar object"
properties:
  foo:
    type: string
    pattern: "abc"
  bar:
    type: integer
  metadata:

Response:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
anyOf:
- properties:
    bar:
      minimum: 42
  required: ["bar"]

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Violations of the structural schema rules are reported in the NonStructural condition in the CustomResourceDefinition.


Prompt:
Explain this yaml code:

type: object
description: "foo bar object"
properties:
  foo:
    type: string
    pattern: "abc"
  bar:
    type: integer
  metadata:
    type: object
    properties:
      name:
        type: string
        pattern: "^a"
anyOf:
- properties:
    bar:
      minimum: 42
  required: ["bar"]

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Violations of the structural schema rules are reported in the NonStructural condition in the CustomResourceDefinition.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  someRandomField: 42


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  someRandomField: 42

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this shell code:

kubectl create --validate=false -f my-crontab.yaml -o yaml

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Your output is similar to:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Your output is similar to:


Prompt:
Complete this yaml code:

apiVersion: stable.example.com/v1
kind: CronTab
metadata:
  creationTimestamp: 2017-05-31T12:56:35Z
  generation: 1
  name: my-new-cron-object

Response:
  namespace: default
  resourceVersion: "285"
  uid: 9423255b-4600-11e7-af6a-28d2447dc82b
spec:
  cronSpec: '* * * * */5'
  image: my-awesome-cron-image

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Notice that the field someRandomField was pruned.


Prompt:
Explain this yaml code:

apiVersion: stable.example.com/v1
kind: CronTab
metadata:
  creationTimestamp: 2017-05-31T12:56:35Z
  generation: 1
  name: my-new-cron-object
  namespace: default
  resourceVersion: "285"
  uid: 9423255b-4600-11e7-af6a-28d2447dc82b
spec:
  cronSpec: '* * * * */5'
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Notice that the field someRandomField was pruned.


Prompt:
Complete this yaml code:

type: object
properties:

Response:
  json:
    x-kubernetes-preserve-unknown-fields: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The field json can store any JSON value, without anything being pruned.


Prompt:
Explain this yaml code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The field json can store any JSON value, without anything being pruned.


Prompt:
Complete this yaml code:

type: object
properties:
  json:

Response:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    description: this is arbitrary JSON

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, only object type values are allowed.


Prompt:
Explain this yaml code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    description: this is arbitrary JSON

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, only object type values are allowed.


Prompt:
Complete this yaml code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    properties:

Response:
      spec:
        type: object
        properties:
          foo:
            type: string
          bar:
            type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, the value:


Prompt:
Explain this yaml code:

type: object
properties:
  json:
    x-kubernetes-preserve-unknown-fields: true
    type: object
    properties:
      spec:
        type: object
        properties:
          foo:
            type: string
          bar:
            type: string

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this, the value:


Prompt:
Complete this yaml code:

json:
  spec:
    foo: abc

Response:
    bar: def
    something: x
  status:
    something: x

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is pruned to:


Prompt:
Explain this yaml code:

json:
  spec:
    foo: abc
    bar: def
    something: x
  status:
    something: x

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | is pruned to:


Prompt:
Complete this yaml code:

json:
  spec:
    foo: abc

Response:
    bar: def
  status:
    something: x

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This means that the something field in the specified spec object is pruned, but everything outside is not.


Prompt:
Explain this yaml code:

json:
  spec:
    foo: abc
    bar: def
  status:
    something: x

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This means that the something field in the specified spec object is pruned, but everything outside is not.


Prompt:
Complete this yaml code:

type: object
properties:

Response:
  foo:
    x-kubernetes-int-or-string: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Also those nodes are partially excluded from rule 3 in the sense that the following two patterns are allowed (exactly those, without variations in order to additional fields):


Prompt:
Explain this yaml code:

type: object
properties:
  foo:
    x-kubernetes-int-or-string: true

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Also those nodes are partially excluded from rule 3 in the sense that the following two patterns are allowed (exactly those, without variations in order to additional fields):


Prompt:
Complete this yaml code:

x-kubernetes-int-or-string: true
anyOf:

Response:
  - type: integer
  - type: string
...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and


Prompt:
Explain this yaml code:

x-kubernetes-int-or-string: true
anyOf:
  - type: integer
  - type: string
...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and


Prompt:
Complete this yaml code:

x-kubernetes-int-or-string: true
allOf:
  - anyOf:

Response:
      - type: integer
      - type: string
  - # ... zero or more
...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With one of those specification, both an integer and a string validate.


Prompt:
Explain this yaml code:

x-kubernetes-int-or-string: true
allOf:
  - anyOf:
      - type: integer
      - type: string
  - # ... zero or more
...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With one of those specification, both an integer and a string validate.


Prompt:
Complete this yaml code:

type: object
properties:

Response:
  foo:
    x-kubernetes-embedded-resource: true
    x-kubernetes-preserve-unknown-fields: true

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Here, the field foo holds a complete object, e.g.:


Prompt:
Explain this yaml code:

type: object
properties:
  foo:
    x-kubernetes-embedded-resource: true
    x-kubernetes-preserve-unknown-fields: true

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Here, the field foo holds a complete object, e.g.:


Prompt:
Complete this yaml code:

foo:
  apiVersion: v1

Response:
  kind: Pod
  spec:
    # ...

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Because x-kubernetes-preserve-unknown-fields: true is specified alongside, nothing is pruned. The use of x-kubernetes-preserve-unknown-fields: true is optional though.


Prompt:
Explain this yaml code:

foo:
  apiVersion: v1
  kind: Pod
  spec:
    # ...

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Because x-kubernetes-preserve-unknown-fields: true is specified alongside, nothing is pruned. The use of x-kubernetes-preserve-unknown-fields: true is optional though.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab

Response:
metadata:
  finalizers:
  - stable.example.com/finalizer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Identifiers of custom finalizers consist of a domain name, a forward slash and the name of the finalizer. Any controller can add a finalizer to any object's list of finalizers.


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  finalizers:
  - stable.example.com/finalizer

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Identifiers of custom finalizers consist of a domain name, a forward slash and the name of the finalizer. Any controller can add a finalizer to any object's list of finalizers.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object

Response:
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * *"
  image: my-awesome-cron-image
  replicas: 15

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and attempt to create it:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * *"
  image: my-awesome-cron-image
  replicas: 15

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and attempt to create it:


Prompt:
Complete this console code:

The CronTab "my-new-cron-object" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"stable.example.com/v1", "kind":"CronTab", "metadata":map[string]interface {}{"name":"my-new-cron-object", "namespace":"default", "deletionTimestamp":interface {}(nil), "deletionGracePeriodSeconds":(*int64)(nil), "creationTimestamp":"2017-09-05T05:20:07Z", "uid":"e14d79e7-91f9-11e7-a598-f0761cb232d1", "clusterName":""}, "spec":map[string]interface {}{"cronSpec":"* * * *", "image":"my-awesome-cron-image", "replicas":15}}:
validation failure list:

Response:
spec.cronSpec in body should match '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
spec.replicas in body should be less than or equal to 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the fields contain valid values, the object creation request is accepted.


Prompt:
Explain this console code:

The CronTab "my-new-cron-object" is invalid: []: Invalid value: map[string]interface {}{"apiVersion":"stable.example.com/v1", "kind":"CronTab", "metadata":map[string]interface {}{"name":"my-new-cron-object", "namespace":"default", "deletionTimestamp":interface {}(nil), "deletionGracePeriodSeconds":(*int64)(nil), "creationTimestamp":"2017-09-05T05:20:07Z", "uid":"e14d79e7-91f9-11e7-a598-f0761cb232d1", "clusterName":""}, "spec":map[string]interface {}{"cronSpec":"* * * *", "image":"my-awesome-cron-image", "replicas":15}}:
validation failure list:
spec.cronSpec in body should match '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
spec.replicas in body should be less than or equal to 10

Response: This console code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the fields contain valid values, the object creation request is accepted.


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 5

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 5

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Explain this shell code:

kubectl apply -f my-crontab.yaml
crontab "my-new-cron-object" created

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you are using a version of Kubernetes older than v1.30, you need to explicitly enable the CRDValidationRatcheting feature gate to use this behavior, which then applies to all CustomResourceDefiniti

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If you are using a version of Kubernetes older than v1.30, you need to explicitly enable the CRDValidationRatcheting feature gate to use this behavior, which then applies to all CustomResourceDefiniti


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self.minReplicas <= self.replicas"
            message: "replicas should be greater than or equal to minReplicas."
          - rule: "self.replicas <= self.maxReplicas"
            message: "replicas should be smaller than or equal to maxReplicas."

Response:
        properties:
          # ...
          minReplicas:
            type: integer
          replicas:
            type: integer
          maxReplicas:
            type: integer
        required:
          - minReplicas
          - replicas
          - maxReplicas

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | will reject a request to create this custom resource:


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self.minReplicas <= self.replicas"
            message: "replicas should be greater than or equal to minReplicas."
          - rule: "self.replicas <= self.maxReplicas"
            message: "replicas should be smaller than or equal to maxReplicas."
        properties:
          # ...
          minReplicas:
            type: integer
          replicas:
            type: integer
          maxReplicas:
            type: integer
        required:
          - minReplicas
          - replicas
          - maxReplicas

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | will reject a request to create this custom resource:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  minReplicas: 0
  replicas: 20
  maxReplicas: 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | with the response:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  minReplicas: 0
  replicas: 20
  maxReplicas: 10

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | with the response:


Prompt:
Explain this text code:

The CronTab "my-new-cron-object" is invalid:
* spec: Invalid value: map[string]interface {}{"maxReplicas":10, "minReplicas":0, "replicas":20}: replicas should be smaller than or equal to maxReplicas.

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | x-kubernetes-validations could have multiple rules. The rule under x-kubernetes-validations represents the expression which will be evaluated by CEL. The message represents the message displayed when

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | x-kubernetes-validations could have multiple rules. The rule under x-kubernetes-validations represents the expression which will be evaluated by CEL. The message represents the message displayed when


Prompt:
Explain this text code:

The CronTab "my-new-cron-object" is invalid:
* spec: Invalid value: map[string]interface {}{"maxReplicas":10, "minReplicas":0, "replicas":20}: failed rule: self.replicas <= self.maxReplicas

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation rules are compiled when CRDs are created/updated. The request of CRDs create/update will fail if compilation of validation rules fail. Compilation process includes type checking as well.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation rules are compiled when CRDs are created/updated. The request of CRDs create/update will fail if compilation of validation rules fail. Compilation process includes type checking as well.


Prompt:
Explain this none code:

Invalid value: apiextensions.ValidationRule{Rule:"self == true", Message:""}: compilation failed: ERROR: \<input>:1:6: found no matching overload for '_==_' applied to '(int, bool)'

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | no_such_field: does not contain the desired field.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | no_such_field: does not contain the desired field.


Prompt:
Explain this none code:

Invalid value: apiextensions.ValidationRule{Rule:"self.nonExistingField > 0", Message:""}: compilation failed: ERROR: \<input>:1:5: undefined field 'nonExistingField'

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | invalid argument: invalid argument to macros.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | invalid argument: invalid argument to macros.


Prompt:
Explain this none code:

Invalid value: apiextensions.ValidationRule{Rule:"has(self)", Message:""}: compilation failed: ERROR: <input>:1:4: invalid argument to has() macro

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation Rules Examples:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Validation Rules Examples:


Prompt:
Explain this text code:

self.minReplicas <= self.replicas && self.replicas <= self.maxReplicas

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

!('MY_KEY' in self.map1) || self['MY_KEY'].matches('^[a-zA-Z]*$')

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

self.envars.filter(e, e.name == 'MY_ENV').all(e, e.value.matches('^[a-zA-Z]*$')

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

has(self.expired) && self.created + self.ttl < self.expired

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

type(self) == string ? self == '100%' : self == 1000

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

size(self.names) == size(self.details) && self.names.all(n, n in self.details)

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Explain this text code:

size(self.clusters.filter(c, c.name == self.primary)) == 1

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Xref: Supported evaluation on CEL


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    x-kubernetes-validations:
      - rule: "self.status.availableReplicas >= self.spec.minReplicas"
    properties:
        spec:
          type: object

Response:
          properties:
            minReplicas:
              type: integer
            # ...
        status:
          type: object
          properties:
            availableReplicas:
              type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued field


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    x-kubernetes-validations:
      - rule: "self.status.availableReplicas >= self.spec.minReplicas"
    properties:
        spec:
          type: object
          properties:
            minReplicas:
              type: integer
            # ...
        status:
          type: object
          properties:
            availableReplicas:
              type: integer

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with properties, the accessible properties of the object are field selectable via self.field and field presence can be checked via has(self.field). Null valued field


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object

Response:
        x-kubernetes-validations:
          - rule: "has(self.foo)"
        properties:
          # ...
          foo:
            type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "has(self.foo)"
        properties:
          # ...
          foo:
            type: integer

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an object with additionalProperties (i.e. a map) the value of the map are accessible via self[mapKey], map containment can be checked via mapKey in self and all entries of the


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:

Response:
          - rule: "self['xyz'].foo > 0"
        additionalProperties:
          # ...
          type: object
          properties:
            foo:
              type: integer

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions.


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        x-kubernetes-validations:
          - rule: "self['xyz'].foo > 0"
        additionalProperties:
          # ...
          type: object
          properties:
            foo:
              type: integer

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to an array, the elements of the array are accessible via self[i] and also by macros and functions.


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      # ...

Response:
      foo:
        type: array
        x-kubernetes-validations:
          - rule: "size(self) == 1"
        items:
          type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to a scalar, self is bound to the scalar value.


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      # ...
      foo:
        type: array
        x-kubernetes-validations:
          - rule: "size(self) == 1"
        items:
          type: string

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If the Rule is scoped to a scalar, self is bound to the scalar value.


Prompt:
Complete this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object

Response:
        properties:
          # ...
          foo:
            type: integer
            x-kubernetes-validations:
            - rule: "self > 0"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Examples:


Prompt:
Explain this yaml code:

# ...
  openAPIV3Schema:
    type: object
    properties:
      spec:
        type: object
        properties:
          # ...
          foo:
            type: integer
            x-kubernetes-validations:
            - rule: "self > 0"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Examples:


Prompt:
Explain this yaml code:

x-kubernetes-validations:
- rule: "self.x <= self.maxLimit"
  messageExpression: '"x exceeded max limit of " + string(self.maxLimit)'

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Keep in mind that CEL string concatenation (+ operator) does not auto-cast to string. If you have a non-string scalar, use the string(<value>) function to cast the scalar to a string like shown in the

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Keep in mind that CEL string concatenation (+ operator) does not auto-cast to string. If you have a non-string scalar, use the string(<value>) function to cast the scalar to a string like shown in the


Prompt:
Explain this yaml code:

x-kubernetes-validations:
- rule: "self.x <= self.maxLimit"
  reason: "FieldValueInvalid"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The HTTP status code returned to the caller will match the reason of the first failed validation rule. The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequi

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The HTTP status code returned to the caller will match the reason of the first failed validation rule. The currently supported reasons are: "FieldValueInvalid", "FieldValueForbidden", "FieldValueRequi


Prompt:
Explain this yaml code:

x-kubernetes-validations:
- rule: "self.foo.test.x <= self.maxLimit"
  fieldPath: ".foo.test.x"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | In the example above, the validation checks the value of field x should be less than the value of maxLimit. If no fieldPath specified, when validation fails, the fieldPath would be default to wherever

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | In the example above, the validation checks the value of field x should be less than the value of maxLimit. If no fieldPath specified, when validation fails, the fieldPath would be default to wherever


Prompt:
Explain this text code:

self.foo == "foo" || (oldSelf.hasValue() && oldSelf.value().foo != "foo")

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Functions available include:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Functions available include:


Prompt:
Explain this json code:

[oldSelf.orValue(""), self].all(x, ["OldCase1", "OldCase2"].exists(case, x == case)) || ["NewCase1", "NewCase2"].exists(case, self == case) || ["NewCase"].has(self)

Response: This json code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Functions available include:


Prompt:
Explain this text code:

oldSelf.optMap(o, o.size()).orValue(0) < 4 || self.size() >= 4

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Functions available include:


Prompt:
Complete this yaml code:

type: string
enum: ["low", "medium", "high"]

Response:
x-kubernetes-validations:
- rule: "!(self == 'high' && oldSelf == 'low') && !(self == 'low' && oldSelf == 'high')"
  message: cannot transition directly between 'low' and 'high'

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Unlike other rules, transition rules apply only to operations meeting the following criteria:


Prompt:
Explain this yaml code:

type: string
enum: ["low", "medium", "high"]
x-kubernetes-validations:
- rule: "!(self == 'high' && oldSelf == 'low') && !(self == 'low' && oldSelf == 'high')"
  message: cannot transition directly between 'low' and 'high'

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Unlike other rules, transition rules apply only to operations meeting the following criteria:


Prompt:
Complete this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:

Response:
      type: array
      items:
        type: string
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | then the API server rejects this rule on validation budget grounds with error:


Prompt:
Explain this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: string
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | then the API server rejects this rule on validation budget grounds with error:


Prompt:
Explain this text code:

spec.validation.openAPIV3Schema.properties[spec].properties[foo].x-kubernetes-validations[0].rule: Forbidden:
CEL rule exceeded budget by more than 100x (try simplifying the rule, or adding maxItems, maxProperties, and
maxLength where arrays, maps, and strings are used)

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The rejection happens because self.all implies calling contains() on every string in foo, which in turn will check the given string to see if it contains 'a string'. Without limits, this is a very exp

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The rejection happens because self.all implies calling contains() on every string in foo, which in turn will check the given string to see if it contains 'a string'. Without limits, this is a very exp


Prompt:
Complete this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      maxItems: 25
      items:
        type: string
        maxLength: 10
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The cost estimation system takes into account how many times the rule will be executed in addition to the estimated cost of the rule itself. For instance, the following rule will have the same estimat


Prompt:
Explain this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      maxItems: 25
      items:
        type: string
        maxLength: 10
      x-kubernetes-validations:
        - rule: "self.all(x, x.contains('a string'))"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | The cost estimation system takes into account how many times the rule will be executed in addition to the estimated cost of the rule itself. For instance, the following rule will have the same estimat


Prompt:
Complete this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      maxItems: 25
      items:
        type: string
        x-kubernetes-validations:
          - rule: "self.contains('a string'))"
        maxLength: 10

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If a list inside of a list has a validation rule that uses self.all, that is significantly more expensive than a non-nested list with the same rule. A rule that would have been allowed on a non-nested


Prompt:
Explain this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      maxItems: 25
      items:
        type: string
        x-kubernetes-validations:
          - rule: "self.contains('a string'))"
        maxLength: 10

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | If a list inside of a list has a validation rule that uses self.all, that is significantly more expensive than a non-nested list with the same rule. A rule that would have been allowed on a non-nested


Prompt:
Complete this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:

Response:
      type: array
      items:
        type: integer
    x-kubernetes-validations:
      - rule: "self.all(x, x == 5)"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | But the same rule on the following schema (with a nested array added) produces a validation error:


Prompt:
Explain this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: integer
    x-kubernetes-validations:
      - rule: "self.all(x, x == 5)"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | But the same rule on the following schema (with a nested array added) produces a validation error:


Prompt:
Complete this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array

Response:
      items:
        type: array
        items:
          type: integer
        x-kubernetes-validations:
          - rule: "self.all(x, x == 5)"

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This is because each item of foo is itself an array, and each subarray in turn calls self.all. Avoid nested lists and maps if possible where validation rules are used.


Prompt:
Explain this yaml code:

openAPIV3Schema:
  type: object
  properties:
    foo:
      type: array
      items:
        type: array
        items:
          type: integer
        x-kubernetes-validations:
          - rule: "self.all(x, x == 5)"

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | This is because each item of foo is itself an array, and each subarray in turn calls self.all. Avoid nested lists and maps if possible where validation rules are used.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:

Response:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                  default: "5 0 * * *"
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this both cronSpec and replicas are defaulted:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        # openAPIV3Schema is the schema for validating custom objects.
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                  pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
                  default: "5 0 * * *"
                image:
                  type: string
                replicas:
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | With this both cronSpec and replicas are defaulted:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:

Response:
  name: my-new-cron-object
spec:
  image: my-awesome-cron-image

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | leads to


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | leads to


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "5 0 * * *"
  image: my-awesome-cron-image
  replicas: 1

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Defaulting happens on the object


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "5 0 * * *"
  image: my-awesome-cron-image
  replicas: 1

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Defaulting happens on the object


Prompt:
Complete this yaml code:

type: object
properties:
  spec:
    type: object
    properties:
      foo:
        type: string

Response:
        nullable: false
        default: "default"
      bar:
        type: string
        nullable: true
      baz:
        type: string

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | creating an object with null values for foo and bar and baz


Prompt:
Explain this yaml code:

type: object
properties:
  spec:
    type: object
    properties:
      foo:
        type: string
        nullable: false
        default: "default"
      bar:
        type: string
        nullable: true
      baz:
        type: string

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | creating an object with null values for foo and bar and baz


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:

Response:
          spec:
            type: object
            properties:
              cronSpec:
                type: string
              image:
                type: string
              replicas:
                type: integer
    additionalPrinterColumns:
    - name: Spec
      type: string
      description: The cron spec defining the interval a CronJob is run
      jsonPath: .spec.cronSpec
    - name: Replicas
      type: integer
      description: The number of jobs launched by the CronJob
      jsonPath: .spec.replicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              cronSpec:
                type: string
              image:
                type: string
              replicas:
                type: integer
    additionalPrinterColumns:
    - name: Spec
      type: string
      description: The cron spec defining the interval a CronJob is run
      jsonPath: .spec.cronSpec
    - name: Replicas
      type: integer
      description: The number of jobs launched by the CronJob
      jsonPath: .spec.replicas
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this text code:

NAME                 SPEC        REPLICAS   AGE
my-new-cron-object   * * * * *   1          7s

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Each column includes a priority field. Currently, the priority differentiates between columns shown in standard view or wide view (using the -o wide flag).

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Each column includes a priority field. Currently, the priority differentiates between columns shown in standard view or wide view (using the -o wide flag).


Prompt:
Explain this text code:

customresourcedefinition/shirt-resource-definition.yaml

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: shirts.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: shirts
    singular: shirt
    kind: Shirt
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object

Response:
        properties:
          spec:
            type: object
            properties:
              color:
                type: string
              size:
                type: string
    selectableFields:
    - jsonPath: .spec.color
    - jsonPath: .spec.size
    additionalPrinterColumns:
    - jsonPath: .spec.color
      name: Color
      type: string
    - jsonPath: .spec.size
      name: Size
      type: string


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: shirts.stable.example.com
spec:
  group: stable.example.com
  scope: Namespaced
  names:
    plural: shirts
    singular: shirt
    kind: Shirt
  versions:
  - name: v1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:
              color:
                type: string
              size:
                type: string
    selectableFields:
    - jsonPath: .spec.color
    - jsonPath: .spec.size
    additionalPrinterColumns:
    - jsonPath: .spec.color
      name: Color
      type: string
    - jsonPath: .spec.size
      name: Size
      type: string

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the CustomResourceDefinition:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/customresourcedefinition/shirt-resource-definition.yaml

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Define some Shirts by editing shirt-resources.yaml; for example:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Define some Shirts by editing shirt-resources.yaml; for example:


Prompt:
Complete this yaml code:

---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example1
spec:
  color: blue
  size: S
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:

Response:
  name: example2
spec:
  color: blue
  size: M
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example3
spec:
  color: green
  size: M

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the custom resources:


Prompt:
Explain this yaml code:

---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example1
spec:
  color: blue
  size: S
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example2
spec:
  color: blue
  size: M
---
apiVersion: stable.example.com/v1
kind: Shirt
metadata:
  name: example3
spec:
  color: green
  size: M

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Create the custom resources:


Prompt:
Explain this shell code:

kubectl apply -f https://k8s.io/examples/customresourcedefinition/shirt-resources.yaml

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Get all the resources:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Get all the resources:


Prompt:
Complete this text code:

NAME       COLOR  SIZE
example1   blue   S

Response:
example2   blue   M
example3   green  M

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Fetch blue shirts (retrieve Shirts with a color of blue):


Prompt:
Explain this text code:

NAME       COLOR  SIZE
example1   blue   S
example2   blue   M
example3   green  M

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Fetch blue shirts (retrieve Shirts with a color of blue):


Prompt:
Explain this shell code:

kubectl get shirts.stable.example.com --field-selector spec.color=blue

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Should output:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Should output:


Prompt:
Explain this text code:

NAME       COLOR  SIZE
example1   blue   S
example2   blue   M

Response: This text code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Get only resources with a color of green and a size of M:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Get only resources with a color of green and a size of M:


Prompt:
Explain this shell code:

kubectl get shirts.stable.example.com --field-selector spec.color=green,spec.size=M

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Should output:


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
            status:

Response:
              type: object
              properties:
                replicas:
                  type: integer
                labelSelector:
                  type: string
      # subresources describes the subresources for custom resources.
      subresources:
        # status enables the status subresource.
        status: {}
        # scale enables the scale subresource.
        scale:
          # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas.
          specReplicasPath: .spec.replicas
          # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas.
          statusReplicasPath: .status.replicas
          # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
          labelSelectorPath: .status.labelSelector
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
            status:
              type: object
              properties:
                replicas:
                  type: integer
                labelSelector:
                  type: string
      # subresources describes the subresources for custom resources.
      subresources:
        # status enables the status subresource.
        status: {}
        # scale enables the scale subresource.
        scale:
          # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas.
          specReplicasPath: .spec.replicas
          # statusReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Replicas.
          statusReplicasPath: .status.replicas
          # labelSelectorPath defines the JSONPath inside of a custom resource that corresponds to Scale.Status.Selector.
          labelSelectorPath: .status.labelSelector
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | And create it:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object

Response:
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 3

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image
  replicas: 3

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this none code:

/apis/stable.example.com/v1/namespaces/*/crontabs/status

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and


Prompt:
Explain this none code:

/apis/stable.example.com/v1/namespaces/*/crontabs/scale

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | A custom resource can be scaled using the kubectl scale command. For example, the following command sets .spec.replicas of the custom resource created above to 5:

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | A custom resource can be scaled using the kubectl scale command. For example, the following command sets .spec.replicas of the custom resource created above to 5:


Prompt:
Complete this shell code:

kubectl scale --replicas=5 crontabs/my-new-cron-object
crontabs "my-new-cron-object" scaled

Response:
kubectl get crontabs my-new-cron-object -o jsonpath='{.spec.replicas}'
5

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | You can use a PodDisruptionBudget to protect custom resources that have the scale subresource enabled.


Prompt:
Explain this shell code:

kubectl scale --replicas=5 crontabs/my-new-cron-object
crontabs "my-new-cron-object" scaled

kubectl get crontabs my-new-cron-object -o jsonpath='{.spec.replicas}'
5

Response: This shell code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | You can use a PodDisruptionBudget to protect custom resources that have the scale subresource enabled.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object

Response:
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
    # categories is a list of grouped resources the custom resource belongs to.
    categories:
    - all


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: crontabs.stable.example.com
spec:
  group: stable.example.com
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                cronSpec:
                  type: string
                image:
                  type: string
                replicas:
                  type: integer
  scope: Namespaced
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
    shortNames:
    - ct
    # categories is a list of grouped resources the custom resource belongs to.
    categories:
    - all

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Complete this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:

Response:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image


Prompt:
Explain this yaml code:

apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
  name: my-new-cron-object
spec:
  cronSpec: "* * * * */5"
  image: my-awesome-cron-image

Response: This yaml code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | and create it:


Prompt:
Explain this none code:

NAME                          AGE
crontabs/my-new-cron-object   3s

Response: This none code 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Read about custom resources.

Context: 11.2.1 - Extend the Kubernetes API with CustomResourceDefinitions | Read about custom resources.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # A schema is required
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  - name: v1
    served: true

Response:
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  # The conversion section is introduced in Kubernetes 1.13+ with a default value of
  # None conversion (strategy sub-field set to None).
  conversion:
    # None conversion assumes the same schema for all versions and only sets the apiVersion
    # field of custom resources to the proper value
    strategy: None
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Context: 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the for


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # A schema is required
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  - name: v1
    served: true
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  # The conversion section is introduced in Kubernetes 1.13+ with a default value of
  # None conversion (strategy sub-field set to None).
  conversion:
    # None conversion assumes the same schema for all versions and only sets the apiVersion
    # field of custom resources to the proper value
    strategy: None
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the for


Prompt:
Complete this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
  - name: v1
    served: true
    storage: false
  validation:
    openAPIV3Schema:
      type: object

Response:
      properties:
        host:
          type: string
        port:
          type: string
  # The conversion section is introduced in Kubernetes 1.13+ with a default value of
  # None conversion (strategy sub-field set to None).
  conversion:
    # None conversion assumes the same schema for all versions and only sets the apiVersion
    # field of custom resources to the proper value
    strategy: None
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the PascalCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Context: 11.2.2 - Versions in CustomResourceDefinitions | You can save the CustomResourceDefinition in a YAML file, then use kubectl apply to create it.


Prompt:
Explain this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
  - name: v1
    served: true
    storage: false
  validation:
    openAPIV3Schema:
      type: object
      properties:
        host:
          type: string
        port:
          type: string
  # The conversion section is introduced in Kubernetes 1.13+ with a default value of
  # None conversion (strategy sub-field set to None).
  conversion:
    # None conversion assumes the same schema for all versions and only sets the apiVersion
    # field of custom resources to the proper value
    strategy: None
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the PascalCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | You can save the CustomResourceDefinition in a YAML file, then use kubectl apply to create it.


Prompt:
Complete this none code:

- v10
- v2
- v1
- v11beta2
- v10beta3

Response:
- v3beta1
- v12alpha1
- v11alpha2
- foo1
- foo10

Context: 11.2.2 - Versions in CustomResourceDefinitions | For the example in Specify multiple versions, the version sort order is v1, followed by v1beta1. This causes the kubectl command to use v1 as the default version unless the provided object specifies t


Prompt:
Explain this none code:

- v10
- v2
- v1
- v11beta2
- v10beta3
- v3beta1
- v12alpha1
- v11alpha2
- foo1
- foo10

Response: This none code 11.2.2 - Versions in CustomResourceDefinitions | For the example in Specify multiple versions, the version sort order is v1, followed by v1beta1. This causes the kubectl command to use v1 as the default version unless the provided object specifies t


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: false
    # This indicates the v1alpha1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.

Response:
    deprecated: true
    # This overrides the default warning returned to API clients making v1alpha1 API requests.
    deprecationWarning: "example.com/v1alpha1 CronTab is deprecated; see http://example.com/v1alpha1-v1 for instructions to migrate to example.com/v1 CronTab"

    schema: ...
  - name: v1beta1
    served: true
    # This indicates the v1beta1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    # A default warning message is returned for this version.
    deprecated: true
    schema: ...
  - name: v1
    served: true
    storage: true
    schema: ...

Context: 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: crontabs.example.com spec: group: example.com na


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: false
    # This indicates the v1alpha1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    deprecated: true
    # This overrides the default warning returned to API clients making v1alpha1 API requests.
    deprecationWarning: "example.com/v1alpha1 CronTab is deprecated; see http://example.com/v1alpha1-v1 for instructions to migrate to example.com/v1 CronTab"

    schema: ...
  - name: v1beta1
    served: true
    # This indicates the v1beta1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    # A default warning message is returned for this version.
    deprecated: true
    schema: ...
  - name: v1
    served: true
    storage: true
    schema: ...

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: name: crontabs.example.com spec: group: example.com na


Prompt:
Complete this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced
  validation: ...
  versions:
  - name: v1alpha1

Response:
    served: true
    storage: false
    # This indicates the v1alpha1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    deprecated: true
    # This overrides the default warning returned to API clients making v1alpha1 API requests.
    deprecationWarning: "example.com/v1alpha1 CronTab is deprecated; see http://example.com/v1alpha1-v1 for instructions to migrate to example.com/v1 CronTab"
  - name: v1beta1
    served: true
    # This indicates the v1beta1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    # A default warning message is returned for this version.
    deprecated: true
  - name: v1
    served: true
    storage: true

Context: 11.2.2 - Versions in CustomResourceDefinitions | An older API version cannot be dropped from a CustomResourceDefinition manifest until existing stored data has been migrated to the newer API version for all clusters that served the older version of


Prompt:
Explain this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced
  validation: ...
  versions:
  - name: v1alpha1
    served: true
    storage: false
    # This indicates the v1alpha1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    deprecated: true
    # This overrides the default warning returned to API clients making v1alpha1 API requests.
    deprecationWarning: "example.com/v1alpha1 CronTab is deprecated; see http://example.com/v1alpha1-v1 for instructions to migrate to example.com/v1 CronTab"
  - name: v1beta1
    served: true
    # This indicates the v1beta1 version of the custom resource is deprecated.
    # API requests to this version receive a warning header in the server response.
    # A default warning message is returned for this version.
    deprecated: true
  - name: v1
    served: true
    storage: true

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | An older API version cannot be dropped from a CustomResourceDefinition manifest until existing stored data has been migrated to the newer API version for all clusters that served the older version of


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced

Response:
  versions:
  - name: v1beta1
    # This indicates the v1beta1 version of the custom resource is no longer served.
    # API requests to this version receive a not found error in the server response.
    served: false
    schema: ...
  - name: v1
    served: true
    # The new served version should be set as the storage version
    storage: true
    schema: ...

Context: 11.2.2 - Versions in CustomResourceDefinitions | The above example has a None conversion between versions which only sets the apiVersion field on conversion and does not change the rest of the object. The API server also supports webhook conversions


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
  name: crontabs.example.com
spec:
  group: example.com
  names:
    plural: crontabs
    singular: crontab
    kind: CronTab
  scope: Namespaced
  versions:
  - name: v1beta1
    # This indicates the v1beta1 version of the custom resource is no longer served.
    # API requests to this version receive a not found error in the server response.
    served: false
    schema: ...
  - name: v1
    served: true
    # The new served version should be set as the storage version
    storage: true
    schema: ...

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | The above example has a None conversion between versions which only sets the apiVersion field on conversion and does not change the rest of the object. The API server also supports webhook conversions


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # Each version can define its own schema when there is no top-level
    # schema is defined.
    schema:
      openAPIV3Schema:
        type: object
        properties:
          hostPort:
            type: string
  - name: v1
    served: true
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:

Response:
          host:
            type: string
          port:
            type: string
  conversion:
    # the Webhook strategy instructs the API server to call an external webhook for any conversion between custom resources.
    strategy: Webhook
    # webhook is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server.
    webhook:
      # conversionReviewVersions indicates what ConversionReview versions are understood/preferred by the webhook.
      # The first version in the list understood by the API server is sent to the webhook.
      # The webhook must respond with a ConversionReview object in the same version it received.
      conversionReviewVersions: ["v1","v1beta1"]
      clientConfig:
        service:
          namespace: default
          name: example-conversion-webhook-server
          path: /crdconvert
        caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # Each version can define its own schema when there is no top-level
    # schema is defined.
    schema:
      openAPIV3Schema:
        type: object
        properties:
          hostPort:
            type: string
  - name: v1
    served: true
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  conversion:
    # the Webhook strategy instructs the API server to call an external webhook for any conversion between custom resources.
    strategy: Webhook
    # webhook is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server.
    webhook:
      # conversionReviewVersions indicates what ConversionReview versions are understood/preferred by the webhook.
      # The first version in the list understood by the API server is sent to the webhook.
      # The webhook must respond with a ConversionReview object in the same version it received.
      conversionReviewVersions: ["v1","v1beta1"]
      clientConfig:
        service:
          namespace: default
          name: example-conversion-webhook-server
          path: /crdconvert
        caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: # name must match the spec fields below, and be in the for


Prompt:
Complete this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # prunes object fields that are not specified in OpenAPI schemas below.
  preserveUnknownFields: false
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # Each version can define its own schema when there is no top-level
    # schema is defined.
    schema:
      openAPIV3Schema:
        type: object
        properties:
          hostPort:
            type: string
  - name: v1
    served: true
    storage: false

Response:
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  conversion:
    # the Webhook strategy instructs the API server to call an external webhook for any conversion between custom resources.
    strategy: Webhook
    # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server.
    webhookClientConfig:
      service:
        namespace: default
        name: example-conversion-webhook-server
        path: /crdconvert
      caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Context: 11.2.2 - Versions in CustomResourceDefinitions | You can save the CustomResourceDefinition in a YAML file, then use kubectl apply to apply it.


Prompt:
Explain this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: crontabs.example.com
spec:
  # group name to use for REST API: /apis/<group>/<version>
  group: example.com
  # prunes object fields that are not specified in OpenAPI schemas below.
  preserveUnknownFields: false
  # list of versions supported by this CustomResourceDefinition
  versions:
  - name: v1beta1
    # Each version can be enabled/disabled by Served flag.
    served: true
    # One and only one version must be marked as the storage version.
    storage: true
    # Each version can define its own schema when there is no top-level
    # schema is defined.
    schema:
      openAPIV3Schema:
        type: object
        properties:
          hostPort:
            type: string
  - name: v1
    served: true
    storage: false
    schema:
      openAPIV3Schema:
        type: object
        properties:
          host:
            type: string
          port:
            type: string
  conversion:
    # the Webhook strategy instructs the API server to call an external webhook for any conversion between custom resources.
    strategy: Webhook
    # webhookClientConfig is required when strategy is `Webhook` and it configures the webhook endpoint to be called by API server.
    webhookClientConfig:
      service:
        namespace: default
        name: example-conversion-webhook-server
        path: /crdconvert
      caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: crontabs
    # singular name to be used as an alias on the CLI and for display
    singular: crontab
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: CronTab
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ct

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | You can save the CustomResourceDefinition in a YAML file, then use kubectl apply to apply it.


Prompt:
Explain this shell code:

kubectl apply -f my-versioned-crontab-with-conversion.yaml

Response: This shell code 11.2.2 - Versions in CustomResourceDefinitions | Make sure the conversion service is up and running before applying new changes.

Context: 11.2.2 - Versions in CustomResourceDefinitions | Make sure the conversion service is up and running before applying new changes.


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
...
spec:
  ...

Response:
  conversion:
    strategy: Webhook
    webhook:
      clientConfig:
        url: "https://my-webhook.example.com:9443/my-webhook-path"
...

Context: 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition ... spec: ... conversion: strategy: Webhook webhookClientC


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
...
spec:
  ...
  conversion:
    strategy: Webhook
    webhook:
      clientConfig:
        url: "https://my-webhook.example.com:9443/my-webhook-path"
...

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition ... spec: ... conversion: strategy: Webhook webhookClientC


Prompt:
Complete this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
...
spec:

Response:
  ...
  conversion:
    strategy: Webhook
    webhookClientConfig:
      url: "https://my-webhook.example.com:9443/my-webhook-path"
...

Context: 11.2.2 - Versions in CustomResourceDefinitions | The service stanza inside webhookClientConfig is a reference to the service for a conversion webhook. If the webhook is running within the cluster, then you should use service instead of url. The serv


Prompt:
Explain this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
...
spec:
  ...
  conversion:
    strategy: Webhook
    webhookClientConfig:
      url: "https://my-webhook.example.com:9443/my-webhook-path"
...

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | The service stanza inside webhookClientConfig is a reference to the service for a conversion webhook. If the webhook is running within the cluster, then you should use service instead of url. The serv


Prompt:
Complete this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
...
spec:
  ...
  conversion:
    strategy: Webhook
    webhook:

Response:
      clientConfig:
        service:
          namespace: my-service-namespace
          name: my-service-name
          path: /my-path
          port: 1234
        caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...


Prompt:
Explain this yaml code:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
...
spec:
  ...
  conversion:
    strategy: Webhook
    webhook:
      clientConfig:
        service:
          namespace: my-service-namespace
          name: my-service-name
          path: /my-path
          port: 1234
        caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Response: This yaml code 11.2.2 - Versions in CustomResourceDefinitions | # Deprecated in v1.16 in favor of apiextensions.k8s.io/v1 apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition ... spec: ... conversion: strategy: Webhook webhookClientC


Prompt:
Complete this yaml code:

# Deprecated in v1.16 in favor of apiextensions.k8s.io/v1
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
...
spec:
  ...
  conversion:
    strategy: Webhook

Response:
    webhookClientConfig:
      service:
        namespace: my-service-namespace
        name: my-service-name
        path: /my-path
        port: 1234
      caBundle: "Ci0tLS0tQk...<base64-encoded PEM bundle>...tLS0K"
...

Context: 11.2.2 - Versions in CustomResourceDefinitions | Webhooks are sent a POST request, with Content-Type: application/json, with a ConversionReview API object in the apiextensions.k8s.io API group serialized to JSON as the body.