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.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 26. Shared Memory
26.1. Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
There are two types of shared memory objects in Linux: System V and POSIX. The containers in a pod share the IPC namespace of the pod infrastructure container and so are able to share the System V shared memory objects. This document describes how they can also share POSIX shared memory objects.
26.2. POSIX Shared Memory 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
POSIX shared memory requires that a tmpfs be mounted at /dev/shm. The containers in a pod do not share their mount namespaces so we use volumes to provide the same /dev/shm into each container in a pod. The following example shows how to set up POSIX shared memory between two containers.
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
Create the pod using the shared-memory.yaml file:
oc create -f shared-memory.yaml
$ oc create -f shared-memory.yaml