简体   繁体   English

如何从 Kubernetes Javascript 客户端创建作业和机密

[英]How to create a Job and a secret from Kubernetes Javascript Client

I am trying to work my way into the kubernetes javascript client .我正在尝试进入kubernetes javascript 客户端

My goal is to create a Job and a secret from inside the cluster.我的目标是从集群内部创建一个作业和一个秘密。

The kubernetes javascript client provide examples on how to create a in-cluster config and make simples API calls, but the generated documentation is no big help if you want to interact with other kubernetes objects (Jobs and Secret in my case)... The kubernetes javascript client provide examples on how to create a in-cluster config and make simples API calls, but the generated documentation is no big help if you want to interact with other kubernetes objects (Jobs and Secret in my case)...

The documentation reference all the classes, but that's all.文档引用了所有类,仅此而已。

So, do you have already worked with the Kubernetes javascript client?那么,您是否已经使用过 Kubernetes javascript 客户端? Is there a more precise documentation or more examples?是否有更精确的文档或更多示例? (I wasn't succesful in my reshearsh) (我的排练没有成功)

Or, do you know how to create Jobs/Secret from the Client?或者,您知道如何从客户端创建作业/秘密吗?

I Won't post my code here, because I only made the in-cluster config, it's only a copy from the repo example.我不会在这里发布我的代码,因为我只制作了集群内配置,它只是来自 repo 示例的副本。

Thanks a Lot in advance: :)提前非常感谢::)

So, after a little meddling with the Kubernetes Javascript Client and with the help of the commentary of @François I found what I was looking to achieve.因此,在稍微干预了Kubernetes Javascript 客户端并在@François 的评论的帮助下,我找到了我想要实现的目标。

The documentation of the K8s javascript client is very "minimal", an the best way to see what is possible is using a good Code Editor (Code for me). K8s javascript 客户端的文档非常“最小”,查看可能的最佳方法是使用好的代码编辑器(Code for me)。

Based on this example you see the createNamespacedIngress, and all the other K8s object linked with the CoreV1Api are created with the same nomenclature.根据示例,您会看到 createNamespacedIngress,并且与 CoreV1Api 链接的所有其他 K8s object 都是使用相同的命名法创建的。

If you want to create an object that is not managed by the CoreV1Api, you need to use the makeApiClient method on the Api you need to interacy with.如果要创建一个不受 CoreV1Api 管理的 object,则需要在需要交互的 Api 上使用 makeApiClient 方法。

So, for creating a Job, I needed to use the BatchV1Api.因此,为了创建作业,我需要使用 BatchV1Api。

I'll try to upload an example on the Javasript client repo, to maybe, help more poor lost souls like me.我将尝试在 Javasript 客户端 repo 上上传一个示例,以帮助更多像我这样可怜的失落灵魂。 Snippet of the code:代码片段:

const k8sCoreV1Api = kc.makeApiClient(k8s.CoreV1Api); // we call the CoreV1Api that will be used for the creation of the secrets

const k8sBatchV1Api = kc.makeApiClient(k8s.BatchV1Api);常量 k8sBatchV1Api = kc.makeApiClient(k8s.BatchV1Api); //we call the BatchV1Api that will be used for the creation of the jobs //我们调用将用于创建作业的 BatchV1Api

Here is the whole sample here: https://pastebin.com/FXWA17RQ这里是整个示例: https://pastebin.com/FXWA17RQ

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 kubernetes-client javascript - 从 cronjob 创建作业 - kubernetes-client javascript - create job from cronjob 如何使用 javascript 客户端创建 Kubernetes 自定义资源 - How do I create a Kubernetes Custom Resource using javascript client 如何为 Kubernetes nodejs API 客户端从 Z6EEDC273A68A62D7C733 文件生成“V1Job” object? - How can I generate a `V1Job` object for the Kubernetes nodejs API client from a yaml file? 为什么从Javascript获得OAuth不需要客户端密码? - Why isn't the client secret needed for OAuth from Javascript? 使用客户端Javascript时如何保持API密钥的秘密? - How to keep API keys secret when using client side Javascript? IdentityServer3和使用Javascript的隐式流-如何处理client_secret - IdentityServer3 & Implicit flow with Javascript - How is client_secret handled createDeployment() 与 Kube.netes JavaScript 客户端 - createDeployment() with Kubernetes JavaScript client 如何在没有任何用户的情况下从Azure AD应用程序中使用Javascript在SPFX或Sharepoint页面中使用client_id和client_secret从Azure AD应用程序读取访问令牌? - How to read the access token without any user from Azure AD Application using client_id and client_secret in SPFX or Sharepoint Page using Javascript? 如何在客户端使用javascript从HTML标签创建图像? - How to create image from HTML tags using javascript at client end? 将 Stripe Client Intent Secret 传递给 Javascript - Passing Stripe Client Intent Secret to Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM