spring-boot - 从 K8s configmap 读取时,Spring Boot Actuator 端点不显示属性值
问题描述
我正在尝试查看我在项目中拥有的一些自定义属性application.yml
。
meanwhileinhell:
myproject:
myserver:
security:
users:
- username: user1
password: "{noop}password1"
roles:
- USER
- username: user2
password: "{noop}password2"
roles:
- USER
services:
- "service-the-first"
- "another-service"
我在 Kubernetes 集群中运行我的系统,在安装过程中,我使用以下命令configmap
为每个项目创建 s :application.yml
kubectl create configmap <project> --from-file "<project>/src/main/resources/application.yml"
在我正在运行的系统上查看这些配置图,我可以看到所有的值都在那里。
这些属性绑定到 Kotlin 类:
@ConstructorBinding
@ConfigurationProperties("meanwhileinhell.myproject.myserver.security")
class SecurityUsersProperties(val users: List<User>)
data class User(val username: String, val password: String, val roles: List<String>)
@ConstructorBinding
@ConfigurationProperties("meanwhileinhell.myproject.myserver")
class ServiceNameProperties(val services: List<String>)
然后在几个配置类中启用:
@EnableConfigurationProperties(ServiceNameProperties::class)
笔记!在课堂
SecurityUsersProperties::class
上启用 。WebSecurityConfig
这些值都已成功加载,因为我可以在需要的地方使用凭据登录,并监控该特定服务列表。
我的问题是当我尝试查看actuator/configprops
端点上的属性时。我可以看到属性名称列表,但是当我单击展开值时,它们不会显示。
contexts:
application-1:
beans:
meanwhileinhell.myproject.myserver.security-com.meanwhileinhell.myproject.myserver.security.properties.SecurityUsersProperties:
properties:
users:
inputs:
users:
0:
roles:
0:
origin: "\"meanwhileinhell.myproject.myserver.security.users[0].roles[0]\" from property source \"bootstrapProperties-configmap.myserver.default\""
1:
roles:
0:
origin: "\"meanwhileinhell.myproject.myserver.security.users[1].roles[0]\" from property source \"bootstrapProperties-configmap.myserver.default\""
在这种情况下,只roles:
显示,没有username
或 (sanitised) password
。如果我搜索我的服务列表也是如此:
contexts:
application-1:
beans:
meanwhileinhell.myproject.myserver.services-com.meanwhileinhell.myproject.myserver.health.properties.ServiceNameProperties:
properties:
services:
inputs:
services:
0:
origin: "\"meanwhileinhell.myproject.myserver.services[0]\" from property source \"bootstrapProperties-configmap.myserver.default\""
1:
origin: "\"meanwhileinhell.myproject.myserver.services[1]\" from property source \"bootstrapProperties-configmap.myserver.default\""
在我的 rootbuild.gradle.kts
中,我在所有服务上启用了执行器端点:
implementation("org.springframework.boot:spring-boot-starter-actuator")
有什么我遗漏的东西可以显示我的属性吗?
更新
我的env
执行器端点现在似乎正在工作,并显示我的用户名和(经过清理的)密码以及角色。但是,configprops
仍然没有显示它们,只有roles
上面提到的那些。
解决方案
推荐阅读
- web-scraping - Python 请求 - 无法获得 POST 表单响应(仅返回表单)
- node.js - 无法使用适用于 Node.js 的 Admin SDK 在 Firebase 存储中将 Content-Disposition 覆盖为“内联”
- php - 未使用 mysqli_real_escape_string() 在表单提交方法中获取数组值
- c# - HttpRootDirectory 的嵌入式资源文件夹路径
- sql - 以更短的方式从日期时间检索分钟
- jxl - jxlsx - GridCommand 传递方法
- java - 如果我在 spring 的 common 类中编写所有依赖项怎么办?它会导致实时现场项目中的内存问题吗?
- mysql - MySQL 将字符串转换为 varbinary
- python - Matlab和Python中的浮点数有什么区别?
- mysql - 基于上次更新的组的 SQL 查询