码迷,mamicode.com
首页 > 其他好文 > 详细

k8s configmap 挂载配置文件

时间:2021-01-22 11:43:56      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:inf   ntp   jdb   data   mod   href   webapps   default   https   

转自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/的意思
不过照着搬,的确好用,那就当作固定用法吧,

k8s configmap 挂载配置文件

标签:inf   ntp   jdb   data   mod   href   webapps   default   https   

原文地址:https://www.cnblogs.com/faberbeta/p/14307258.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!