Skip to content

Commit

Permalink
Migrate to Docker Compose V2 (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Motičák <[email protected]>
  • Loading branch information
pemoticak authored Jul 14, 2023
1 parent 7d72731 commit d480d0b
Show file tree
Hide file tree
Showing 23 changed files with 132 additions and 130 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,12 @@ documentation (`*.md`) and some examples to get you started.

#### Requirements

1. StoneWork requires an **Ubuntu VM** or a **bare-metal server** running Ubuntu, preferably version **18.04 (Bionic Beaver)**.
1. StoneWork requires an **Ubuntu VM** or a **bare-metal server** running Ubuntu, preferably version **20.04 (Focal Fossa)**.


2. Next, Docker and docker-compose must be installed.
2. Next, Docker and Docker Compose plugin must be installed.

Install with:
```
$ apt-get install docker.io docker-compose
```
Official manual for installing Docker and Docker Compose can be found [here][install-docker] and [here][install-compose] respectively.

3. **(DPDK Only)** Install/Enable Drivers

Expand Down Expand Up @@ -203,14 +200,14 @@ documentation (`*.md`) and some examples to get you started.


6. Finally, the StoneWork image has to be loaded so that
Docker/docker-compose/K8s is able to provision a container instance. Run:
Docker/Docker Compose/K8s is able to provision a container instance. Run:
```
$ docker load <./stonework.image
```

## Deployment

StoneWork is deployed using [Docker Compose][docker-compose] version 3.3 or
StoneWork is deployed using [Docker Compose][compose] version 3.3 or
newer. StoneWork itself is only a single container (with VPP and StoneWork agent
inside), but every CNF that is deployed alongside it runs in a **separate
container**, hence the use of Compose.
Expand Down Expand Up @@ -329,7 +326,9 @@ services:
[config-pdf]: docs/config/STONEWORK-CONFIG.pdf
[config-jsonschema]: docs/config/STONEWORK-CONFIG.jsonschema
[vscode-jsonschema]: https://dev.to/brpaz/how-to-create-your-own-auto-completion-for-json-and-yaml-files-on-vs-code-with-the-help-of-json-schema-k1i
[docker-compose]: https://docs.docker.com/compose/
[compose]: https://docs.docker.com/compose/
[install-docker]: https://docs.docker.com/engine/install/ubuntu/
[install-compose]: https://docs.docker.com/compose/install/linux/
[vpp]: https://wiki.fd.io/view/VPP
[ligato-vpp-agent]: https://github.com/ligato/vpp-agent
[cdnf-io]: https://cdnf.io/cnf_list/
Expand Down
4 changes: 2 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ StoneWork Architecture
CNF Integration
---------------

Each CNF remains to be packaged and delivered as a single docker image. The same image can be used to deploy the
Each CNF remains to be packaged and delivered as a single Docker image. The same image can be used to deploy the
CNF either as **Standalone** (i.e. inside a chain/mesh of CNFs) or as a **StoneWork Module** or *SW-Module* for short.

Simply by setting the environment variable `CNF_MODE` to `STANDALONE` or `STONEWORK_MODULE`, the CNF will either start
Expand All @@ -26,7 +26,7 @@ Instead, every CNF runs as a separate container from its own image, running its
manage the single, shared data-plane.

All (enabled) CNFs and the StoneWork itself are typically orchestrated by
*docker-compose*. To enable a new CNF feature is then as easy, as to add a container entry into *docker-compose.yaml*
*Docker Compose*. To enable a new CNF feature is then as easy, as to add a container entry into *docker-compose.yaml*
for the CNF, restart the deployment and let the StoneWork to discover it.

If a given CNF is never used, it doesn't have to be mentioned in *docker-compose.yaml*
Expand Down
2 changes: 1 addition & 1 deletion docs/CNF_HOW_TO.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ see the [StoneWork Architecture][architecture].
}
}
```
Then, inside dockerfile, call (replace `cnf-init` with the name of your init command):
Then, inside Dockerfile, call (replace `cnf-init` with the name of your init command):
```
RUN /usr/local/bin/cnf-init --print-spec > /api/models.spec.yaml
```
Expand Down
4 changes: 2 additions & 2 deletions docs/UPDATE_PROCEDURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ StoneWork is based on *vpp-agent* and thus supports stable VPP versions, support

Check whether `ligato/vpp-base`, with your desired version, already exists.

To do so, just look at `ligato/vpp-base` tags on [DockerHub][dockerhub-tags]. Or directly by docker pull command, for example:
To do so, just look at `ligato/vpp-base` tags on [DockerHub][dockerhub-tags]. Or directly by `docker pull` command, for example:
`docker pull ligato/vpp-base:23.06`

If there is no such tagged version, you need to create it.
Expand Down Expand Up @@ -75,7 +75,7 @@ found a compatible API.

## 2.5 Upload new tag for the StoneWork to image repository

StoneWork docker images are present on [GitHub Container Registry][ghcr].
StoneWork Docker images are present on [GitHub Container Registry][ghcr].

To update images, create and push a git tag into image repository according to
the following convention:
Expand Down
49 changes: 26 additions & 23 deletions docs/USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ StoneWork introduces a **complete routing platform**, based on VPP, running well

Dependencies
============
StoneWork requires an **Ubuntu VM** or a **bare-metal server** running Ubuntu, preferably version **20.04 (Focal Fossa)**.

Other required dependencies of StoneWork are Docker and Docker Compose plugin.

Official manual for installing Docker on Ubuntu can be found [here][install-docker] and for Docker Compose [here][install-compose].

First of all we need to install Docker and *docker-compose*:
```
$ apt-get install docker.io docker-compose
```
First Steps w/ StoneWork
========================

Expand All @@ -35,7 +36,7 @@ $ docker logs stonework
When working with StoneWork, it is useful to see the logs of control plane transactions. These are actions
done by StoneWork to set its dataplane - FD.io VPP.

By looking at the logs, it can be verified whether concrete transaction were successful or not.
By looking at the logs, it can be verified whether concrete transactions were successful or not.

To access the StoneWork container:
```
Expand Down Expand Up @@ -165,22 +166,22 @@ root@44480538e5b0:/# ip add
```
But this tap interface is present only inside our StoneWork container. What if we wanted to expose the tap to our host system?

Then we need to use host network mode in our docker run one liner:
Then we need to use host network mode in our `docker run` one liner:
```
$ docker run -it --rm --name stonework --privileged --network="host" -e ETCD_CONFIG="" ghcr.io/pantheontech/stonework:23.06
```
For more details about tap interfaces and VPP, take a look [at this example][tap-example].

docker-compose Manifest
=======================
Docker Compose File
===================

As our Docker run one-liner grows, it becomes better to use docker-compose, in terms of readability and maintainability.
As our `docker run` one-liner grows, it becomes better to use Docker Compose, in terms of readability and maintainability.

Lets rewrite the above mentioned docker run command, i.e.:
Lets rewrite the above mentioned `docker run` command, i.e.:
```
$ docker run -it --rm --name stonework --privileged --network="host" -e ETCD_CONFIG="" ghcr.io/pantheontech/stonework:23.06
```
into *docker-compose.yaml*:
into `docker-compose.yaml`:
```
version: '3.3'
Expand All @@ -195,22 +196,22 @@ services:
```
All of the fields should be obvious, as it is a 1-2-1 translation of the command we used so far.

The StoneWork docker container is then turned on/off by the following commands from the same directory as our docker-compose file is located:
The StoneWork Docker container is then turned on/off by the following commands from the same directory where our Docker Compose file is located:
```
$ docker-compose up -d
$ docker compose up -d
```
```
$ docker-compose down
$ docker compose down
```

AF_PACKET Interface
===================

Using this interface type, we can easily start using interfaces of the host system in StoneWork.

The downside of the af_packet interface is its performance, so it should be used mainly for testing purposes.
The downside of the AF_PACKET interface is its performance, so it should be used mainly for testing purposes.

To use the host interfaces using AF_PACKET, the same docker-compose.yaml can be used as the one for TAPs.
To use the host interfaces using AF_PACKET, the same `docker-compose.yaml` can be used as the one for TAPs.

Now, suppose we have an interface called ens33 and its MAC address is 00:0c:29:0a:93:4d.

Expand Down Expand Up @@ -248,10 +249,10 @@ Prerequisities
To enable DPDK interfaces in data plane, few specifics steps must be done, those are well described in the
[StoneWork README][readme] file, in the [Installation section.](/README.md#Installation)

docker-compose
Docker Compose
--------------

To enable DPDK interfaces, we will need to extend our docker-compose a bit more.
To enable DPDK interfaces, we will need to extend our Docker Compose file a bit more.
```
version: '3.3'
Expand Down Expand Up @@ -333,7 +334,7 @@ To do so, just uncomment the dpdk part of the config above.

An arbitrary amount of interfaces can be used.

If we now start the docker container, VPP will contain our new DPDK interface:
If we now start the Docker container, VPP will contain our new DPDK interface:
```
$ docker exec -it stonework vppctl show int
Name Idx State MTU (L3/IP4/IP6/MPLS) Counter Count
Expand Down Expand Up @@ -365,7 +366,7 @@ As probably obvious, this configuration is telling StoneWork to set the DPDK int

Now, it's time to wake up StoneWork:
```
$ docker-compose up -d
$ docker compose up -d
```
And to verify that everything was set properly in the data plane:
```
Expand Down Expand Up @@ -419,13 +420,13 @@ StoneWork Enterprise
With StoneWork Enterprise you'll get access to additional control plane features. Enterprise features are packaged
as container images. To use them you need a valid license.

First the CNF image must be loaded into docker as:
First the CNF image must be loaded into Docker as:
```
docker load -i <path/to/image/file>
```
Then, the `docker-compose.yaml` is updated.

Lets demonstrate it on cnf-bgp, this is how the new docker-compose will look like:
Lets demonstrate it on cnf-bgp, this is how the new Docker Compose file will look like:
```
version: '3.3'
Expand Down Expand Up @@ -494,7 +495,7 @@ The rest of environment variables have the same meaning as for StoneWork.

Now start the StoneWork with:
```
docker-compose up -d
docker compose up -d
```
And finally verify that the CNF was successfully discovered by examining the StoneWork logs as:
```
Expand Down Expand Up @@ -532,6 +533,8 @@ So the `cnf-bgp` introduces new root level entry called bgpConfig, to describe i
- **10.10.0.10/24** is some other BGP server to connect to and to exchange the routes with
- **memif-vrf1** is interface towards 10.10.0.10/24. Note, that not neccessarily directly to that network, there might be next hops in between

[install-docker]: https://docs.docker.com/engine/install/ubuntu/
[install-compose]: https://docs.docker.com/compose/install/linux/
[vpp-hugepages]: https://fd.io/docs/vpp/master/gettingstarted/users/configuring/hugepages.html
[vpp-startup]: https://my-vpp-docs.readthedocs.io/en/latest/gettingstarted/users/configuring/startup.html
[agentctl-link]: https://docs.ligato.io/en/latest/user-guide/agentctl/
Expand Down
20 changes: 10 additions & 10 deletions examples/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Deployment Description

This example consists of two YAML-formatted files:
- `docker-compose.yaml`: describes how to deploy the StoneWork container in the
[Docker-Compose][docker-compose] language. While in this example there is
[Docker Compose][compose-plugin] language. While in this example there is
only **one container** - StoneWork itself - it is still advised to take this
opportunity and learn how to work with docker-compose. Extending StoneWork's
opportunity and learn how to work with Docker Compose. Extending StoneWork's
feature-set with any of the CNFs from the PANTHEON.tech
[cloud-native network functions portfolio][cdnf-portfolio] requires deploying additional containers
alongside StoneWork, hence the use of *Compose*. The content of
Expand Down Expand Up @@ -60,7 +60,7 @@ Interacting with StoneWork

In order to deploy StoneWork, simply run (from within this directory):
```
$ docker-compose up -d
$ docker compose up -d
```
The StoneWork container should be present almost immediately:
```
Expand Down Expand Up @@ -101,7 +101,7 @@ rtt min/avg/max/mdev = 0.247/0.492/0.839/0.251 ms

Let's enter the VPP CLI:
```
$ docker-compose exec -it stonework vppctl
$ docker compose exec -it stonework vppctl
_______ _ _ _____ ___
__/ __/ _ \ (_)__ | | / / _ \/ _ \
_/ _// // / / / _ \ | |/ / ___/ ___/
Expand Down Expand Up @@ -147,7 +147,7 @@ StoneWork container.

Obtain the currently running configuration with:
```
$ docker-compose exec stonework agentctl config get 2>/dev/null
$ docker compose exec stonework agentctl config get 2>/dev/null
netallocConfig: {}
linuxConfig:
interfaces:
Expand Down Expand Up @@ -210,7 +210,7 @@ linuxConfig:
Remember, that the config dir is mounted into
the container under `/etc/stonework/config`. Apply the new, desired config with:
```
$ docker-compose exec stonework agentctl config update --replace /etc/stonework/config/new-config.yaml
$ docker compose exec stonework agentctl config update --replace /etc/stonework/config/new-config.yaml
```
Observe the performed config changes:
```
Expand All @@ -223,7 +223,7 @@ vpp: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 77 bytes 11885 (11.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ docker-compose exec stonework vppctl show interface address
$ docker compose exec stonework vppctl show interface address
local0 (dn):
tap0 (up):
L3 192.168.222.3/30
Expand Down Expand Up @@ -274,18 +274,18 @@ $ curl -v --header "Content-Type: application/yaml" --request PUT --data-binary
To observe what is happening behind the scenes and to debug any potential issues,
obtain StoneWork logs with:
```
$ docker-compose logs stonework
$ docker compose logs stonework
```

### Shutdown & Undeploy

Finally, to shutdown and undeploy StoneWork container, simply run:
```
$ docker-compose down
$ docker compose down
```


[docker-compose]: https://docs.docker.com/compose/
[compose-plugin]: https://docs.docker.com/compose/
[config]: ../../docs/config/STONEWORK-CONFIG.md
[readme]: ../../README.md
[cdnf-portfolio]: https://cdnf.io/cnf_list/
10 changes: 5 additions & 5 deletions examples/nat-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ Running the Example
Once the configuration is updated to match the actual environment, deploy
StoneWork using:
```
$ docker-compose up -d
$ docker compose up -d
```

Initially, only physical interfaces should be configured.

To verify this, run:
```
$ docker-compose exec stonework vppctl show interface address
$ docker compose exec stonework vppctl show interface address
gbe-private-net (up):
L3 192.168.1.1/24
gbe-public-net (up):
Expand All @@ -77,14 +77,14 @@ local0 (dn):

Explore the CLI provided by StoneWork:
```
$ docker-compose exec stonework agentctl --help
$ docker compose exec stonework agentctl --help
```

## Add & Enable NAT Config

For example, to **add and enable NAT configuration**, run:
```
$ docker-compose exec stonework agentctl config update /etc/stonework/config/add-nat-config.yaml
$ docker compose exec stonework agentctl config update /etc/stonework/config/add-nat-config.yaml
```
`add-nat-config.yaml` is mounted from `./config/add-nat-config.yaml`.

Expand All @@ -97,7 +97,7 @@ network should be able to access servers in the public network(s).

Observe the NAT in process using packet tracing on VPP (only `SYN` packet shown):
```
$ docker-compose exec stonework vpptrace.sh -i dpdk
$ docker compose exec stonework vpptrace.sh -i dpdk
00:04:40:604246: dpdk-input
gbe-private-net rx queue 0
Expand Down
Loading

0 comments on commit d480d0b

Please sign in to comment.