[英]How do I create a Kubernetes Custom Resource using javascript client
My custom definition我的自定义定义
apiVersion: something.com/v1alpha1
kind: MyKind
metadata:
name: test
spec:
size: 1
image: myimage
Here is an answer that shows how to create a deployment using a javascript client. 这是一个显示如何使用 javascript 客户端创建部署的答案。 However, I need to create a custom resource using a javascript client
但是,我需要使用 javascript 客户端创建自定义资源
All the client libraries are auto-generated from the same underlying IDL so it works like in Go, createNamespacedCustomObject
.所有客户端库都是从相同的底层 IDL 自动生成的,因此它的工作方式类似于 Go 中的
createNamespacedCustomObject
。 You can also use the raw API directly too.您也可以直接使用原始 API。
const k8s = require('@kubernetes/client-node')
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sClient = kc.makeApiClient(k8s.CustomObjectsApi);
var body = {
"apiVersion": "something.com/v1alpha1",
"kind": "MyKind",
"metadata": {
"name": "mycustomobject",
},
"spec": {
"size": "1",
"image": "myimage"
}
}
k8sClient.createNamespacedCustomObject('something.com','v1alpha1','default','mykinds', body)
.then((res)=>{
console.log(res)
})
.catch((err)=>{
console.log(err)
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.