resource-marathon-deploy
![License](http://img.shields.io/:license-mit-blue.svg)
resource-marathon-deploy
is a Concourse resource type that deploys an APP to
Marathon using a .json file.
resource-marathon-deploy Docker Image
on DockerHub.
resource-marathon-deploy GitHub Webpage
DEVELOPED
Written in GO, resource-marathon-deploy
was used as a test to help develop marathon-resource
.
This resource was built using resource-template
.
SOURCE CONFIGURATION
marathonuri
: The uri of marathon.
BEHAVIOR
CHECK (a resource version(s))
CHECK will mimic getting the list of versions from a resource.
CHECK stdin
{
"source": {
"source1": "sourcefoo1",
"source2": "sourcefoo2"
},
"version": {
"ref": "123 ",
}
}
123 is the current version.
CHECK stdout
[
{ "ref": "123" },
{ "ref": "3de" },
{ "ref": "456" }
]
456 is the latest version that will be used.
The last number 456 will become the current ref version that will be used by IN.
CHECK - go run
echo '{
"params": {"param1": "Hello Clif","param2": "Nice to meet you"},
"source": {"source1": "sourcefoo1","source2": "sourcefoo2"},
"version":{"ref": "123"}}' |
go run main.go check $PWD
IN (fetch a resource)
IN will mimic fetching a resource and placing a file in the working directory.
IN Parameters
IN stdin
{
"source": {
"source1": "sourcefoo1",
"source2": "sourcefoo2"
},
"params": {
"param1": "Hello Clif",
"param2": "Nice to meet you"
},
"version": {
"ref": "456",
}
IN stdout
{
"version":{ "ref": "456" },
"metadata": [
{ "name": "nameofmonkey", "value": "Larry" },
{ "name": "author","value": "Jeff DeCola" }
]
}
IN file fetched (fetch.json)
The IN will mimic a fetch and place a fake file fetched.json
file in the working directory:
IN - go run
echo '{
"params": {"param1": "Hello Clif","param2": "Nice to meet you"},
"source": {"source1": "sourcefoo1","source2": "sourcefoo2"},
"version":{"ref": "777"}}' |
go run main.go in $PWD
OUT (update a resouce)
OUT shall delploy an APP to marathon based on marathon.json file.
Create a marathon .json file. As an example:
{
"id": "appname",
"cpus": 0.1,
"mem": 16.0,
"container": {
"type": "DOCKER",
"docker": {
"forcePullImage": true,
"image": "jeffdecola/hello-go:latest",
"network": "BRIDGE",
"portMappings": [{
"containerPort": 8080,
"hostPort": 0
}]
}
}
}
OUT Parameters
app_json_path
: the path to your newly created marathon .json file.
OUT stdin
{
"params": {
"app_json_path": "hello-go/app.json",
},
"source": {
"marathonuri": "http://10.141.141.10:808",
},
"versions": {
"ref": ""
}
}
OUT stdout
{
"version":{ "ref": "(timestamp of when marathon started)" },
"metadata": [
{ "name": "????????????","value": "????????????" },
]
}
OUT - go run
echo '{
"params": {"param1": "Hello Jeff","param2": "How are you?"},
"source": {"source1": "sourcefoo1","source2": "sourcefoo2"},
"version":{"ref": ""}}' |
go run main.go out $PWD
PIPELINE EXAMPLE USING PUT
jobs:
...
- name: your-job-name
plan:
...
- put: resource-marathon-deploy
params: {app_json_path: "hello-go/app.json"}
resource_types:
...
- name: marathon-deploy
type: docker-image
source:
marathonuri:http://10.141.141.10:8080
repository: jeffdecola/resource-marathon-deploy
tag: latest
resources:
...
- name: resource-marathon-deploy
type: marathon-deploy
source:
repository: /username/image-name
tag: latest
GET would look similar.
TESTED, BUILT & PUSHED TO DOCKERHUB USING CONCOURSE
To automate the creation of the resource-marathon-deploy
docker image, a concourse pipeline
will,
- Update README.md for resource-marathon-deploy github webpage.
- Unit Test the code.
- Build the docker image
resource-marathon-deploy
and push to DockerHub.
![IMAGE - resource-marathon-deploy concourse ci pipeline - IMAGE](https://github.com/jeffdecola/resource-marathon-deploy/raw/20f1a061933b/docs/pics/resource-marathon-deploy-pipeline.jpg)
As seen in the pipeline diagram, the resource-dump-to-dockerhub uses
the resource type
docker-image
to push a docker image to dockerhub.
resource-marathon-deploy
also contains a few extra concourse resources:
- A resource (resource-slack-alert) uses a docker image
that will notify slack on your progress.
- A resource (resource-repo-status) use a docker image
that will update your git status for that particular commit.
- A resource (
resource-template
)
that can be used as a starting point and template for creating other concourse
ci resources.
For more information on using concourse for continuous integration,
refer to my cheat sheet on concourse.