본문 바로가기
OS/kubernetes

🥰 Kubernetes에서 PostgreSQL 공유 메모리 설정

by Knowledge Store In Hyunsoft 2024. 8. 25.

 

postgres의 공유메모리가  부족해서 오류가 발생하면 아래와 같이  shm-size를 늘려주면 됩니다.

 

 

docker 샘플

docker run --name my_postgres \
           --shm-size=1g \
           -e POSTGRES_PASSWORD=mysecretpassword \
           -d postgres

 

 

kubernetes 샘플

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:latest
        resources:
          requests:
            memory: "2Gi"
            cpu: "1"
          limits:
            memory: "4Gi"
            cpu: "2"
        volumeMounts:
        - mountPath: /dev/shm
          name: dshm
        env:
        - name: POSTGRES_PASSWORD
          value: "yourpassword"
      volumes:
      - name: dshm
        emptyDir:
          medium: Memory
          sizeLimit: 1Gi
728x90

댓글