-
Notifications
You must be signed in to change notification settings - Fork 7
/
porter.yaml
231 lines (222 loc) · 7.54 KB
/
porter.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# See https://porter.sh/authoring-bundles for documentation on how to configure your bundle
name: spring-music
version: 0.7.0
description: "Run the Spring Music Service on Kubernetes and Digital Ocean PostgreSQL"
invocationImage: jeremyrickard/porter-do:v0.7.0
tag: jeremyrickard/porter-do-bundle:v0.7.0
dockerfile: Dockerfile.tmpl
credentials:
- name: do_access_token
description: "Access Token for Digital Ocean Account"
env: DO_ACCESS_TOKEN
- name: do_spaces_key
description: "DO Spaces API Key"
env: DO_SPACES_KEY
- name: do_spaces_secret
description: "DO Spaces API Secret"
env: DO_SPACES_SECRET
- name: kubeconfig
description: "Kube config file with permissions to deploy app"
path: /root/.kube/config
parameters:
- name: region
description: "Region to create Database and DO Space"
type: string
default: "nyc3"
- name: space_name
description: "Name for DO Space"
type: string
default: "jrrportertest"
- name: database_name
description: "Name of database to create"
type: string
default: "jrrportertest"
- name: node_count
type: integer
description: "Number of database nodes"
default: 1
- name: namespace
description: "Namespace to install Spring Music app"
type: string
default: "default"
- name: helm_release
description: "Helm release name"
type: string
default: "spring-music-helm"
outputs:
- name: service_ip
description: "IP Address assigned to the Load Balancer"
type: string
applyTo:
- install
- upgrade
mixins:
- exec
- helm
- terraform
images:
spring-music:
description: "Spring Music Example"
imageType: "docker"
repository: "jeremyrickard/spring-music"
tag: "v1.0.0"
#digest: "sha256:8f1133d81f1b078c865cdb11d17d1ff15f55c449d3eecca50190eed0f5e5e26f"
install:
- exec:
description: "s3cmd create bucket"
command: s3cmd
arguments:
- mb
- "s3://{{bundle.parameters.space_name}}"
- "--access_key={{bundle.credentials.do_spaces_key}}"
- "--secret_key={{bundle.credentials.do_spaces_secret}}"
- "--host={{bundle.parameters.region}}.digitaloceanspaces.com"
- "--host-bucket=%(bucket)s.{{bundle.parameters.region}}.digitaloceanspaces.com"
- terraform:
description: "Create DO PostgreSQL With Terraform"
backendConfig:
key: "{{ bundle.name }}.tfstate"
access_key: "{{bundle.credentials.do_spaces_key}}"
secret_key: "{{bundle.credentials.do_spaces_secret}}"
bucket: "{{bundle.parameters.space_name}}"
endpoint: "{{bundle.parameters.region}}.digitaloceanspaces.com"
vars:
do_token: "{{bundle.credentials.do_access_token}}"
region: "{{bundle.parameters.region}}"
database_name: "{{bundle.parameters.database_name}}"
node_count: "{{bundle.parameters.node_count}}"
outputs:
- name: "db_host"
- name: "db_port"
- name: "db"
- name: "db_user"
- name: "db_password"
- helm:
description: "Deploy Spring Music with Helm"
name: "{{bundle.parameters.helm_release}}"
namespace: "{{bundle.parameters.namespace}}"
chart: charts/spring-music
replace: true
set:
deploy.image: "{{bundle.images.spring-music.repository}}@{{bundle.images.spring-music.digest}}"
deploy.profile: "postgresql"
deploy.db: "{{bundle.outputs.db}}"
deploy.db_user: "{{bundle.outputs.db_user}}"
deploy.db_password: "{{bundle.outputs.db_password}}"
deploy.db_host: "{{bundle.outputs.db_host}}"
deploy.db_port: "{{bundle.outputs.db_port}}"
- exec:
description: "Wait for IP"
command: "bash"
arguments:
- "waitForIP.sh"
- "spring-music"
- "{{bundle.parameters.namespace}}"
- exec:
description: "Get Ingress IP"
command: "kubectl"
arguments:
- "get"
- "service"
- "spring-music"
flags:
o: "json"
namespace: "{{bundle.parameters.namespace}}"
outputs:
- name: "service_ip"
jsonPath: "$.status.loadBalancer.ingress[0].ip"
upgrade:
- terraform:
description: "Create DO PostgreSQL With Terraform"
backendConfig:
key: "{{ bundle.name }}.tfstate"
access_key: "{{bundle.credentials.do_spaces_key}}"
secret_key: "{{bundle.credentials.do_spaces_secret}}"
bucket: "{{bundle.parameters.space_name}}"
endpoint: "{{bundle.parameters.region}}.digitaloceanspaces.com"
vars:
do_token: "{{bundle.credentials.do_access_token}}"
region: "{{bundle.parameters.region}}"
database_name: "{{bundle.parameters.database_name}}"
node_count: "{{bundle.parameters.node_count}}"
outputs:
- name: "db_host"
- name: "db_port"
- name: "db"
- name: "db_user"
- name: "db_password"
- helm:
description: "Deploy Spring Music with Helm"
name: "{{bundle.parameters.helm_release}}"
namespace: "{{bundle.parameters.namespace}}"
chart: charts/spring-music
set:
deploy.image: "jeremyrickard/spring-music@sha256:8f1133d81f1b078c865cdb11d17d1ff15f55c449d3eecca50190eed0f5e5e26f"
deploy.profile: "postgresql"
deploy.db: "{{bundle.outputs.db}}"
deploy.db_user: "{{bundle.outputs.db_user}}"
deploy.db_password: "{{bundle.outputs.db_password}}"
deploy.db_host: "{{bundle.outputs.db_host}}"
deploy.db_port: "{{bundle.outputs.db_port}}"
- exec:
description: "Wait for IP"
command: "bash"
arguments:
- "waitForIP.sh"
- "spring-music"
- "{{bundle.parameters.namespace}}"
- exec:
description: "Get Ingress IP"
command: "kubectl"
arguments:
- "get"
- "service"
- "spring-music"
flags:
o: "json"
namespace: "{{bundle.parameters.namespace}}"
outputs:
- name: "service_ip"
jsonPath: "$.status.loadBalancer.ingress[0].ip"
uninstall:
- helm:
description: "Deploy Spring Music with Helm"
purge: true
releases:
- "{{bundle.parameters.helm_release}}"
- terraform:
description: "Create DO PostgreSQL With Terraform"
backendConfig:
key: "{{ bundle.name }}.tfstate"
access_key: "{{bundle.credentials.do_spaces_key}}"
secret_key: "{{bundle.credentials.do_spaces_secret}}"
bucket: "{{bundle.parameters.space_name}}"
endpoint: "{{bundle.parameters.region}}.digitaloceanspaces.com"
vars:
do_token: "{{bundle.credentials.do_access_token}}"
region: "{{bundle.parameters.region}}"
database_name: "{{bundle.parameters.database_name}}"
node_count: "{{bundle.parameters.node_count}}"
- exec:
description: "s3cmd delete bucket"
command: s3cmd
arguments:
- del
- "s3://{{bundle.parameters.space_name}}"
- "--recursive"
- "--force"
- "--access_key={{bundle.credentials.do_spaces_key}}"
- "--secret_key={{bundle.credentials.do_spaces_secret}}"
- "--host={{bundle.parameters.region}}.digitaloceanspaces.com"
- "--host-bucket=%(bucket)s.{{bundle.parameters.region}}.digitaloceanspaces.com"
- exec:
description: "s3cmd delete bucket"
command: s3cmd
arguments:
- rb
- "s3://{{bundle.parameters.space_name}}"
- "--force"
- "--access_key={{bundle.credentials.do_spaces_key}}"
- "--secret_key={{bundle.credentials.do_spaces_secret}}"
- "--host={{bundle.parameters.region}}.digitaloceanspaces.com"
- "--host-bucket=%(bucket)s.{{bundle.parameters.region}}.digitaloceanspaces.com"