笔记分享 | Note Share No matter where I am, I will reply you immediately when I see the email.My Email: echo "YUBzYW1lZ28uY29tCg==" | base64 -d
应用程序部署的信息和程序进行模块分离
volume
形式挂载成容器内的文件或目录configmap
# 创建 configmap
➜ kubectl create configmap one.json --from-file=/Users/alicfeng/demo/configmap/one.json
configmap/one.json created
➜ kubectl create configmap one.json --from-file=/Users/alicfeng/demo/configmap/one.ini
configmap/one.json created
# 查看 configmap
➜ kubectl get configmap
NAME DATA AGE
one.ini 1 43m
one.json 1 43m
# 查看具体 configmap
➜ kubectl describe configmap one.ini
Name: one.ini
Namespace: default
Labels: <none>
Annotations: <none>
Data
====
one.ini:
----
name=alicfeng
Events: <none>
apiVersion: v1
kind: Pod
metadata:
name: web
labels:
name: web
spec:
containers:
- name: socket
image: alicfeng/web:socket
ports:
- containerPort: 5200
volumeMounts:
# 挂载目录
- name: config
mountPath: /var/www/config
# 映射挂载文件
- name: one-ini
mountPath: /var/www/config/one.ini
subPath: one.ini
readOnly: True
- name: one-json
mountPath: /var/www/config/one.json
subPath: one.json
readOnly: True
volumes:
# 声明主机目录
- name: config
hostPath:
path: /Users/alicfeng/demo/configmap/config
# 声明定义configMap
- name: one-ini
configMap:
name: one.ini
- name: one-json
configMap:
name: one.json
假设运行失败 kubectl describe 查看具体日志
# 创建 pod
➜ configmap kubectl create -f demo.yaml
pod/web created