1、创建configmap
configmap文件内容
其中walletkey.properties: >-引用部分是文本内容
---
apiVersion: v1
data:
walletkey.properties: >-
wallet.keys.data[0].coin=bnb
wallet.keys.data[0].seed=abcdedfefeds
wallet.keys.data[0].type=eth
wallet.keys.data[1].coin=arb
wallet.keys.data[1].seed=abcdedfefeds
wallet.keys.data[1].type=eth
wallet.keys.data[2].coin=op
wallet.keys.data[2].seed=abcdedfefeds
wallet.keys.data[2].type=eth
wallet.keys.data[3].coin=matic
wallet.keys.data[3].seed=abcdedfefeds
wallet.keys.data[3].type=eth
wallet.keys.data[4].coin=sol
wallet.keys.data[4].seed=abcdedfefeds
wallet.keys.data[4].type=sol
wallet.keys.data[5].coin=btc
wallet.keys.data[5].seed=abcdedfefeds
wallet.keys.data[5].type=btc
kind: ConfigMap
metadata:
name: walletkey.properties
namespace: bitget
resourceVersion: '4866437'
创建configmap
kubectl create -f configmap.yaml
查看创建好的configmap
kubectl get configmap walletkey.properties -n bitget
2、挂载操作
A方案、yaml配置
配置文件内容如下
volumeMounts:
- mountPath: /data/walletkey.properties
name: volume-h77am
readOnly: true
subPath: walletkey.properties
volumes:
- configMap:
defaultMode: 420
items:
- key: walletkey.properties
path: walletkey.properties
name: walletkey.properties
name: volume-h77am
B方案、kuboard控制台操作
3、进入容器后我们可以看到我们的文本内容
root@wallet-597c57d89c-z6hvz:/data# ls /data/
data logs wallet-core.jar wallet-core.uuid walletkey.properties
root@wallet-core-597c57d89c-z6hvz:/data# cat /data/walletkey.properties
wallet.keys.data[0].coin=bnb
wallet.keys.data[0].seed=abcdedfefeds
wallet.keys.data[0].type=eth
wallet.keys.data[1].coin=arb
wallet.keys.data[1].seed=abcdedfefeds
wallet.keys.data[1].type=eth
wallet.keys.data[2].coin=op
wallet.keys.data[2].seed=abcdedfefeds
wallet.keys.data[2].type=eth
wallet.keys.data[3].coin=matic
wallet.keys.data[3].seed=abcdedfefeds
wallet.keys.data[3].type=eth
wallet.keys.data[4].coin=sol
wallet.keys.data[4].seed=abcdedfefeds
wallet.keys.data[4].type=sol
wallet.keys.data[5].coin=btc
wallet.keys.data[5].seed=abcdedfefeds
wallet.keys.data[5].type=btc
如果我们有多个文件需要这样挂载的话,我们可以操作如下
volumeMounts:
- mountPath: /data/leaf.properties
name: volume-zhma7
subPath: leaf.properties
- mountPath: /data/bootstrap.yml
name: volume-zhma7
subPath: bootstrap.yml
workingDir: /data
volumes:
- configMap:
defaultMode: 420
items:
- key: leaf.properties
path: leaf.properties
- key: bootstrap.yml
path: bootstrap.yml
name: leaf.properties
name: volume-zhma7
kuboard挂载方式
然后启动的时候可以
java -Dspring.config.location=/data/leaf.properties -jar yourapp.jar