您可以将 configmap 作为卷挂载到 pod 中。
一个例子:
apiVersion: v1
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
env: prod
app: metis
client: ueuropea
name: metis-clients-configmap
data:
clients_db_config.yaml: |
default-tenant:
DB_HOST: dbhost
DB_USERNAME: user
DB_PASSWORD: pass
DB_NAME: dbname
DB_PORT: 3306
部署:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
env: dev
app: metis
name: metis-rules-evaluator-dev
spec:
progressDeadlineSeconds: 3600
replicas: 0
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
env: dev
app: metis
client: ueuropea
mode: rules-evaluator
spec:
containers:
- image: metis
name: metis
imagePullPolicy: Always
resources:
requests:
memory: "1024Mi"
cpu: "3000m"
limits:
memory: "16384Mi"
cpu: "4000m"
volumeMounts:
- name: config-vol
mountPath: /usr/src/metis/config/
volumes:
- name: config-vol
configMap:
name: metis-clients-configmap
terminationGracePeriodSeconds: 150
restartPolicy: Always
在本例中,configmap 数据将安装在 path: 上/usr/src/metis/config/
,并将创建clients_db_config.yaml
也可以是 .ini的文件