简体   繁体   English

如何从 Quarkus 的 application.properties 及其 helm extension 生成 kubernetes configmap?

[英]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.

相关问题 Spring 引导从 kube.netes configmap 中获取动态 application.properties - Spring boot pick up dynamic application.properties from kubernetes configmap 来自application.properties的Kubernetes服务解析 - Kubernetes Service Resolution from application.properties Dockerized Spring Boot 应用程序不使用挂载的 Kubernetes ConfigMap (application.properties) - Dockerized Spring Boot app not using mounted Kubernetes ConfigMap (application.properties) Spring 引导:覆盖来自 Kubernetes ConfigMap 的 application.yml 属性 - Spring Boot: override application.yml properties from Kubernetes ConfigMap 如何从安装为文件的 kubernetes 中填充 application.properties 文件值 - How to populate application.properties file value from kubernetes Secrets mounted as file 如何在 maven 构建期间从属性文件创建 kubernetes 配置映射? - How to create kubernetes configmap from properties file during maven build? 如何基于激活的弹簧配置文件从 kubernetes configMap 加载属性 - How to load properties from kubernetes configMap based on activated spring profiles kubernetes部署时同步application.properties - Synchronize application.properties when deploying in kubernetes configmap.yaml、deployment.yaml、configmap.yaml 和 application.properties 之间的区别 - Difference between configmap.yaml, deployment.yaml, configmap.yaml and application.properties 如何使用 helm 从目录创建 ConfigMap - How to create ConfigMap from directory using helm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM