首页 > 解决方案 > 使用 K8S / Minikube 安装本地 FTP 服务器,并使用 Filezilla 访问它

问题描述

我正在尝试基于此 repo使用 Kubernetes 安装 FTP 服务器。

我也使用 Traefik 作为 Ingress。

一切似乎都很好,我可以将 FTP 服务器与 cluster-ip 连接,但我无法使其与 ftp.local 之类的本地域一起使用

这是我的 K8S 文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    reloader.stakater.com/auto: "true"
  labels:
    app: ftp-local
  name: ftp-local
  namespace: influx
spec:
  selector:
    matchLabels:
      app: ftp-local
  strategy:
    type: Recreate
  replicas: 1
  template:
    metadata:
      labels:
        app: ftp-local
    spec:
      containers:
      - name: ftp-local
        image: fauria/vsftpd
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 21
          protocol: TCP
          name: "ftp-server"
        volumeMounts:
        - mountPath: "/home/vsftpd"
          name: task-pv-storage
        env:
        - name: FTP_USER
          value: "sunchain"
        - name: FTP_PASS
          value: "sunchain"
        #- name: PASV_ADDRESS
        #  value: "127.0.0.1"
        #- name: PASV_MIN_PORT
        #  value: "21100"
        #- name: PASV_MAX_PORT
        #  value: "21110"
      volumes:
      - name: task-pv-storage
        persistentVolumeClaim:
          claimName: task-pv-claim
---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: task-pv-claim
  namespace: influx
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: task-pv-volume
  namespace: influx
  labels:
    type: local
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/tmp/data"
---
apiVersion: v1
kind: Service
metadata:
  name: ftp-local
  namespace: influx
  labels:
    app: ftp-local
spec:
  ports:
  - name: "21"
    port: 21
    targetPort: 21
  selector:
    app: ftp-local
  type: NodePort
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ftp-ingress
  namespace: influx
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: ftp.local
    http:
      paths:
      - backend:
         serviceName: ftp-local
         servicePort: 21

我在 /etc/hosts 中也有这样一行:

127.0.0.1      ftp.local

我错过了什么?

标签: kubernetesftpkubernetes-ingress

解决方案


起初,您使用的回购链接是在2-3 年前创建/更新的。

许多最新的 Kubernetes 功能都需要SSL通信。这就是为什么SFTP更容易在 Kubernetes 中应用的原因。另一件事,您使用Minikube--driver=none有一些限制。此处描述了有关none驱动程序的所有必要信息。

这个线程中已经有关于 FTP Filezilla 的类似问题。

作为解决方法,您可以考虑使用hostPortor hostNetwork

许多配置方面取决于您要使用Acitve 还是 Passive FTP

FTP 需要两个 TCP 连接才能工作。第二个连接是使用随机端口建立的。我看起来与Services概念不兼容。SFTP只需要一个连接。

作为另一种解决方案,您可以考虑使用SFTP. 您可以在网络上找到许多文章,其中包含使用 SFTP 而不是 FTP 更好的信息。例如Tibco 文档这篇文章

您可以使用 OpenSSH 查看有关 SFTP 服务器的信息并尝试这个 github SFTP 示例

在这里您可以找到使用SFTPin 的信息FileZilla


推荐阅读