Skip to content

Commit 49d9009

Browse files
dcos-app-deploy/plugin.yaml added
1 parent db881d6 commit 49d9009

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

stable/dcos-app-deploy/NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Notes

stable/dcos-app-deploy/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# cf-deploy-dcos
2+
The repository contains code for `codefresh/cf-deploy-dcos` image building. This image makes an application deployment on DC/OS cluster using application definition json file.
3+
It takes application deployment template (deployment.tmpl) and generates application deployment json file substituting variables in the template with the the environment variables values then applies the application deployment json file to DC/OS cluster using DC/OS CLI command.
4+
5+
6+
# Usage
7+
In order to use the `codefresh/cf-deploy-dcos` image we need to do the following:
8+
9+
1. Define environment variables in Codefresh pipeline.
10+
11+
- `DCOS_URL` **required** - DC/OS cluster URL
12+
- `DCOS_CLUSTER_NAME` **required** - DC/OS cluster name
13+
- `DCOS_CLUSTER_ID` **required** - DC/OS cluster ID
14+
- `DCOS_DCOS_ACS_TOKEN` **required** - DC/OS cluster existing user's token (make it encrypted)
15+
- `DCOS_SSL_VERIFY` default is true, if we want to bypass SSL certificate verification - set it to `false`
16+
- `APP_ID` - application name
17+
- `IMAGE_NAME` - application image name
18+
- `IMAGE_TAG` - application image tag
19+
20+
2. Create deployment.tmpl and codefresh.yml files in an application repository at the root level.
21+
22+
```
23+
codefresh.yml
24+
---
25+
version: '1.0'
26+
steps:
27+
BuildingDockerImage:
28+
type: build
29+
image_name: applcation/image
30+
...
31+
32+
PushToRegistry:
33+
type: push
34+
candidate: ${{BuildingDockerImage}}
35+
...
36+
37+
DeployToDcos:
38+
image: codefresh/cf-deploy-dcos:latest
39+
working_directory: ${{main_clone}}
40+
commands:
41+
- /cf-deploy-dcos deployment.tmpl
42+
environment:
43+
- DCOS_URL=${{DCOS_URL}}
44+
- DCOS_CLUSTER_NAME=${{DCOS_CLUSTER_NAME}}
45+
- DCOS_CLUSTER_ID=${{DCOS_CLUSTER_ID}}
46+
- DCOS_DCOS_ACS_TOKEN=${{DCOS_DCOS_ACS_TOKEN}}
47+
- DCOS_SSL_VERIFY=${{DCOS_SSL_VERIFY}}
48+
- APP_ID=${{APP_ID}}
49+
- IMAGE_NAME=${{IMAGE_NAME}}
50+
- IMAGE_TAG=${{IMAGE_TAG}}
51+
```
52+
We define freestyle step (DeployToDcos in the example above) and environment variables the same as in the Codefresh pipeline.
53+
54+
```
55+
deployment.tmpl
56+
57+
{
58+
"id": "{{APP_ID}}",
59+
"instances": 1,
60+
"cpus": 0.1,
61+
"mem": 64,
62+
"container": {
63+
"type" : "DOCKER",
64+
"docker": {
65+
"image": "{{IMAGE_NAME}}:{{IMAGE_TAG}}",
66+
"forcePullImage": true,
67+
"privileged": false,
68+
"network": "BRIDGE",
69+
"portMappings": [
70+
{ "hostPort": 80, "containerPort": 8081, "protocol": "tcp", "name": "http"}
71+
]
72+
}
73+
},
74+
"acceptedResourceRoles": [
75+
"slave_public"
76+
]
77+
}
78+
```
79+
`APP_ID`, `IMAGE_NAME` and `IMAGE_TAG` variables are just examples. We can parametrise any value in application deployment template depending on our requirements.
80+
But if we set some parameter `{{PARAMETER}}` in application deployment template we should ensure that this parameter is set both in Codefresh pipeline and in codefresh.yml freestyle step as well.
81+
82+
Notes: we can use already configured DC/OS CLI dcos command to get DC/OS cluster parameters.
83+
Example:
84+
```
85+
dcos cluster list --attached --json
86+
87+
[
88+
{
89+
"attached": true,
90+
"cluster_id": "9d50f776-****-433c-****-ebb01eaafbbc",
91+
"name": "dcos-master",
92+
"url": "https://dcos-master.cloudapp.azure.com",
93+
"version": "1.10.2"
94+
}
95+
]
96+
```
97+
```
98+
dcos config show core.dcos_acs_token
99+
100+
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik9UQkVOakZFTWtWQ09VRTRPRVpGTlRNMFJrWXlRa015Tnprd1JrSkVRemRCTWpBM1FqYzVOZyJ9.ey********
101+
```

stable/dcos-app-deploy/plugin.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
image: codefresh/cf-deploy-dcos
2+
tag: latest
3+
version: 0.1.0
4+
description: Deploy an application on dcos cluster
5+
keywords:
6+
- dcos
7+
- deploy
8+
- deployment
9+
home: https://github.com/codefresh-io/cf-deploy-dcos
10+
sources:
11+
- https://github.com/codefresh-io/cf-deploy-dcos
12+
maintainers: # (optional)
13+
- name: Eugene Semirski
14+
email: eugene@codefresh.io
15+
icon: https://avatars0.githubusercontent.com/u/29493517?v=4&s=400
16+
envs:
17+
- name: DCOS_URL
18+
type: required
19+
description: DC/OS cluster URL
20+
- name: DCOS_CLUSTER_NAME
21+
type: required
22+
description: DC/OS cluster name
23+
- name: DCOS_CLUSTER_ID
24+
type: required
25+
description: DC/OS cluster ID
26+
- name: DCOS_DCOS_ACS_TOKEN
27+
type: required
28+
description: DC/OS cluster existing user's token
29+
- name: DCOS_SSL_VERIFY
30+
type: not_required
31+
description: default is true, if we want to bypass SSL certificate verification - set it to false
32+
- name: PARAMETER
33+
type: not_required
34+
description: see README.md for details

0 commit comments

Comments
 (0)