k8s configmap 掛載配置文件


轉自https://blog.csdn.net/weixin_34102807/article/details/85965725

1、新建ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-conf
  namespace: default
  labels:
    name: test-conf
data:
  test.properties: |
    db.url=jdbc:oracle:thin:@172.16.10.178:1521:orcl
    db.user=sz_res
    db.passwd=sz_res
  test2.properties: |
    xxxxxxxxxxxxxxxxxxxxxxxxxxxx

2、新建deployment

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test-app
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: test-app
    spec:
      containers:
        - name: test-container
          image: test/tomcat:v1
          imagePullPolicy: Always
          volumeMounts:
            - name: test
              mountPath: /usr/local/tomcat/webapps/test/WEB-INF/classes/test.properties
              subPath: path/to/test.properties
            - name: test2
              mountPath: /usr/local/tomcat/webapps/test/WEB-INF/classes/test2.properties
              subPath: path/to/test2.properties
      volumes:
        - name: test
          configMap:
            name: test-conf
            defaultMode: 0777
            items:
            - key: test.properties
              path: path/to/test.properties
        - name: test2
          configMap:
            name: test-conf
            items:
            - key: test2.properties
              path: path/to/test2.properties

掛載容器內部的文件的權限。(必須是介於0和0777(八進制)之間的數字,包括兩者在內)

其實我沒搞懂path/to/的意思
不過照着搬,的確好用,那就當作固定用法吧,


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM