[root@master01 ~]# cat conf/nginx.conf 
sladkld;kdl;sakdl;askl;dsakl;

创建一个configmap

[root@master01 ~]# kubectl create configmap  test-daemo1 --from-file=conf
[root@master01 ~]# kubectl describe configmaps test-daemo1 
Name:         test-daemo1
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
nginx.conf:
----
sladkld;kdl;sakdl;askl;dsakl;

Events:  <none>

挂载进去

apiVersion: v1
kind: Pod
metadata:
  name: testcm1-pod
spec:
  containers:
    - name: testcm1
      image: busybox
      command: [ "/bin/sh", "-c" ]
      args: ["ls /etc; cat /etc/nginx.conf " ]
      volumeMounts:
      - name: config-volume
        mountPath: /etc/nginx.conf
        subPath: nginx.conf
  volumes:
    - name: config-volume
      configMap:
        name: test-daemo1
        items:
        - key: nginx.conf
          path: nginx.conf

·查看结果

[root@master01 testvolume]# kubectl apply -f . 
[root@master01 testvolume]# kubectl logs testcm1-pod 
group
hostname
hosts
localtime
mtab
network
nginx.conf
passwd
resolv.conf
shadow
sladkld;kdl;sakdl;askl;dsakl;