This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.sh
executable file
·172 lines (123 loc) · 5.15 KB
/
demo.sh
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
#!/bin/bash
# Reset for demo:
# * Tear down the kind cluster
# kind delete cluster
# * Delete the CloudFormation stacks from my AWS account
# aws cloudformation delete-stack --stack-name my-cfn-stack-deployed-by-flux
# aws cloudformation delete-stack --stack-name my-other-cfn-stack-deployed-by-flux
# aws cloudformation delete-stack --stack-name yet-another-cfn-stack-deployed-by-flux
# aws cloudformation wait stack-delete-complete --stack-name my-cfn-stack-deployed-by-flux
# aws cloudformation wait stack-delete-complete --stack-name my-other-cfn-stack-deployed-by-flux
# aws cloudformation wait stack-delete-complete --stack-name yet-another-cfn-stack-deployed-by-flux
# * Delete the stack files from testdata/my-flux-configuration (git push)
# * Re-copy the examples into testdata
# cp -rf examples/my-cloudformation-templates/* testdata/my-cloudformation-templates/ (git push)
# cp -rf examples/my-flux-configuration/* testdata/my-flux-configuration/
# * Re-create the kind cluster
# make bootstrap-local-cluster
# * Start up local controller:
# make run
export PATH="$PATH:$PWD/bin/local"
PS1="$ "
# Ensure demo-magic is cloned here
# https://github.com/paxtonhare/demo-magic
. ../demo-magic/demo-magic.sh
clear
# Look and feel
TYPE_SPEED=20
DEMO_COMMENT_COLOR=$CYAN
NO_WAIT=false
# Start the demo
# Press enter to continue
PROMPT_TIMEOUT=0
p "# Welcome to the AWS CloudFormation Template Sync Controller for Flux!"
PROMPT_TIMEOUT=1
NO_WAIT=true
p "#"
p "# Flux is a GitOps tool that runs on Kubernetes. Out of the box, Flux automates syncing"
p "# Kubernetes configuration from source locations like git repositories into your Kubernetes"
p "# cluster."
p "#"
p "# The CloudFormation controller for Flux automates syncing CloudFormation templates from source"
p "# locations like git repositories into CloudFormation stacks in your AWS account."
p "#"
p "# Let's walk through an example!"
NO_WAIT=false
pe "cd examples/"
p "# I have 2 git repositories here:"
pe "ls -1"
# Highlight repos, press enter to continue
PROMPT_TIMEOUT=0
p "# First, I have a repository that stores the CloudFormation templates that I need to deploy."
PROMPT_TIMEOUT=1
pe "ls -1 my-cloudformation-templates"
# Highlight template files, press enter to continue
PROMPT_TIMEOUT=0
p "# I have three CloudFormation template files that will be deployed to three stacks."
NO_WAIT=true
p "# I also have a git repository that stores the configuration for Flux running in my Kubernetes"
p "# cluster."
NO_WAIT=false
pe "cd my-flux-configuration"
pe "ls -1"
# Highlight the template git repo file, press enter to continue
PROMPT_TIMEOUT=0
p "# I first hooked up my CloudFormation template git repository to Flux."
PROMPT_TIMEOUT=1
NO_WAIT=true
p "# Flux polls my git repository every five minutes to check for new commits to my CloudFormation"
p "# templates."
NO_WAIT=false
pe "cat my-cloudformation-templates-repo.yaml"
# Highlight repo configuration, press enter to continue
PROMPT_TIMEOUT=0
p "# In my Kubernetes cluster, I can see that Flux has the latest commits for my git repositories."
PROMPT_TIMEOUT=1
pe "flux get sources git"
# Highlight git sources, press enter to continue
PROMPT_TIMEOUT=0
p "# In my Flux configuration, I have three Flux CloudFormationStack objects defined."
PROMPT_TIMEOUT=1
pe "ls -1 *-stack.yaml"
NO_WAIT=true
p "# For each CloudFormationStack object, the CloudFormation controller for Flux will create and"
p "# update a CloudFormation stack in my AWS account."
p "#"
p "# The CloudFormationStack configuration specifies which source code repository and file contain"
p "# the template for the stack, and how often to re-sync the latest template into the stack."
NO_WAIT=false
pe "cat my-cloudformation-stack.yaml"
# Highlight stack configuration, press enter to continue
PROMPT_TIMEOUT=0
p "# Let's push this configuration to Flux and watch it create the CloudFormation stacks!"
PROMPT_TIMEOUT=1
cd ../../testdata/my-flux-configuration
pe "git add *-stack.yaml"
pe "git commit -m 'Add CFN stacks'"
pe "git push -q"
pe "flux reconcile source git flux-system"
pe "flux get sources git"
pe "kubectl get cfnstack -A --watch"
pe "kubectl get cfnstack -A"
p "# The stacks are now created in my AWS account!"
# Highlight succeeded reconciliation, press enter to continue
PROMPT_TIMEOUT=0
pe "aws cloudformation describe-stacks --stack-name my-cfn-stack-deployed-by-flux"
# Highlight stack status, press enter to continue
p "# Let's now update a template file and watch Flux automatically deploy the change."
PROMPT_TIMEOUT=1
pe "cd ../my-cloudformation-templates"
pe "sed -i 's/Hello World/Hey there/g' template.yaml"
pe "git diff"
pe "git add template.yaml"
pe "git commit -m 'Update template file'"
pe "git push -q"
pe "flux reconcile source git my-cfn-templates-repo"
pe "flux get sources git"
pe "kubectl get cfnstack -A --watch"
pe "kubectl get cfnstack -A"
p "# The stack is now updated in my AWS account with the latest template file!"
# Highlight stack status, press enter to continue
PROMPT_TIMEOUT=0
pe "aws cloudformation describe-stacks --stack-name my-cfn-stack-deployed-by-flux"
p "# Enjoy continuous delivery of your CloudFormation stacks with Flux!"