1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
[root@k8s-master lab7]# kubectl get configmap NAME DATA AGE map 1 16m [root@k8s-master lab7]# kubectl get configmap -o yaml apiVersion: v1 items: - apiVersion: v1 data: configmap.md: | <<<<<<<<<<<<< 作为key 引用时候这是key名称,作为volumemount时候这是文件名 hahahahah <<<<<<<<<<<<<key的value或文件里的内容 kind: ConfigMap metadata: creationTimestamp: 2018-08-08T10:15:16Z name: map namespace: default resourceVersion: "137633" selfLink: /api/v1/namespaces/default/configmaps/map uid: f2540927-9af3-11e8-8140-000c29850765 kind: List metadata: resourceVersion: "" selfLink: "" [root@k8s-master lab7]# cat mysql-configmap.yaml apiVersion: v1 kind: Pod metadata: name: mysql spec: containers: - name: mysql image: mysql:5.5 env: - name: MYSQL_ROOT_PASSWORD valueFrom: configMapKeyRef: name: map key: configmap.md <<<<<<<<<<<<<<<<<<<<<<<<<key是文件名 imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /configmappath name: map volumes: - name: map configMap: name: map <<<<<<<<volume挂载configmap中的data里的所有内容,一个key就对应一个文件 restartPolicy: Always |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@k8s-master lab7]# kubectl exec -it mysql bash root@mysql:/# pwd / root@mysql:/# ls bin boot configmappath dev docker-entrypoint-initdb.d entrypoint.sh etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@mysql:/# cd configmappath/ root@mysql:/configmappath# ls configmap.md <<<<<<<<<<<<<<<<<<<<<<<<<mount进来的文件名 root@mysql:/configmappath# more configmap.md hahahahah <<<<<<<<<<<<<<<<<<<<<<<<<文件里面的内容 root@mysql:/configmappath# env HOSTNAME=mysql KUBERNETES_PORT_443_TCP_PROTO=tcp KUBERNETES_PORT_443_TCP_ADDR=10.250.0.1 MYSQL_ROOT_PASSWORD=hahahahah <<<<<<<<<<<<<<<<<<<<<<<<<Key内容作为环境变量值 KUBERNETES_PORT=tcp://10.250.0.1:443 PWD=/configmappath HOME=/root MYSQL_MAJOR=5.5 GOSU_VERSION=1.7 KUBERNETES_SERVICE_PORT_HTTPS=443 KUBERNETES_PORT_443_TCP_PORT=443 MYSQL_VERSION=5.5.61 KUBERNETES_PORT_443_TCP=tcp://10.250.0.1:443 TERM=xterm SHLVL=1 KUBERNETES_SERVICE_PORT=443 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/mysql/bin:/usr/local/mysql/scripts KUBERNETES_SERVICE_HOST=10.250.0.1 _=/usr/bin/env OLDPWD=/ |
文章评论