Skip to content

Commit 8334940

Browse files
dcos-app-deploy/plugin.yaml
1 parent db881d6 commit 8334940

File tree

8 files changed

+136
-19
lines changed

8 files changed

+136
-19
lines changed

dcos-app-deploy/LICENSE

Whitespace-only changes.

dcos-app-deploy/NOTES.md

Whitespace-only changes.

dcos-app-deploy/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

dcos-app-deploy/plugin.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

stable/dcos-app-deploy/LICENSE

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

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-10d4-433c-9ae5-ebb01eaafbbc",
91+
"name": "dcos-master-ip-es-dcos-master-es-dcos",
92+
"url": "https://es-dcos-master.westeurope.cloudapp.azure.com",
93+
"version": "1.10.2"
94+
}
95+
]
96+
```
97+
```
98+
dcos config show core.dcos_acs_token
99+
100+
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Ik9UQkVOakZFTWtWQ09VRTRPRVpGTlRNMFJrWXlRa015Tnprd1JrSkVRemRCTWpBM1FqYzVOZyJ9.eyJlbWFpbCI6ImV1Z2VuZUBjb2RlZnJlc2guaW8iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly9kY29zLmF1dGgwLmNvbS8iLCJzdWIiOiJnb29nbGUtb2F1dGgyfDExODA0MjgxODQ2NjI1NTk0NzkyOSIsImF1ZCI6IjN5RjVUT1N6ZGxJNDVRMXhzcHh6ZW9HQmU5Zk54bTltIiwiaWF0IjoxNTEyMTM3ODUyLCJleHAiOjE1MTI1Njk4NTJ9.Ckp3HcR0P31EaadOM1TXk1EwrgmsNM0Neem3U633g8wAt7xQXnYV9VymQz9cDMExzKQPTLmwHcIG7QDBrUO__eBznJRzThhvCfvS85N410WuaaYrjdYbKzkM9XiEeNpHNIa0JI5RfIMGX_4TGUuXvGkHXzZtGKxq40Zq5cMRgS71Seljzeor5SvxOU3Llwhlh4pgw3zRlDFVz7BoFNxOV19RpKxVZPrklM7tjEUn1mw6eEbFgL7oDnuXJEIMiNgYkgfTvz1tYWugtZA6GiWWnbRTqFRb0niaHE5EOOmsBx64BfMsK8OMEwAwflDVLSpmMd_GcFZYXz1twbzyn_qqmQ
101+
```

stable/dcos-app-deploy/plugin.yaml

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

0 commit comments

Comments
 (0)