下午好,我需要帮助定义生产集群的结构,我想要类似的东西。
但是,如果对于每个POD,我都有将连接到客户数据库的env vars这样的话,我将如何做这样的结构
env:
- name: dbuser
value: "svc_iafox_test@***"
- name: dbpassword
value: "****"
- name: dbname
value: "ts-demo1"
- name: dbconnectstring
value: "jdbc:sqlserver://***-test.database.windows.net:1433;database=$(dbname);user=$(dbuser);password=$(dbpassword);encrypt=true;trustServerCertificate=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;"
所以对于每个吊舱,我都必须更改这些env变量...反正我这样做的最佳方法是什么?
答案 0 :(得分:0)
您可以使用configmap来实现:
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "echo $(SPECIAL_LEVEL_KEY) $(SPECIAL_TYPE_KEY)" ]
env:
- name: SPECIAL_LEVEL_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_LEVEL
- name: SPECIAL_TYPE_KEY
valueFrom:
configMapKeyRef:
name: special-config
key: SPECIAL_TYPE
restartPolicy: Never
ps。我认为每个pod 1个部署是没有道理的。每个客户进行1次部署。我认为您不完全了解部署的功能:https://kubernetes.io/docs/concepts/workloads/controllers/deployment/