zoukankan      html  css  js  c++  java
  • k8s容器挂载配置文件

    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(八进制)之间的数字,包括两者在内)

  • 相关阅读:
    防火墙实践
    提高工作效率的小技巧
    网络系统参数配置
    linux 文件截取
    python (1) 还不是大全的小问题
    iptables 命令记录
    网络常用端口
    HTTP时间指标
    错误集锦
    access数据库调用
  • 原文地址:https://www.cnblogs.com/boshen-hzb/p/8310275.html
Copyright © 2011-2022 走看看