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
- Prerequisites
- Step 1: Install the Skupper Ansible collection
- Step 2: Install the Skupper command-line tool
- Step 3: Set up your clusters
- Step 4: Inspect the inventory file
- Step 5: Run the setup playbook
- Step 6: Access the frontend
- Step 7: Run the teardown playbook
- Next steps
- About this example
This example is a variant of Skupper Hello World that is deployed using the Skupper Ansible collection.
It contains two services:
-
A backend service that exposes an
/api/hello
endpoint. It returns greetings of the formHi, <your-name>. I am <my-name> (<pod-name>)
. -
A frontend service that sends greetings to the backend and fetches new greetings in response.
In this scenario, each service runs in a different Kubernetes cluster. The frontend runs in a namespace on cluster 1 called West, and the backend runs in a namespace on cluster 2 called East.
Skupper enables you to place the backend in one cluster and the frontend in another and maintain connectivity between the two services without exposing the backend to the public internet.
-
The
kubectl
command-line tool, version 1.15 or later (installation guide) -
Access to at least one Kubernetes cluster, from any provider you choose
- Ansible, version 2.14 or later (installation guide)
Use the ansible-galaxy
command to install the
skupper.network
collection.
Terminal:
ansible-galaxy collection install skupper.network
The Skupper Ansible collection uses the Skupper command-line tool to deploy Skupper.
On Linux or Mac, you can use the install script (inspect it here) to download and extract the command:
curl https://skupper.io/install.sh | sh
The script installs the command under your home directory. It prompts you to add the command to your path if necessary.
For Windows and other installation options, see Installing Skupper.
This example uses two clusters. The clusters are accessed using two kubeconfig files:
<project-dir>/ansible/kubeconfigs/east
<project-dir>/ansible/kubeconfigs/west
For each kubeconfig, set the KUBECONFIG
environment variable
to the file path and run the login command for your cluster.
This updates the kubeconfig with the required credentials.
Note: The cluster login procedure varies by provider. See the documentation for yours:
- Minikube
- Amazon Elastic Kubernetes Service (EKS)
- Azure Kubernetes Service (AKS)
- Google Kubernetes Engine (GKE)
- IBM Kubernetes Service
- OpenShift
Terminal:
cd <project-dir>
export KUBECONFIG=$PWD/ansible/kubeconfigs/west
# Enter your provider-specific login command for cluster 1
export KUBECONFIG=$PWD/ansible/kubeconfigs/east
# Enter your provider-specific login command for cluster 2
Before we start running commands, let's examine the inventory file. It's here that we can define Skupper sites, links, and exposed services.
all:
vars:
ansible_connection: local
hosts:
west:
kubeconfig: "{{ inventory_dir }}/kubeconfigs/west"
namespace: west
east:
kubeconfig: "{{ inventory_dir }}/kubeconfigs/east"
namespace: east
links:
- host: west
services:
backend:
ports:
- 8080
targets:
- type: deployment
name: backend
Our example has two sites, West and East, enumerated under
hosts
.
The links
attribute on host east
defines a link from East to West.
The services
attribute on host east
exposes the backend on
East so the frontend in West can access it.
The playbooks that follow use this inventory data to set up and tear down the Skupper network.
For more information about inventory files, see the Ansible inventory guide.
Now let's look at the setup playbook.
- hosts: west
tasks:
- command: "kubectl apply -f {{ playbook_dir }}/kubernetes/west.yaml"
- hosts: east
tasks:
- command: "kubectl apply -f {{ playbook_dir }}/kubernetes/east.yaml"
- hosts: all
collections:
- skupper.network
tasks:
- import_role:
name: skupper
The two kubectl
tasks deploy our example application.
The last task is to use the skupper
role from the
skupper.network
collection to deploy the Skupper network.
Use the ansible-playbook
command to run the playbook:
Terminal:
ansible-playbook -i ansible/inventory.yml ansible/setup.yml
Sample output:
$ ansible-playbook -i ansible/inventory.yml ansible/setup.yml
[...]
PLAY RECAP *********************************************************************************************
west : ok=34 changed=12 unreachable=0 failed=0 skipped=69 rescued=0 ignored=0
east : ok=34 changed=13 unreachable=0 failed=0 skipped=69 rescued=0 ignored=0
In order to use and test the application, we need external access to the frontend.
Use kubectl port-forward
to make the frontend available at
localhost:8080
.
Terminal:
export KUBECONFIG=$PWD/ansible/kubeconfigs/west
kubectl port-forward deployment/frontend 8080:8080
You can now access the web interface by navigating to http://localhost:8080 in your browser.
To clean everything up, run the teardown playbook.
- hosts: all
collections:
- skupper.network
tasks:
- import_role:
name: skupper_delete
- hosts: west
tasks:
- command: "kubectl delete -f {{ playbook_dir }}/kubernetes/west.yaml"
- hosts: east
tasks:
- command: "kubectl delete -f {{ playbook_dir }}/kubernetes/east.yaml"
The skupper_delete
role from the skupper.network
collection
removes all the Skupper resources.
Terminal:
ansible-playbook -i ansible/inventory.yml ansible/teardown.yml
Sample output:
$ ansible-playbook -i ansible/inventory.yml ansible/teardown.yml
[...]
PLAY RECAP *********************************************************************************************
west : ok=9 changed=2 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
east : ok=9 changed=2 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
Check out the other examples on the Skupper website.
This example was produced using Skewer, a library for documenting and testing Skupper examples.
Skewer provides utility functions for generating the README and
running the example steps. Use the ./plano
command in the project
root to see what is available.
To quickly stand up the example using Minikube, try the ./plano demo
command.