Bootstraping resource managers/orchestrators (k8s, swarm, openstack…)#



Prerequisites#

Make sure you’ve run the one time setup for your environment

An example of how a complex application can be bootstraped.

Swarm / Death Star Bench#

DeathStarBench is a micro-service app built for benchmarking purpose (see the academic paper)

One of its flavor comes packaged as a docker stack that you can deploy on a docker swarm. The purpose of the following is to show you how a docker swarm can be bootstraped using EnOSlib and how DeathStarBench can be deployed on Grid’5000.

The spare some physical resources we first to go with virtual machines.

Get some resources#

[ ]:
import enoslib as en

# Enable rich logging
_ = en.init_logging()


# claim the resources
conf = (
    en.VMonG5kConf
    .from_settings(job_name="enoslib_providers")
    .add_machine(
        roles=["swarm"],
        cluster="paravance",
        number=10,
        flavour="large"
    )
    .finalize()
)


provider = en.VMonG5k(conf)

roles, networks = provider.init()

roles

Install some dependencies#

[ ]:
registry_opts = dict(type="external", ip="docker-cache.grid5000.fr", port=80)


d = en.Docker(
    agent=roles["swarm"],
    bind_var_docker="/tmp/docker",
    registry_opts=registry_opts,
    swarm=True
)
d
[ ]:
d.deploy()
[ ]:
# install some of the deathstar's requirements
with en.actions(roles=roles) as a:
    a.pip(name="aiohttp", state="present")
    a.apt(name=["libssl-dev", "libz-dev", "liblua5.2-dev", "luarocks", "git"], state="present", update_cache=True)
    a.shell("luarocks install luasocket")
    a.git(repo="https://github.com/delimitrou/DeathStarBench.git", dest="/tmp/dsb")

Start DeathStarBench#

[ ]:
# start dsb
r = en.run_command("docker stack deploy --compose-file=docker-compose-swarm.yml social", roles=roles["swarm"][0], chdir="/tmp/dsb/socialNetwork")
[ ]:
print(f"""
Access the UI at {roles['swarm'][0].address}:8080")
---
tip1: create a ssh port forwarding -> ssh -NL 8080:{roles['swarm'][0].address}:8080 access.grid5000.fr (and point your browser to http://localhost:8080)
tip2: use a proxy socks -> ssh -ND 2100 access.grid5000.fr (and point your browser to http://{roles['swarm'][0].address}:8080)
tip3: use the G5K vpn
""")
[ ]:
n.destroy()
[ ]:
# cleanup
provider.destroy()

K3S#

K3s is a lightweight K8s distribution. For instance it’s supposed to run on constrained hardware.

For an (heavyweight) deployment of K8s, you can check enos-kubernetes.

Get some resources#

[ ]:
import enoslib as en

# Enable rich logging
_ = en.init_logging()


# claim the resources
conf = (
    en.VMonG5kConf
    .from_settings(job_name="enoslib_providers")
    .add_machine(
        roles=["master"],
        cluster="paravance",
        number=1,
        flavour="large"
    )
    .add_machine(
        roles=["agent"],
        cluster="paravance",
        number=10,
        flavour="large"
    )
    .finalize()
)


provider = en.VMonG5k(conf)

roles, networks = provider.init()

roles
[ ]:
# wait for the nodes
en.wait_for(roles)

Deploy K3s#

[ ]:
k3s = en.K3s(master=roles["master"], agent=roles["agent"])

k3s.deploy()

Accessing the dashboard

The dashboard should be reachable at http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/node?namespace=default see below for creating a tunnel

[ ]:
print("Create a tunnel from your local machine to the head node:")
print(f"ssh -NL 8001:{roles['master'][0].address}:8001 access.grid5000.fr")

Cleanup#

[ ]:
provider.destroy()

Openstack#

see EnOS.

[ ]: