インフラ系SEの技術メモ

雑なエンジニアが低信頼性のメモを書いています。参考程度にとどめてください。

(Kubernetes)複数コンテナで同一ストレージを共有する

一例

以下のようにボリュームを2つのコンテナで共有すれば別のイメージから同じデータが見れます。

apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
    restartPolicy: Never
    containers:
     - name: getdata
       image: test
       command: ["データ取得系"]
       volumeMounts:
       - name: test
         mountPath: /dump
     - name: putdata
       image: test
       command: ["データを送付系"]
       volumeMounts:
       - name: test
         mountPath: /dump
    volumes:
    - name: test
      emptyDir: {}

emptyDirにしているのNode上の領域を使うため、これが嫌なら外部ディスクを使うべきですね。