Skip to content

CustomResourceDefinition Serialization | x-kubernetes-int-or-string Dropped #2483

Open
@sebastianserrano

Description

@sebastianserrano

Describe the bug

When trying to create a CRD with x-kubernetes-int-or-string, its being dropped causing the server to respond with The CustomResourceDefinition "middlewares.traefik.io" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[circuitBreaker].properties[checkPeriod].type: Required value: must not be empty for specified object fields.

Original CRD

original.yaml

Image

Broken CRD

broken.yaml

This is what is actually being passed to the server. How do I know? I print it out before sending the request in the underlying node_module, node_modules/@kubernetes/client-node/dist/object.js

Image

Image

Client Version
1.0.0 to 1.3.0

Server Version
1.30.0 to 1.33.0

To Reproduce
Steps to reproduce the behavior:

First option
  1. Use example code
Second option
  1. kubectl apply -f [USE HERE BROKEN CRD YAML]

Image

^^ These are the errors you get while using the first option

Expected behavior

The create call should not strip out x-kubernetes-int-or-string. In essence, it should replicate the behaviour of kubectl apply -f [USE HERE ORIGINAL CRD YAML] which successfully creates the resource

Example Code

import yaml from 'yaml';
import * as k8s from '@kubernetes/client-node';

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

const client = k8s.KubernetesObjectApi.makeApiClient(kc);
const spec = yaml.parse(USE HERE ORIGINAL CRD YAML).toJS()

await client.create(spec);

Environment (please complete the following information):

  • OS: Linux
  • Node.js version: v20.14.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions