# Persistent Volume 및 Persistent Volume Claim 정의
apiVersion: v1
kind: PersistentVolume
metadata:
  name: web-etc-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: web-etc
  hostPath:
    path: /mnt/data/etc  # 호스트 경로

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: web-etc-pvc
  namespace: poc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: web-etc

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: web-log-pv
spec:
  capacity:
    storage: 2Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: web-log
  hostPath:
    path: /mnt/data/logs  # 호스트 경로

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: web-log-pvc
  namespace: poc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
  storageClassName: web-log

---
# Next.js Deployment 및 Service 정의
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nextjs-deployment
  namespace: poc
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nextjs
  template:
    metadata:
      labels:
        app: nextjs
    spec:
      containers:
      - name: nextjs
        image: ablecloudteam/ablecloud-homepage:20240612  # 직접 빌드한 Next.js Docker 이미지
        ports:
        - containerPort: 3000
        volumeMounts:
        - mountPath: /etc/nextjs
          name: etc-volume
        - mountPath: /var/log/nextjs
          name: log-volume
      volumes:
      - name: etc-volume
        persistentVolumeClaim:
          claimName: web-etc-pvc
      - name: log-volume
        persistentVolumeClaim:
          claimName: web-log-pvc

---
apiVersion: v1
kind: Service
metadata:
  name: nextjs-service
  namespace: poc
spec:
  selector:
    app: nextjs
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000
  type: ClusterIP

