spring-boot - Kubernetes Configmap 数据格式
问题描述
我正在为我的 Spring Boot 应用程序编写一个 K8s 配置映射。这是我的 application.yaml 文件:
app:
config:
paths:
- id: a
uri: http://localhost:8080
args:
- x=1
- y=2
- id: b
uri: http://localhost:8081
args:
- x=3
- y=4
我尝试将其转换为 Kubernetes configmap,如下所示(我遵循此文档https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0):
apiVersion: v1
kind: ConfigMap
metadata:
name: my-configmap
data:
app.config.paths_0_id: a
app.config.paths_0_uri: "http://a-service"
app.config.paths_0_args_0_: "x=1"
app.config.paths_0_args_1_: "y=2"
app.config.paths_1_id: b
app.config.paths_1_uri: "http://b-service"
app.config.paths_1_args_0_: "x=3"
app.config.paths_1_args_1_: "y=4"
在部署文件中我定义了 configmap:
...
envFrom:
- configMapRef:
my-configmap
...
但是当我部署我的应用程序时,它不起作用,configmap没有覆盖application.yaml,例如:app.config.paths的第一个uri仍然是http ://localhost:8080而不是http://a-服务。
所以有人有这方面的经验,请帮助我!如何在 K8S configmap 中定义数组?
谢谢
解决方案
推荐阅读
- javascript - javascript - 将对象数组中的 2 个对象合并为一个对象
- python - 裁剪图像后转换 Numpy 数组
- angular - Atlassian Bamboo 无法发布工件
- reactjs - 使用状态钩子触发一系列事件
- javascript - Electron - ipcRenderer 在 main.js 中不起作用
- mysql - 如何将 mysql 距离查询转换为 Laravel Eloquent 查询?- (带有纬度、经度和半径参数)
- python - 为什么python认为“自我”是一个论点
- scala - 是否可以在 Scala 3 中使用类似于打字稿映射类型的另一种类型来包装成员类型?
- python - 使用 QuantLib Python 使用 Heston 模型对亚洲期权定价
- java - 尝试更新多张图片。如果我更新单个图像但更新两个或多个图像,则下面的代码有效