如何将外部yml配置文件添加到Kubernetes配置映射中
我在配置文件夹(即console-service.yml)中有一个配置文件。我正在尝试使用configMap在运行时加载,下面是我的部署yml:如何将外部yml配置文件添加到Kubernetes配置映射中,kubernetes,Kubernetes,我在配置文件夹(即console-service.yml)中有一个配置文件。我正在尝试使用configMap在运行时加载,下面是我的部署yml: kind: Deployment apiVersion: apps/v1 metadata: name: consoleservice spec: replicas: 1 template: metadata: labels: app: consoleservice spec: con
kind: Deployment
apiVersion: apps/v1
metadata:
name: consoleservice
spec:
replicas: 1
template:
metadata:
labels:
app: consoleservice
spec:
containers:
- name: consoleservice
image: docker.example.com/app:1
volumeMounts:
- name: console-config-volume
mountPath: /config/console-server.yml
subPath: console-server.yml
readOnly: true
volumes:
- name: console-config-volume
configMap:
name: console-config
kind: ConfigMap
apiVersion: v1
metadata:
name: consoleservice
data:
pool.size.core: 1
pool.size.max: 16
我不熟悉配置地图。如何从
config/
位置读取.yml配置?有两种可能的解决方案
1。将文件直接嵌入到ConfigMap中这看起来可能类似于:
kind: ConfigMap
apiVersion: v1
metadata:
name: some-yaml
file.yaml: |
pool:
size:
core: 1
max: 16
2。从YAML文件创建配置映射将通过使用kubectl完成:
kubectl create configmap some-yaml \
--from-file=./some-yaml-file.yaml
这将创建包含所选文件的ConfigMap。您可以将多个文件添加到单个ConfigMap
您可以找到。您的问题有两种可能的解决方案 1。将文件直接嵌入到ConfigMap中
这看起来可能类似于:
kind: ConfigMap
apiVersion: v1
metadata:
name: some-yaml
file.yaml: |
pool:
size:
core: 1
max: 16
2。从YAML文件创建配置映射将通过使用kubectl完成:
kubectl create configmap some-yaml \
--from-file=./some-yaml-file.yaml
这将创建包含所选文件的ConfigMap。您可以将多个文件添加到单个ConfigMap
您可以找到。看起来您正在创建一个名为
consoleservice
的配置映射,但在部署中引用了console config
。看起来您正在创建一个名为consoleservice
的配置映射,但在部署中引用了console config