Issue
Currently, the application that is running as a containerized K8 spins up a new K8 pod every time and the new pod tries to connect to an sftp server.
Somehow the new pod always fails to connect to the sftp server and times out. The instance or the IP address on which these pods are spun up has access to the sftp server and I am able to connect to the server using the command
sshpass -p password sftp user@ip-address
Every new pod tries to connect to the sftp server using the below script
transport = paramiko.Transport((host, 22))
transport.connect(username, assword, hostkey=None, pkey=none)
connect = paramiko.SFTPClient.from_transport(transport)
Every time a new pod spins up, a new IP address is assigned to the pod, and that IP will not be whitelisted in the sftp server for it to make authentication - I think this is why it's not working.
What changes has to be included in the new pod so that it is able to connect to the sftp server? Should I include the public key of the host in the config map of the pod so that it uses that to connect to sftp?
Solution
It was basically the security group issue. Once the subnet ranges are added to sec group, the pod was able to access the sftp server
Answered By - Harish Answer Checked By - David Marino (WPSolving Volunteer)