You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes节点多存储访问:Minecraft服务器FTP配置及存储疑问

Answers to Your Minecraft + FTP on Kubernetes Questions

Hey there! Let's break down your two questions one by one to get you sorted out—you're already doing great with your StatefulSet setup for Minecraft, so we just need to tweak things a bit for FTP access.

1. Building the Lightest Possible Docker FTP Image

Python-based images work in a pinch, but using a dedicated FTP server like vsftpd on Alpine is way more lightweight: smaller footprint, fewer unnecessary dependencies, and purpose-built for FTP. Here's a minimal Dockerfile you can use to build your own tiny image:

FROM alpine:latest

# Install vsftpd and configure basic secure settings
RUN apk add --no-cache vsftpd && \
    mkdir -p /var/run/vsftpd/empty && \
    echo "anonymous_enable=NO" >> /etc/vsftpd/vsftpd.conf && \
    echo "local_enable=YES" >> /etc/vsftpd/vsftpd.conf && \
    echo "write_enable=YES" >> /etc/vsftpd/vsftpd.conf && \
    echo "chroot_local_user=YES" >> /etc/vsftpd/vsftpd.conf && \
    echo "allow_writeable_chroot=YES" >> /etc/vsftpd/vsftpd.conf && \
    echo "pasv_enable=YES" >> /etc/vsftpd/vsftpd.conf && \
    echo "pasv_min_port=21100" >> /etc/vsftpd/vsftpd.conf && \
    echo "pasv_max_port=21110" >> /etc/vsftpd/vsftpd.conf && \
    echo "listen=YES" >> /etc/vsftpd/vsftpd.conf

# Create a local user for FTP access (adjust username/password to your needs)
RUN adduser -D ftpuser && echo "ftpuser:your-secure-password" | chpasswd

# Expose required FTP ports (21 for control, 21100-21110 for passive mode)
EXPOSE 21 21100-21110

# Start the FTP server
CMD ["/usr/sbin/vsftpd", "/etc/vsftpd/vsftpd.conf"]

Build it with docker build -t lightweight-ftp ., push it to your registry, and you've got an image that's well under 100MB—way lighter than any Python-based alternative.

2. Accessing Volumes Used by Minecraft Pods

Looking at your PVC config, you're using accessModes: [ "ReadWriteOnce" ] (RWO). This mode means the volume can only be mounted read-write by a single Pod on a single node. So if your Minecraft Pod is running and using the config volume, another standalone FTP Pod can't mount it unless you stop the Minecraft Pod first. But there are way better alternatives to avoid downtime:

Option 1: Switch to ReadWriteMany (RWX) Volumes (Best if Supported)

If your Kubernetes cluster's storage class supports ReadWriteMany (RWX)—like NFS, CephFS, or cloud-based shared storage—update your PVCs to use this access mode:

# In your volumeClaimTemplates for config/world/logs
spec:
  accessModes: [ "ReadWriteMany" ]

With RWX, multiple Pods (Minecraft and FTP) can mount the same volume at the same time. Just deploy your FTP Pod as a separate Deployment, mount the config volume, and you're set without any downtime.

Option 2: Add FTP as a Sidecar to Your Minecraft StatefulSet (No Downtime, No RWX Needed)

Instead of running a separate FTP Pod, add an FTP container directly to your Minecraft StatefulSet's Pod template. Containers in the same Pod share the same volume mounts, so the FTP sidecar will have full access to /config while Minecraft runs. Here's how to modify your existing StatefulSet YAML:

# Inside spec.template.spec.containers (add this alongside your lapitos container)
- name: ftp-sidecar
  image: your-registry/lightweight-ftp:latest # Use the image you built earlier
  volumeMounts:
    - name: config
      mountPath: /home/ftpuser/config # Mount config to the FTP user's home for easy access
  ports:
    - containerPort: 21
      name: ftp
    - containerPort: 21100
      name: ftp-passv-start
    - containerPort: 21110
      name: ftp-passv-end

Don't forget to update your Service to expose FTP ports for external access:

# In your Service spec.ports
- name: ftp
  port: 21
  protocol: TCP
  targetPort: 21
- name: ftp-passv-range
  port: 21100
  protocol: TCP
  targetPort: 21100
  # For LoadBalancer, you might need to map the full passive port range or use NodePort

This is my top recommendation—it keeps everything tied together, no separate Pod management, and zero downtime for your Minecraft server.

Option 3: Scripted Pod Coordination (Last Resort)

If you can't use RWX or sidecars, you'd need a script to:

  1. Scale your Minecraft StatefulSet down to 0 replicas (stopping the Pod and releasing the volume)
  2. Deploy/scale up your FTP Pod to mount the volume
  3. After you're done, scale down the FTP Pod and restart Minecraft
    This works but causes server downtime, so only use it if the other options aren't feasible.

内容的提问来源于stack exchange,提问作者sfxworks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:36:05