Deployment API
.
|-- Makefile
|-- README.md
|-- docker-compose.yml
`-- src
|-- deploymentagent # Code and tests for the deployment agent
`-- podman # Podman inside of Docker replicating behavior on the live server for local testing
Accepts a deployment specification to produce a deployment state file.
Setup
This project makes use of gitlab.com/infektcommon/settings, in order to be able to build it locally with Docker, you will need to provide the path to an ssh private key with access to Gitlab in the Makefile, like so:
$ cat Makefile
IMAGE=deploymentagent
VERSION=latest
KEY_NAME=/home/user/.ssh/my-key
Testing
Launch the testing environment
make build
make run
Launch unit tests in a separate shell
make test
Cleanup after you are done
Removes dangling containers and volumes
make clean
Data formats
Deployment specification
[
{
"app" : "foo",
"version" : "latest"
},
{
"app" : "bar",
"version" : "latest"
}
]
If the same app is specified multiple times, the last entry in the list takes precedence.
Deployment state
{
"foo": "latest",
"bar": "latest"
}
The deployment state file is intended to be read by Nix, which will produce a systemd unit file that configures the Podman container.
Commands
curl -u'testuser:testpass' -i -XPOST localhost:8080/deploy -d '[{"app":"alpine", "version": "3.12"}]'
{"Message": "Queued for deployment", "DeploymentId": "1609855921147639"}
curl -u'testuser:testpass' -XGET localhost:8080/status | json_pp
[
{
"Id": 1609855921147639,
"Status": "queued",
"StatusMessage": "Queued for deployment",
"DeploymentSpec": [
{
"app": "alpine",
"version": "3.12"
}
],
"DeploymentState": null
}
]
.. deployment in progress ..
curl -u'testuser:testpass' -XGET localhost:8080/status | json_pp
[
{
"Id": 1610356267147639,
"Status": "deployed",
"StatusMessage": "Deployment successful",
"DeploymentSpec": [
{
"app": "alpine",
"version": "3.12"
}
],
"DeploymentState": {
"alpine": "3.12"
}
}
]
curl -u'testuser:testpass' -i -XPOST localhost:8080/deploy -d '[{"app":"alpine", "version": "latest"}, {"app":"busybox", "version": "latest"}]'
[
{
"Id": 1610356267147639,
"Status": "deployed",
"StatusMessage": "Deployment successful",
"DeploymentSpec": [
{
"app": "alpine",
"version": "3.12"
}
],
"DeploymentState": {
"alpine": "3.12"
}
},
{
"Id": 1610356267266631,
"Status": "deployed",
"StatusMessage": "Deployment successful",
"DeploymentSpec": [
{
"app": "alpine",
"version": "latest"
},
{
"app": "busybox",
"version": "latest"
}
],
"DeploymentState": {
"alpine": "latest",
"busybox": "latest"
}
}
]
To test with api, web, filestore, html2pdf, the Podman container would need to be authenticated with the Gitlab registry of the glv5 project.