当使用 operatorsdk构建运营商:GO 框架时,我们最终创建了Kubernetes资源,例如部署
,服务
等,通过利用K8S模块/软件包的结构来编程。与以YAML/JSON格式创建这些清单相比,这很麻烦,需要大量编码。对清单的任何更改都需要更改代码,并且需要推出操作员的新版本。
我想知道现有的模板/覆盖工具(例如Helm或Kustomize)是否可以用于在操作员代码中构建这些K8S资源。这也将使您可以将清单/模板文件与操作员代码外部化。我找不到任何很好的例子,说明如何将这些工具用作GO程序中的模块/库。请提供任何指示,建议或替代方法。
相关问题: kubernetes操作员使用yaml Template创建部署 您可以读取YAML文件并将其删除到部署对象中。在这里,我仍然需要在操作员内编码模板/覆盖逻辑。
While building operators using OperatorSDK: Go framework, we end up creating Kubernetes resources such Deployments
, Services
etc programmatically by leveraging structs from k8s modules/packages. Compared to creating these manifests in yaml/json formats, this is quite cumbersome and requires quite a bit of coding. And any changes to the manifest would require code changes and the new version of the operator needs to be rolled out.
I am wondering whether existing templating/overlay tools such as Helm or Kustomize can be used for building these k8s resources within the operator code. This would also enable you to externalise the manifest/template files from the operator code. I couldn't find any good examples of how these tools can be used as modules/libraries within a Go program. Please provide any pointers, suggestions or alternate approaches.
Related question: Kubernetes operator create Deployment using yaml template
This talks about how you can read a yaml file and unmarshal it into a Deployment object. Here, I would still need to code templating/overlay logic within the operator.
发布评论
评论(1)
您可以通过编程使用掌舵发动机,通过调用。
You can use the helm engine programmatically, by calling engine.Render.