Skip to content

Commit 41e444f

Browse files
committed
Add ctl tool
1 parent 56c67fe commit 41e444f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

deploy/ctl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env variant
2+
# vim:set ft=yaml
3+
tasks:
4+
deps:
5+
description: "Install alpine dependencies"
6+
script: |
7+
apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse
8+
9+
color:
10+
description: "Lookup the current color"
11+
12+
parameters:
13+
- name: config
14+
default: ".color"
15+
description: "Config file that keeps track of the current color"
16+
17+
script: |
18+
config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
19+
if [ -f ${config} ]; then
20+
cat ${config}
21+
else
22+
echo "blue" | tee ${config}
23+
fi
24+
blue-green:
25+
description: "Trigger a blue-green deployment"
26+
27+
parameters:
28+
- name: namespace
29+
default: "default"
30+
description: "Kubernetes namespace"
31+
32+
- name: config
33+
default: ".color"
34+
description: "Config file that keeps track of the current color"
35+
36+
- name: color
37+
type: string
38+
description: "Selected color to deploy"
39+
40+
- name: blue
41+
type: string
42+
default: green
43+
description: "Flip blue color to this color"
44+
45+
- name: green
46+
type: string
47+
default: blue
48+
description: "Flip green color to this color"
49+
50+
script: |
51+
config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
52+
cur_color={{ get "color" }}
53+
new_color={{ get "color" | get }}
54+
echo "Updating {{ get "namespace" }}: $cur_color => $new_color"
55+
echo "$new_color" > ${config}
56+
export COLOR=$new_color
57+
helmfile --namespace {{ get "namespace" }} sync

0 commit comments

Comments
 (0)