17.2. 为批处理操作创建 ConfigMap
创建一个 ConfigMap
,以便其他文件(如 Data Grid 缓存配置)可用于批处理操作。
先决条件
为了进行演示,您应该在启动流程前将一些配置工件添加到主机文件系统中:
创建一个
/tmp/mybatch
目录,您可以在其中添加一些文件。mkdir -p /tmp/mybatch
创建数据网格缓存配置。
cat > /tmp/mybatch/mycache.xml<<EOF <distributed-cache name="mycache" mode="SYNC"> <encoding media-type="application/x-protostream"/> <memory max-count="1000000" when-full="REMOVE"/> </distributed-cache> EOF
流程
创建包含您要运行的所有命令的
批处理
文件。例如,以下
批处理
文件创建一个名为"mycache"的缓存,并为其添加两个条目:create cache mycache --file=/etc/batch/mycache.xml put --cache=mycache hello world put --cache=mycache hola mundo
重要ConfigMap
挂载于/etc/batch
的 Data Grid pod。您必须使用该路径在批处理操作中添加 all--file=
指令。确保您的批处理操作需要的所有配置工件与
批处理
文件位于同一个目录中。ls /tmp/mybatch batch mycache.xml
从目录中创建
ConfigMap
。oc create configmap mybatch-config-map --from-file=/tmp/mybatch