-
Notifications
You must be signed in to change notification settings - Fork 41
/
corekube-heat.yaml
500 lines (453 loc) · 19 KB
/
corekube-heat.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
heat_template_version: 2013-05-23
description: Deploy a CoreOS cluster that operates a Kubernetes cluster
parameters:
kubernetes-master-count:
description: Number of CoreOS machines to deploy as Kubernetes Master
type: number
default: 1
constraints:
- range:
min: 1
max: 1
description: Must be between 1 and 1 servers.
kubernetes-minion-count:
description: Number of CoreOS machines to deploy as Kubernetes Minion
type: number
default: 4
constraints:
- range:
min: 2
max: 12
description: Must be between 2 and 12 servers.
key-name:
type: string
description: Name of key-pair to be used for compute instance
flavor:
type: string
default: 2 GB Performance
constraints:
- allowed_values:
- 2 GB Performance
- 4 GB Performance
- 8 GB Performance
- 15 GB Performance
- 30 GB Performance
description: |
Must be a valid Rackspace Cloud Server flavor for the region you have
selected to deploy into.
public-key:
type: string
description: Public SSH key to use with Fleet
default: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn8g4xaL/A3C9M89rDNcSLj4mUm4iOF6gN3hvdqnQD0GHM81RP3U6Nm6QbIR7Vv8xAvnpLooK9tEIS9f4xpEjcurV0w7m7iYxhw0WvyxEt7HlTixe1rkinJe4GvWdsWR71kjwaFuYzSHpM0c87qYM8fQhW2UvPy90Yi2EAiIvyOlIrICpljY0DrPokUvHXnr+whdmNydZVxl93Qxegj55BDZq+SglbLmlghdhsrb6MVMefpMxMtHtq90ejZ3Dah2/eKMvmc62eMHiz6x338HuZB2PQbkpfg7lH1B10NjAV7ylonPD7YpwATBatQw37GtEBV1HQbJr6HPtNKbqOiMW1 core@coreos"
coreos-image:
type: string
description: Rackspace Cloud Servers CoreOS Alpha (410.0.0) UUID
default: "78a24bc3-2545-433b-8067-a5143c04a3c3"
git-repo:
type: string
description: Public git repo url
default: "https://github.com/bketelsen/corekube.git"
git-branch:
type: string
description: Git repo branch
default: "master"
resources:
coreos-cluster-uuid:
type: OS::Heat::RandomString
priv_network:
type: Rackspace::Cloud::Network
properties:
label: kubernetes
cidr: 192.168.3.0/24
discovery:
type: OS::Nova::Server
properties:
key_name: { get_param: key-name }
image: { get_param: coreos-image }
flavor: { get_param: flavor }
name: "discovery"
user_data_format: RAW
config_drive: "true"
user_data: |
#cloud-config
coreos:
update:
group: alpha
reboot-strategy: off
units:
- name: private-discovery.service
command: start
content: |
[Unit]
After=network-online.target
Requires=network-online.target
[Service]
ExecStart=/usr/bin/docker run -d --name discovery -p 4001:4001 -p 7001:7001 coreos/etcd
overlord:
type: OS::Nova::Server
properties:
key_name: { get_param: key-name }
image: { get_param: coreos-image }
flavor: { get_param: flavor }
name: "overlord"
user_data_format: RAW
config_drive: "true"
user_data:
str_replace:
template: |
#cloud-config
write_files:
- content: |
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAp/IOMWi/wNwvTPPawzXEi4+JlJuIjheoDd4b3ap0A9BhzPNU
T91OjZukGyEe1b/MQL56S6KCvbRCEvX+MaRI3Lq1dMO5u4mMYcNFr8sRLex5U4sX
ta5IpyXuBr1nbFke9ZI8GhbmM0h6TNHPO6mDPH0IVtlLz8vdGIthAIiL8jpSKyAq
ZY2NA6z6JFLx156/sIXZjcnWVcZfd0MXoI+eQQ2avkoJWy5pYIXYbK2+jFTHn6TM
TLR7avdHo2dw2odv3ijL5nOtnjB4s+sd9/B7mQdj0G5KX4O5R9QddDYwFe8paJzw
+2KcAEwWrUMN+xrRAVdR0Gya+hz7TSm6jojFtQIDAQABAoIBAGikNxeuDpwaFRa7
cfjjjXzviGehqSnvr3REidRJmlOuCOHsUwIYABPXgB6vOkkwYhGNHSH3NcMBh5HM
1/8SP5vYcas5MIabI27efpMT0bZtewMEzVcUKoyK444rgT9PIC0eWnhfADu/0wP+
TkL8UZrkxMdoSQZGHZJndZ8hdSENFo1GIySQw6F+Fad5LhwElmXPEm1/cxsLCfmI
Rq+J83WSKtDbU0mFLyA7f/cOORJPV5n8J6SiIKRMoxHYln9A8DbxHhideNEM9ON8
e8KcbpIDVy+BUUf4Q+gkJdRpuKlU/IbJriYOSFHI0YtFv0DzTVPfOqL3j6CPZ6MK
xy9QyYECgYEA3qzU6393Sx6g5QJ/0QFSvIYp6zym+jDKXlq7gqlL+5O9y3w8VGtA
PDS3M/RSNDonEpyoIPSP0qOEG9TKRYi4QhqwiEvuTyxBT0ijljWxFazAQ1qrDRV9
8gt5pz16jW6yn6rWjIqqBZdHfjphsmC9gByKU33alzP0/uXkx216JMUCgYEAwRRp
9mvi+THI+AugT+MIID1rym2P12bcc28+uAmUPVsWDfT9mASagKTgLsRgtJXPGqdO
dfM79eN9m29ZGFy74p7i7FY54LR6U+jVAfpYEQ8iuEWPrQZa0MzVwPPkhFQSAhNM
nKPM7DlJ/PhLjmRx9xw3vl/lyzMCdO8Sbi6cjDECgYEApbS0FjQbEDnQvdtoRp7X
dRfaJgZStCiO0DxxAcD+nE7LlJv1QVU2zhbkprMQYXFNFlqh+zRDuxqX+yYVCD2/
8OFvsV3gD+b9CwUhR2zZRSnzQaw9UlVGDlNfyobDpnBUWOGHG7ss31A+kb7caSP4
oVeb0Jn9izvM+8sUvxvHI4kCgYEAqQ3csXxJIXNryXM0jH32UXQ1+unvNeTERPY0
biNE/mvQZawKlp4BQX4bJBehrLw2t9mhozizWVo0UnIuCly3zXbcrZ3Z01tyeCG2
z6KIlXcxKTMO16pmvcd7qRRjE1Ig6lxHiicJeBO5KpukXCqqdnjoffGtXDtvfT8O
XhbFzyECgYEArzXO7hPLGV67yg7tbQDdDtVtufJdTG1lQ9tUWONtkfpywUG6R8Bk
h1KDIp8O4PR3Ce26w4Put7NSlYy8vMAw8/yjf1k6vV34vvm7slAnWTwhvI2cJugR
Vl/vxnRB+yLhA8FHRr7Xa9Fy/oTUnxo/vcsrn4HQP3qGeNKH1voklf4=
-----END RSA PRIVATE KEY-----
path: /root/.ssh/id_rsa
permissions: '0600'
- content: |
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel QUIET
path: /root/.ssh/config
permissions: '0644'
coreos:
etcd:
name: overlord
discovery: http://%discovery%:4001/v2/keys/_etcd/registry/%uuid%
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
fleet:
public-ip: $private_ipv4
metadata: kubernetes_role=overlord
update:
group: alpha
reboot-strategy: off
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: setup-kubernetes.service
command: start
content: |
[Unit]
After=network-online.target
Requires=network-online.target
[Service]
WorkingDirectory=/root
Environment="DIR=corekube"
ExecStartPre=/usr/bin/rm -rf $DIR
ExecStartPre=/usr/bin/git clone -b %branch% %repo%
ExecStart=/usr/bin/bash ${DIR}/build_run.sh %branch% %master_count% %minion_count% 1
- name: update-fleet.service
command: start
content: |
[Unit]
Description=Download & replace Fleet v0.7.1 local
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/wget -q -P /root/ https://github.com/coreos/fleet/releases/download/v0.7.1/fleet-v0.7.1-linux-amd64.tar.gz ; /usr/bin/tar xfz /root/fleet-v0.7.1-linux-amd64.tar.gz -C /root
- name: fleet.socket
command: start
content: |
[Unit]
After=update-fleet.service
Requires=update-fleet.service
[Socket]
# Talk to the API over a Unix domain socket (default)
ListenStream=/var/run/fleet.sock
# Talk to the API over an exposed port, uncomment to enable and choose a port
ListenStream=10001
Service=fleet-local.service
[Install]
WantedBy=sockets.target
- name: fleet-local.service
command: start
content: |
[Unit]
Description=fleet-local
Wants=etcd.service
After=etcd.service
Wants=update-fleet.service
After=update-fleet.service
[Service]
Environment=FLEET_PUBLIC_IP=$private_ipv4
Environment=FLEET_METADATA=kubernetes_role=overlord
ExecStartPre=/usr/bin/systemctl stop fleet.service
ExecStart=/root/fleet-v0.7.1-linux-amd64/fleet
Restart=always
RestartSec=10s
params:
"%discovery%": { get_attr: [discovery, networks, private, 0] }
"%uuid%": { get_attr: [coreos-cluster-uuid, value] }
"%master_count%": { get_param: kubernetes-master-count }
"%minion_count%": { get_param: kubernetes-minion-count }
"%repo%": { get_param: git-repo }
"%branch%": { get_param: git-branch }
master_machines:
type: "OS::Heat::ResourceGroup"
properties:
count: { get_param: kubernetes-master-count }
resource_def:
type: OS::Nova::Server
properties:
key_name: { get_param: key-name }
image: { get_param: coreos-image }
flavor: { get_param: flavor }
name: kubernetes-master-%index%
networks:
- uuid: "00000000-0000-0000-0000-000000000000"
- uuid: "11111111-1111-1111-1111-111111111111"
- uuid: { get_resource: priv_network }
user_data_format: RAW
config_drive: "true"
user_data:
str_replace:
template: |
#cloud-config
ssh_authorized_keys:
- %public_key%
coreos:
etcd:
name: kubernetes-master-%index%
discovery: http://%discovery%:4001/v2/keys/_etcd/registry/%uuid%
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
fleet:
public-ip: $private_ipv4
metadata: kubernetes_role=master
update:
group: alpha
reboot-strategy: off
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: cbr0.netdev
command: start
content: |
[NetDev]
Kind=bridge
Name=cbr0
- name: cbr0.network
command: start
content: |
[Match]
Name=cbr0
[Network]
Address=10.244.%index%.1/24
[Route]
Destination=10.244.0.0/15
Gateway=0.0.0.0
- name: vxlan0.netdev
command: start
content: |
[NetDev]
Kind=vxlan
Name=vxlan0
[VXLAN]
Id=1
Group=224.0.0.1
- name: 49-eth2.network
command: start
content: |
[Match]
Name=eth2
[Network]
VXLAN=vxlan0
- name: vxlan0.network
command: start
content: |
[Match]
Name=vxlan0
[Network]
Bridge=cbr0
- name: docker.service
command: start
content: |
[Unit]
After=network.target
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
[Service]
ExecStartPre=/bin/mount --make-rprivate /
ExecStart=/usr/bin/docker -d -s=btrfs -H fd:// -b cbr0
[Install]
WantedBy=multi-user.target
- name: update-fleet.service
command: start
content: |
[Unit]
Description=Download & replace Fleet v0.7.1 local
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/wget -q -P /root/ https://github.com/coreos/fleet/releases/download/v0.7.1/fleet-v0.7.1-linux-amd64.tar.gz ; /usr/bin/tar xfz /root/fleet-v0.7.1-linux-amd64.tar.gz -C /root
- name: fleet-local.service
command: start
content: |
[Unit]
Description=fleet-local
Wants=etcd.service
After=etcd.service
Wants=update-fleet.service
After=update-fleet.service
[Service]
Environment=FLEET_PUBLIC_IP=$private_ipv4
Environment=FLEET_METADATA=kubernetes_role=master
ExecStartPre=/usr/bin/systemctl stop fleet.service
ExecStart=/root/fleet-v0.7.1-linux-amd64/fleet
Restart=always
RestartSec=10s
params:
"%discovery%": { get_attr: [discovery, networks, private, 0] }
"%uuid%": { get_attr: [coreos-cluster-uuid, value] }
"%public_key%": { get_param: public-key }
minion_machines:
type: "OS::Heat::ResourceGroup"
properties:
count: { get_param: kubernetes-minion-count }
resource_def:
type: OS::Nova::Server
properties:
key_name: { get_param: key-name }
image: { get_param: coreos-image }
flavor: { get_param: flavor }
name: kubernetes-minion-%index%
networks:
- uuid: "00000000-0000-0000-0000-000000000000"
- uuid: "11111111-1111-1111-1111-111111111111"
- uuid: { get_resource: priv_network }
user_data_format: RAW
config_drive: "true"
user_data:
str_replace:
template: |
#cloud-config
ssh_authorized_keys:
- %public_key%
coreos:
etcd:
name: kubernetes-minion-%index%
discovery: http://%discovery%:4001/v2/keys/_etcd/registry/%uuid%
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
fleet:
public-ip: $private_ipv4
metadata: kubernetes_role=minion
update:
group: alpha
reboot-strategy: off
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: cbr0.netdev
command: start
content: |
[NetDev]
Kind=bridge
Name=cbr0
- name: cbr0.network
command: start
content: |
[Match]
Name=cbr0
[Network]
Address=10.245.%index%.1/24
[Route]
Destination=10.244.0.0/15
Gateway=0.0.0.0
- name: vxlan0.netdev
command: start
content: |
[NetDev]
Kind=vxlan
Name=vxlan0
[VXLAN]
Id=1
Group=224.0.0.1
- name: 49-eth2.network
command: start
content: |
[Match]
Name=eth2
[Network]
VXLAN=vxlan0
- name: vxlan0.network
command: start
content: |
[Match]
Name=vxlan0
[Network]
Bridge=cbr0
- name: docker.service
command: start
content: |
[Unit]
After=network.target
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
[Service]
ExecStartPre=/bin/mount --make-rprivate /
ExecStart=/usr/bin/docker -d -s=btrfs -H fd:// -b cbr0
[Install]
WantedBy=multi-user.target
- name: update-fleet.service
command: start
content: |
[Unit]
Description=Download & replace Fleet v0.7.1 local
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/wget -q -P /root/ https://github.com/coreos/fleet/releases/download/v0.7.1/fleet-v0.7.1-linux-amd64.tar.gz ; /usr/bin/tar xfz /root/fleet-v0.7.1-linux-amd64.tar.gz -C /root
- name: fleet-local.service
command: start
content: |
[Unit]
Description=fleet-local
Wants=etcd.service
After=etcd.service
Wants=update-fleet.service
After=update-fleet.service
[Service]
Environment=FLEET_PUBLIC_IP=$private_ipv4
Environment=FLEET_METADATA=kubernetes_role=minion
ExecStartPre=/usr/bin/systemctl stop fleet.service
ExecStart=/root/fleet-v0.7.1-linux-amd64/fleet
Restart=always
RestartSec=10s
params:
"%discovery%": { get_attr: [discovery, networks, private, 0] }
"%uuid%": { get_attr: [coreos-cluster-uuid, value] }
"%public_key%": { get_param: public-key }