This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.第33章 共有メモリー
33.1. 概要
Linux には、System V と POSIX という 2 つのタイプの共有メモリーオブジェクトがあります。Pod のコンテナーは Pod インフラストラクチャーコンテナーの IPC namespace を共有し、System V 共有メモリーオブジェクトを共有できます。本書ではそれらが POSIX 共有メモリーオブジェクトを共有する方法についても説明します。
33.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: 1 - name: dshm emptyDir: medium: Memory containers: - image: kubernetes/pause name: hello-container1 ports: - containerPort: 8080 hostPort: 6061 volumeMounts: 2 - mountPath: /dev/shm name: dshm - image: kubernetes/pause name: hello-container2 ports: - containerPort: 8081 hostPort: 6062 volumeMounts: 3 - mountPath: /dev/shm name: dshm
---
apiVersion: v1
id: hello-openshift
kind: Pod
metadata:
name: hello-openshift
labels:
name: hello-openshift
spec:
volumes: 1
- name: dshm
emptyDir:
medium: Memory
containers:
- image: kubernetes/pause
name: hello-container1
ports:
- containerPort: 8080
hostPort: 6061
volumeMounts: 2
- mountPath: /dev/shm
name: dshm
- image: kubernetes/pause
name: hello-container2
ports:
- containerPort: 8081
hostPort: 6062
volumeMounts: 3
- mountPath: /dev/shm
name: dshm
Copy to clipboardCopiedshared-memory.yaml ファイルを使用して Pod を作成します。
oc create -f shared-memory.yaml
$ oc create -f shared-memory.yaml
Copy to clipboardCopied