Chapter 5. Accessing an FTP server using Skupper
Securely connect to an FTP server on a remote Kubernetes cluster
This example is part of a suite of examples showing the different ways you can use Skupper to connect services across cloud providers, data centers, and edge sites.
Overview
This example shows you how you can use Skupper to connect an FTP client on one Kubernetes cluster to an FTP server on another.
It demonstrates use of Skupper with multi-port services such as FTP. It uses FTP in passive mode (which is more typical these days) and a restricted port range that simplifies Skupper configuration.
Prerequisites
-
The
kubectl
command-line tool, version 1.15 or later (installation guide) - Access to at least one Kubernetes cluster, from any provider you choose
Procedure
- Clone the repo for this example.
- Install the Skupper command-line tool
- Set up your namespaces
- Deploy the FTP server
- Create your sites
- Link your sites
- Expose the FTP server
- Clone the repo for this example. Navigate to the appropriate GitHub repository from https://skupper.io/examples/index.html and clone the repository.
Install the Skupper command-line tool
This example uses the Skupper command-line tool to deploy Skupper. You need to install the
skupper
command only once for each development environment.See the Installation for details about installing the CLI. For configured systems, use the following command:
sudo dnf install skupper-cli
sudo dnf install skupper-cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set up your namespaces
Skupper is designed for use with multiple Kubernetes namespaces, usually on different clusters. The
skupper
andkubectl
commands use your kubeconfig and current context to select the namespace where they operate.Your kubeconfig is stored in a file in your home directory. The
skupper
andkubectl
commands use theKUBECONFIG
environment variable to locate it.A single kubeconfig supports only one active context per user. Since you will be using multiple contexts at once in this exercise, you need to create distinct kubeconfigs.
For each namespace, open a new terminal window. In each terminal, set the
KUBECONFIG
environment variable to a different path and log in to your cluster. Then create the namespace you wish to use and set the namespace on your current context.NoteThe login procedure varies by provider. See the documentation for yours:
Public:
export KUBECONFIG=~/.kube/config-public # Enter your provider-specific login command kubectl create namespace public kubectl config set-context --current --namespace public
export KUBECONFIG=~/.kube/config-public # Enter your provider-specific login command kubectl create namespace public kubectl config set-context --current --namespace public
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Private:
export KUBECONFIG=~/.kube/config-private # Enter your provider-specific login command kubectl create namespace private kubectl config set-context --current --namespace private
export KUBECONFIG=~/.kube/config-private # Enter your provider-specific login command kubectl create namespace private kubectl config set-context --current --namespace private
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the FTP server
In Private, use
kubectl apply
to deploy the FTP server.Private:
kubectl apply -f server
kubectl apply -f server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
kubectl apply -f server
$ kubectl apply -f server deployment.apps/ftp-server created
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create your sites
A Skupper site is a location where components of your application are running. Sites are linked together to form a network for your application. In Kubernetes, a site is associated with a namespace.
For each namespace, use
skupper init
to create a site. This deploys the Skupper router and controller. Then useskupper status
to see the outcome.Public:
skupper init skupper status
skupper init skupper status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Private:
skupper init skupper status
skupper init skupper status
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow As you move through the steps below, you can use
skupper status
at any time to check your progress.Link your sites
A Skupper link is a channel for communication between two sites. Links serve as a transport for application connections and requests.
Creating a link requires use of two
skupper
commands in conjunction,skupper token create
andskupper link create
.The
skupper token create
command generates a secret token that signifies permission to create a link. The token also carries the link details. Then, in a remote site, Theskupper link create
command uses the token to create a link to the site that generated it.NoteThe link token is truly a secret. Anyone who has the token can link to your site. Make sure that only those you trust have access to it.
First, use
skupper token create
in site Public to generate the token. Then, useskupper link create
in site Private to link the sites.Public:
skupper token create ~/secret.token
skupper token create ~/secret.token
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
skupper token create ~/secret.token
$ skupper token create ~/secret.token Token written to ~/secret.token
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Private:
skupper link create ~/secret.token
skupper link create ~/secret.token
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
skupper link create ~/secret.token
$ skupper link create ~/secret.token Site configured to link to https://10.105.193.154:8081/ed9c37f6-d78a-11ec-a8c7-04421a4c5042 (name=link1) Check the status of the link using 'skupper link status'.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your terminal sessions are on different machines, you may need to use
scp
or a similar tool to transfer the token securely. By default, tokens expire after a single use or 15 minutes after creation.Expose the FTP server
In Private, use
skupper expose
to expose the FTP server on all linked sites.Private:
skupper expose deployment/ftp-server --port 21100 --port 21
skupper expose deployment/ftp-server --port 21100 --port 21
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
skupper expose deployment/ftp-server --port 21100 --port 21
$ skupper expose deployment/ftp-server --port 21100 --port 21 deployment ftp-server exposed as ftp-server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the FTP client
In Public, use
kubectl run
and thecurl
image to perform FTP put and get operations.Public:
echo "Hello!" | kubectl run ftp-client --stdin --rm --image=docker.io/curlimages/curl --restart=Never -- -s -T - ftp://example:example@ftp-server/greeting kubectl run ftp-client --attach --rm --image=docker.io/curlimages/curl --restart=Never -- -s ftp://example:example@ftp-server/greeting
echo "Hello!" | kubectl run ftp-client --stdin --rm --image=docker.io/curlimages/curl --restart=Never -- -s -T - ftp://example:example@ftp-server/greeting kubectl run ftp-client --attach --rm --image=docker.io/curlimages/curl --restart=Never -- -s ftp://example:example@ftp-server/greeting
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Sample output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow