@@ -71,34 +71,25 @@ pipeline {
71
71
DEBIAN_FRONTEND=noninteractive apt -y install figlet openjdk-11-jdk make docker.io
72
72
# Make sure our kubeconfig dir exists…
73
73
mkdir $HOME/.kube || true
74
- '''
74
+ '''
75
75
}
76
76
}
77
77
78
78
stage(' Cleaning Up' ) {
79
79
steps {
80
80
81
81
/*
82
- * Run a find and check for any stacks that currently exist with our generated stack name; this should not
83
- * happen in normal operation, but could potentially happen if things break so better safe than sorry.
82
+ * This is currently empty since we are building a new executor for each run. However, maintaining
83
+ * here for anyone who wants to add cleanup steps for their environment
84
84
*
85
- * This function also tries to remove both K3S and Microk8s if they are found on the host; this is because we
86
- * will be installing Microk8s and we want to both make sure we are removing any previous installations as well as
87
- * ensuring this Jenkins Agent does not already have a Microk8s installation on it.
85
+ * Other cleanup related functions can be placed here as well.
88
86
*/
89
87
90
- sh '''
91
- # Reset our K3S Environment
92
- /usr/local/bin/k3s-killall.sh || true
93
- /usr/local/bin/k3s-uninstall.sh || true
94
- # Reset our Microk8s Environment; true if it’s not there
95
- microk8s reset --destroy-storage || true
96
- # True if it’s not there…
97
- snap remove microk8s || true
98
- # Clean up the Pulumi stack if it exists for our run - which it shouldn\' t, but you never know.
99
- find $WORKSPACE -mindepth 2 -maxdepth 7 -type f -name Pulumi.yaml -execdir $WORKSPACE/pulumi/python/venv/bin/pulumi stack rm marajenk${BUILD_NUMBER} --force --yes \\ ;
100
- '''
101
- }
88
+ sh '''
89
+ # Just return...
90
+ true
91
+ '''
92
+ }
102
93
}
103
94
104
95
stage(' Microk8s Setup' ) {
@@ -115,7 +106,7 @@ pipeline {
115
106
snap install microk8s --classic --channel=1.23/stable
116
107
microk8s.enable storage dns helm3
117
108
microk8s.enable metallb 192.168.100.100/30
118
- '''
109
+ '''
119
110
}
120
111
}
121
112
@@ -129,7 +120,7 @@ pipeline {
129
120
130
121
sh '''
131
122
microk8s.config > $HOME/.kube/config
132
- '''
123
+ '''
133
124
}
134
125
}
135
126
@@ -142,7 +133,7 @@ pipeline {
142
133
143
134
sh '''
144
135
$WORKSPACE/bin/setup_venv.sh
145
- '''
136
+ '''
146
137
}
147
138
}
148
139
@@ -159,21 +150,21 @@ pipeline {
159
150
*/
160
151
161
152
sh '''
162
- echo "PULUMI_STACK=marajenk ${BUILD_NUMBER}" > $WORKSPACE/config/pulumi/environment
163
- $WORKSPACE/pulumi/python/venv/bin/pulumi stack select --create marajenk ${BUILD_NUMBER} -C pulumi/python/config
164
- $WORKSPACE/pulumi/python/venv/bin/pulumi stack select --create marajenk ${BUILD_NUMBER} -C pulumi/python/kubernetes/applications/sirius
165
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set certmgr:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
166
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set kic-helm:fqdn "marajenks ${BUILD_NUMBER}.zathras.io" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
167
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set kic-helm:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
168
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:cluster_name "microk8s-cluster" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
169
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:infra_type "kubeconfig" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
170
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:kubeconfig "$HOME/.kube/config" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
171
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set logagent:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
172
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set logstore:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
173
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:adminpass "password" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
174
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
175
- $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:helm_timeout "600" -C pulumi/python/config -s marajenk ${BUILD_NUMBER}
176
- '''
153
+ echo "PULUMI_STACK=marajenkmk8s ${BUILD_NUMBER}" > $WORKSPACE/config/pulumi/environment
154
+ $WORKSPACE/pulumi/python/venv/bin/pulumi stack select --create marajenkmk8s ${BUILD_NUMBER} -C pulumi/python/config
155
+ $WORKSPACE/pulumi/python/venv/bin/pulumi stack select --create marajenkmk8s ${BUILD_NUMBER} -C pulumi/python/kubernetes/applications/sirius
156
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set certmgr:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
157
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set kic-helm:fqdn "marajenkmk8ss ${BUILD_NUMBER}.zathras.io" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
158
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set kic-helm:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
159
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:cluster_name "microk8s-cluster" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
160
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:infra_type "kubeconfig" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
161
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set kubernetes:kubeconfig "$HOME/.kube/config" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
162
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set logagent:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
163
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set logstore:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
164
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:adminpass "password" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
165
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
166
+ $WORKSPACE/pulumi/python/venv/bin/pulumi config set prometheus:helm_timeout "600" -C pulumi/python/config -s marajenkmk8s ${BUILD_NUMBER}
167
+ '''
177
168
}
178
169
}
179
170
@@ -188,7 +179,7 @@ pipeline {
188
179
sh '''
189
180
echo $NGINX_JWT > $WORKSPACE/extras/jwt.token
190
181
$WORKSPACE/bin/start_kube.sh
191
- '''
182
+ '''
192
183
}
193
184
}
194
185
@@ -209,14 +200,8 @@ pipeline {
209
200
microk8s reset --destroy-storage || true
210
201
# True if it’s not there…
211
202
sudo snap remove microk8s || true
212
- find . -mindepth 2 -maxdepth 6 -type f -name Pulumi.yaml -execdir $WORKSPACE/pulumi/python/venv/bin/pulumi stack rm marajenk${BUILD_NUMBER} --force --yes \\ ;
213
- # This is a hack to allow additional commands to be issued following cleanup. This is needed because the VMs
214
- # that currently run as agents for K3S and Microk8s deployments need to be rebooted following some number of
215
- # runs due to zombie processes and other issues. Long term we want to deploy these VM's via IaaC so the only
216
- # exist for the lifetime of the project. We do it this way in order to provide some flexibility for the
217
- # jenkins configuration.
218
- ${POSTRUN_CMD- true}
219
- '''
203
+ find . -mindepth 2 -maxdepth 6 -type f -name Pulumi.yaml -execdir $WORKSPACE/pulumi/python/venv/bin/pulumi stack rm marajenkmk8s${BUILD_NUMBER} --force --yes \\ ;
204
+ '''
220
205
221
206
}
222
207
}
@@ -233,14 +218,13 @@ pipeline {
233
218
*/
234
219
235
220
sh '''
236
- # Destroy our partial build...
237
- $WORKSPACE/bin/destroy.sh || true
238
- # Reset our Microk8s Environment; true if it’s not there
239
- microk8s reset --destroy-storage || true
240
- # True if it’s not there…
241
- snap remove microk8s || true
242
- # Clean up the Pulumi stack if it exists for our run - which it shouldn\' t, but you never know.
243
- find $WORKSPACE -mindepth 2 -maxdepth 7 -type f -name Pulumi.yaml -execdir $WORKSPACE/pulumi/python/venv/bin/pulumi stack rm marajenk${BUILD_NUMBER} --force --yes \;
221
+ # Destroy our partial build...
222
+ $WORKSPACE/bin/destroy.sh || true
223
+ # Reset our Microk8s Environment; true if it’s not there
224
+ microk8s reset --destroy-storage || true
225
+ # True if it’s not there…
226
+ snap remove microk8s || true
227
+ find $WORKSPACE -mindepth 2 -maxdepth 7 -type f -name Pulumi.yaml -execdir $WORKSPACE/pulumi/python/venv/bin/pulumi stack rm marajenkmk8s${BUILD_NUMBER} --force --yes \\ ;
244
228
'''
245
229
}
246
230
}
0 commit comments