[英]How to generate kubernetes configmap from the Quarkus `application.properties` with its `helm extension`?
How to have the properties of Quarkus application.properties
be available as configmap or environment variable in the Kubernetes container?如何让 Quarkus
application.properties
的属性在 Kubernetes 容器中作为 configmap 或环境变量可用?
The quarkus provides helm and kubernetes extensions to generate resources (yaml) during the build, which can be used to deploy the application in kubernetes. quarkus 提供 helm 和 kubernetes 扩展在构建过程中生成资源(yaml),可用于在 kubernetes 中部署应用。 However this extension does not elaborate the ways to generate the configmap to hold the application properties set in the
application.properties
.但是,此扩展并未详细说明生成配置映射以保存在 application.properties 中设置的
application.properties
程序属性的方法。 The site too does not give directions on it.该网站也没有给出指示。
This is the purpose of the Kubernetes Config extension.这是Kubernetes 配置扩展的目的。 Basically, after adding the Kubernetes Config, Kubernetes, and Helm extensions to your Maven/Gradle configuration, you need first to enable it by adding the following properties to your application properties:
基本上,在将 Kubernetes 配置、Kubernetes 和 Helm 扩展添加到 Maven/Gradle 配置之后,您首先需要通过将以下属性添加到应用程序属性来启用它:
quarkus.kubernetes-config.enabled=true
quarkus.kubernetes-config.config-maps=app-config
With these two properties, Quarkus will try to load the config map named app-config
at startup as config source.有了这两个属性,Quarkus 将在启动时尝试加载名为
app-config
的配置 map 作为配置源。
Where is the ConfigMap named app-config
?名为
app-config
的 ConfigMap 在哪里? You need to write it on your own and write the application properties there, for example:您需要自己编写并在那里编写应用程序属性,例如:
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
application.properties: |
hello.message=Hello %s from configmap
and then add the content at the file src/main/kubernetes/kubernetes.yml
.然后在
src/main/kubernetes/kubernetes.yml
文件中添加内容。 (Note that the name of the file must be kubernetes.yml
and the folder src/main/kubernetes
). (注意文件名必须是
kubernetes.yml
和文件夹src/main/kubernetes
)。 More information is in this link .更多信息在这个链接中。
The Kubernetes extension will aggregate the resources within the file src/main/kubernetes/kubernetes.yml
into the generated target/kubernetes/kubernetes.yml
(you will notice your configmap is there). Kubernetes 扩展会将文件
src/main/kubernetes/kubernetes.yml
中的资源聚合到生成的target/kubernetes/kubernetes.yml
(您会注意到您的 configmap 在那里)。
And finally, the Helm extension will inspect the target/kubernetes
folder and create the Helm chart templates accordingly.最后,Helm 扩展将检查
target/kubernetes
文件夹并相应地创建 Helm 图表模板。
You can checkout a complete example in this link .您可以在此链接中查看完整示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.