refactor storage minio for k8s
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN pip install --no-cache-dir uv
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -14,6 +14,7 @@ docker_build(
|
||||
'mpr-fastapi',
|
||||
context='..',
|
||||
dockerfile='Dockerfile',
|
||||
ignore=['.git', 'def', 'docs', 'media', 'ui', 'gpu', 'modelgen', '.claude', 'tests'],
|
||||
live_update=[
|
||||
sync('..', '/app'),
|
||||
],
|
||||
|
||||
@@ -32,10 +32,10 @@ spec:
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests:
|
||||
memory: 128Mi
|
||||
cpu: 100m
|
||||
limits:
|
||||
memory: 512Mi
|
||||
cpu: 500m
|
||||
limits:
|
||||
memory: 2Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
@@ -5,8 +5,10 @@ metadata:
|
||||
namespace: mpr
|
||||
data:
|
||||
S3_ENDPOINT_URL: http://minio:9000
|
||||
S3_BUCKET_IN: mpr-media-in
|
||||
S3_BUCKET_OUT: mpr-media-out
|
||||
S3_BUCKET: mpr
|
||||
S3_PREFIX_IN: in/
|
||||
S3_PREFIX_OUT: out/
|
||||
S3_PREFIX_CHECKPOINTS: checkpoints/
|
||||
AWS_ACCESS_KEY_ID: minioadmin
|
||||
AWS_SECRET_ACCESS_KEY: minioadmin
|
||||
AWS_REGION: us-east-1
|
||||
@@ -54,9 +56,7 @@ spec:
|
||||
- -c
|
||||
- |
|
||||
sleep 3
|
||||
for bucket in mpr-media-in mpr-media-out; do
|
||||
mkdir -p /data/$bucket
|
||||
done
|
||||
mkdir -p /data/mpr/in /data/mpr/out /data/mpr/checkpoints
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
|
||||
12
ctrl/k8s/kind-config.yaml.tpl
Normal file
12
ctrl/k8s/kind-config.yaml.tpl
Normal file
@@ -0,0 +1,12 @@
|
||||
kind: Cluster
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
name: mpr
|
||||
nodes:
|
||||
- role: control-plane
|
||||
extraPortMappings:
|
||||
- containerPort: 30080
|
||||
hostPort: 80
|
||||
protocol: TCP
|
||||
extraMounts:
|
||||
- hostPath: ${MEDIA_HOST_PATH}
|
||||
containerPath: /mnt/media
|
||||
@@ -3,6 +3,7 @@ kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../../base
|
||||
- minio-pvc.yaml
|
||||
|
||||
patches:
|
||||
# Gateway as NodePort for local access
|
||||
@@ -28,3 +29,40 @@ patches:
|
||||
- op: add
|
||||
path: /spec/ports/0/nodePort
|
||||
value: 30379
|
||||
|
||||
# MinIO with persistent storage + host media mount for seeding.
|
||||
# PV survives pod restarts. Host mount is read-only for mc mirror seeding.
|
||||
# Requires kind cluster created with MEDIA_HOST_PATH extraMount (see kind-create.sh).
|
||||
- target:
|
||||
kind: Deployment
|
||||
name: minio
|
||||
patch: |
|
||||
- op: replace
|
||||
path: /spec/template/spec/volumes/0
|
||||
value:
|
||||
name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: minio-data
|
||||
- op: add
|
||||
path: /spec/template/spec/containers/0/volumeMounts/-
|
||||
value:
|
||||
name: host-media
|
||||
mountPath: /host-media
|
||||
readOnly: true
|
||||
- op: add
|
||||
path: /spec/template/spec/volumes/-
|
||||
value:
|
||||
name: host-media
|
||||
hostPath:
|
||||
path: /mnt/media
|
||||
type: DirectoryOrCreate
|
||||
- op: replace
|
||||
path: /spec/template/spec/containers/0/lifecycle/postStart/exec/command
|
||||
value:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
until curl -sf http://localhost:9000/minio/health/live; do sleep 1; done
|
||||
/usr/bin/mc alias set local http://localhost:9000 minioadmin minioadmin --quiet
|
||||
/usr/bin/mc mb --ignore-existing local/mpr
|
||||
/usr/bin/mc cp --recursive /host-media/mpr/out/ local/mpr/out/ --quiet || true
|
||||
|
||||
11
ctrl/k8s/overlays/dev/minio-pvc.yaml
Normal file
11
ctrl/k8s/overlays/dev/minio-pvc.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: minio-data
|
||||
namespace: mpr
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
12
ctrl/kind-create.sh
Executable file
12
ctrl/kind-create.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# Create the kind cluster with host media mount.
|
||||
# Usage: MEDIA_HOST_PATH=/home/you/mpr/media ./kind-create.sh
|
||||
set -euo pipefail
|
||||
|
||||
: "${MEDIA_HOST_PATH:?Set MEDIA_HOST_PATH to your local media directory (e.g. /home/you/mpr/media)}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
CONFIG_TPL="$SCRIPT_DIR/k8s/kind-config.yaml.tpl"
|
||||
|
||||
envsubst < "$CONFIG_TPL" | kind create cluster --config -
|
||||
echo "Cluster 'mpr' created with media mount: $MEDIA_HOST_PATH → /mnt/media"
|
||||
Reference in New Issue
Block a user