有些容器启动时需要通过volume,把配置文件塞进容器的肚子里。本例子中,要把一个README.txt
文件添加到容器中。
ConfigMap配置
apiVersion: v1kind: ConfigMapmetadata: name: playground-configmap namespace: "playground"data: readme: | 这是readme文件,请勿删除。复制代码
Pod配置
apiVersion: v1kind: Podmetadata: name: pod namespace: "playground" labels: app: "playground"spec: volumes: - name: configmap-volume configMap: name: playground-configmap items: - key: "readme" path: "README.txt" containers: - name: "app" image: "10.211.55.6:5000/yingzhuo/playground:latest" imagePullPolicy: Always ports: - containerPort: 8080 volumeMounts: - name: configmap-volume mountPath: "/config"复制代码