Kubernetes PropertySource implementations
在 Kubernetes 环境中,启用此覆盖需要将 spring.config.import 属性设置为 "kubernetes:"。Spring Cloud Kubernetes 会加载名称与应用程序名称匹配的 ConfigMap 和机密。如果没有设置应用程序名称,则会加载名称为 application 的 ConfigMap 和机密。
还可以通过添加 spring-cloud-starter-bootstrap 到类路径或设置 spring.cloud.bootstrap.enabled=true 来在引导阶段加载 Kubernetes PropertySource。
配置 Spring Boot 应用程序最常见的方法是创建一个 application.properties
或 application.yaml
或 application-profile.properties
或 application-profile.yaml
文件,其中包含为你的应用程序或 Spring Boot 初学者提供自定义值的键值对。你可以通过指定系统属性或环境变量来覆盖这些属性。
The most common approach to configuring your Spring Boot application is to create an application.properties
or application.yaml
or
an application-profile.properties
or application-profile.yaml
file that contains key-value pairs that provide customization values to your
application or Spring Boot starters. You can override these properties by specifying system properties or environment
variables.
要启用此功能,你需要将 spring.config.import
应用程序配置属性设为 kubernetes:
(在使用 yaml 时用引号转义,例如 "kubernetes:"
)。当前你无法使用 spring.config.import
指定要加载的 ConfigMap 或机密,默认情况下,Spring Cloud Kubernetes 将根据 spring.application.name
属性加载 ConfigMap 和/或机密。如果未设置 spring.application.name
,它将加载名称为 application
的 ConfigMap 和/或机密。
To enable this functionality you need to set the spring.config.import
application configuration property to kubernetes:
(escape with quotes when using yaml eg. "kubernetes:"
).
Currently you can not specify a ConfigMap or Secret to load using spring.config.import
, by default Spring Cloud Kubernetes
will load a ConfigMap and/or Secret based on the spring.application.name
property. If spring.application.name
is not set it will
load a ConfigMap and/or Secret with the name application
.
如果你想将 Kubernetes PropertySource`s during the bootstrap phase like it worked prior to the 3.0.x release
you can either add `spring-cloud-starter-bootstrap
加载到应用程序的类路径或将 spring.cloud.bootstrap.enabled=true
设置为环境变量。
If you would like to load Kubernetes PropertySource`s during the bootstrap phase like it worked prior to the 3.0.x release
you can either add `spring-cloud-starter-bootstrap
to your application’s classpath or set spring.cloud.bootstrap.enabled=true
as an environment variable.