Describe the bug
KubernetesObjectApi.create() silently drops the CRD schema extension x-kubernetes-preserve-unknown-fields when given a plain JavaScript object parsed from YAML.
Client Version
1.4.0
Server Version
1.34
To Reproduce
const yaml = require("js-yaml");
const k8s = require("@kubernetes/client-node");
async function main() {
const crd = yaml.load(`
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: foos.example.com
spec:
group: example.com
scope: Namespaced
names:
plural: foos
singular: foo
kind: Foo
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
podTemplate:
type: object
x-kubernetes-preserve-unknown-fields: true
`);
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
kc.setCurrentContext("orbstack");
const client = k8s.KubernetesObjectApi.makeApiClient(kc);
const result = await client.create(crd);
console.log(result.body)
}
main().then(() => console.log("done"));
the API server response does not contain x-kubernetes-preserve-unknown-fields.
Expected behavior
The API server response should retain x-kubernetes-preserve-unknown-fields: true, since it is present in the YAML input.
Example Code
Code snippet for what you are doing
Environment (please complete the following information):
- OS: [macOS]
- Node.js version [26.5.0]
Describe the bug
KubernetesObjectApi.create()silently drops the CRD schema extensionx-kubernetes-preserve-unknown-fieldswhen given a plain JavaScript object parsed from YAML.Client Version
1.4.0Server Version
1.34To Reproduce
the API server response does not contain x-kubernetes-preserve-unknown-fields.
Expected behavior
The API server response should retain x-kubernetes-preserve-unknown-fields: true, since it is present in the YAML input.
Example Code
Code snippet for what you are doing
Environment (please complete the following information):