32.2. POSIX 共有メモリー
POSIX 共有メモリーでは、tmpfs が /dev/shm にマウントされる必要があります。Pod のコンテナーはそれらのマウント namespace を共有しないため、ボリュームを使用して同じ /dev/shm を Pod の各コンテナーに提供します。以下の例では、2 つのコンテナー間で POSIX 共有メモリーをセットアップする方法を示しています。
shared-memory.yaml
--- apiVersion: v1 id: hello-openshift kind: Pod metadata: name: hello-openshift labels: name: hello-openshift spec: volumes: - name: dshm emptyDir: medium: Memory containers: - image: kubernetes/pause name: hello-container1 ports: - containerPort: 8080 hostPort: 6061 volumeMounts: - mountPath: /dev/shm name: dshm - image: kubernetes/pause name: hello-container2 ports: - containerPort: 8081 hostPort: 6062 volumeMounts: - mountPath: /dev/shm name: dshm
---
apiVersion: v1
id: hello-openshift
kind: Pod
metadata:
name: hello-openshift
labels:
name: hello-openshift
spec:
volumes:
- name: dshm
emptyDir:
medium: Memory
containers:
- image: kubernetes/pause
name: hello-container1
ports:
- containerPort: 8080
hostPort: 6061
volumeMounts:
- mountPath: /dev/shm
name: dshm
- image: kubernetes/pause
name: hello-container2
ports:
- containerPort: 8081
hostPort: 6062
volumeMounts:
- mountPath: /dev/shm
name: dshm
shared-memory.yaml ファイルを使用して Pod を作成します。
oc create -f shared-memory.yaml
$ oc create -f shared-memory.yaml