Pod无法连接到FTP服务

时间:2020-04-14 15:24:55

标签: openshift okd

问题:从CLI(cli)成功连接到ftp服务时,来自(openshift)pod的python脚本失败。 环境如下。

  1. OKD v3.11(1个主节点+ 3个工作节点)
  2. 所有节点:Centos 7.7
  3. 主节点(ip xx.xx.xx.55)如下安装FTP并通过端口20,21启用iptables
public class LogLine
{
    public readonly string Message;

    public readonly object[] Params;

    public static implicit operator LogLine(string message)
    {
        return new LogLine(message ?? string.Empty);
    }

    public LogLine(string message, params object[] @params)
    {
        Message = message;
        Params = @params;
    }
}
[centos@xxx-master ~]$ ftp localhost
Trying ::1...
Connected to localhost (::1).
220 (vsFTPd 3.0.2)
Name (localhost:centos): xxxxxxxx
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

来自python脚本的FTP,pod无法连接到ftp

root@waxxx-7798748f8-lk2wk:/wxxxx_py3# ftp xx.xx.xx.55
Connected to xx.xx.xx.55.
220 (vsFTPd 3.0.2)
Name (xx.xx.xx.55:root): xxxxxxxx
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> bye

该代码是与ftp的简单连接

root@waxxx-7798748f8-lk2wk:/wxxxx_py3# python ftps.py
listing directory
Traceback (most recent call last):
  File "ftps.py", line 6, in <module>
    server.dir()
  File "/usr/local/lib/python3.5/ftplib.py", line 576, in dir
    self.retrlines(cmd, func)
  File "/usr/local/lib/python3.5/ftplib.py", line 469, in retrlines
    with self.transfercmd(cmd) as conn, \
  File "/usr/local/lib/python3.5/ftplib.py", line 400, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/local/lib/python3.5/ftplib.py", line 362, in ntransfercmd
    source_address=self.source_address)
  File "/usr/local/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/local/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host

从okd集群中的docker容器中观察到相同的脚本,将连接到FTP,这令人困惑,因为只有okd pod的脚本无法访问FTP。 此Pod中的相同脚本将连接到此OKD群集之外的另一台托管自己的FTP服务的计算机。

0 个答案:

没有答案
相关问题