@@ -27,6 +27,7 @@ const {
27
27
runClusterAcceptanceTests,
28
28
installAgent,
29
29
installRuntime,
30
+ installAppProxy,
30
31
attachRuntime,
31
32
newRuntimeName,
32
33
newAgentName,
@@ -158,6 +159,11 @@ const initCmd = new Command({
158
159
. option ( 'env-vars' , {
159
160
describe : 'Addiontal env vars to be used in agent\'s pod' ,
160
161
type : array ,
162
+ } )
163
+ . option ( 'app-proxy' , {
164
+ describe : 'install app proxy component (default false)' ,
165
+ default : false ,
166
+ type : 'boolean' ,
161
167
} ) ,
162
168
handler : async ( argv ) => {
163
169
let resumedInstallation = false ;
@@ -181,56 +187,59 @@ const initCmd = new Command({
181
187
_argv = Object . assign ( oldInstallationPlan . getContext ( 'argv' ) , _argv ) ; // restore previous installation environment
182
188
}
183
189
184
- let {
190
+ const {
185
191
'kube-node-selector' : kubeNodeSelector ,
186
192
'build-node-selector' : buildNodeSelector ,
187
193
tolerations,
188
194
'kube-config-path' : kubeConfigPath ,
189
195
'storage-class-name' : storageClassName ,
190
- 'yes' : noQuestions ,
191
196
verbose,
192
- name, url,
193
- token,
194
- 'values' : valuesFile ,
197
+ values : valuesFile ,
195
198
'set-value' : setValue ,
196
199
'set-file' : setFile ,
197
200
'skip-cluster-test' : skipClusterTest ,
198
- 'install-monitor' : installMonitor ,
199
201
'docker-registry' : dockerRegistry ,
200
-
202
+ 'app-proxy' : appProxy ,
203
+ } = _argv ;
204
+ let {
205
+ yes : noQuestions ,
201
206
'kube-context-name' : kubeContextName ,
202
207
'kube-namespace' : kubeNamespace ,
203
208
'set-default-runtime' : shouldMakeDefaultRe ,
204
209
'exec-demo-pipeline' : shouldExecutePipeline ,
205
210
'env-vars' : envVars ,
206
211
'http-proxy' : httpProxy ,
207
212
'https-proxy' : httpsProxy ,
213
+ url,
214
+ token,
215
+ name,
216
+ 'install-monitor' : installMonitor ,
208
217
} = _argv ;
209
218
210
219
let valuesObj ;
211
220
if ( valuesFile ) {
212
- let valuesFileStr = fs . readFileSync ( valuesFile , 'utf8' ) ;
221
+ const valuesFileStr = fs . readFileSync ( valuesFile , 'utf8' ) ;
213
222
valuesObj = YAML . parse ( valuesFileStr ) ;
214
223
noQuestions = true ;
215
224
216
- if ( ! kubeNamespace && valuesObj . Namespace ) {
225
+ if ( ! kubeNamespace && valuesObj . Namespace ) {
217
226
kubeNamespace = valuesObj . Namespace ;
218
227
}
219
- if ( ! kubeContextName && valuesObj . Context ) {
228
+ if ( ! kubeContextName && valuesObj . Context ) {
220
229
kubeContextName = valuesObj . Context ;
221
230
}
222
- if ( ! url && valuesObj . CodefreshHost ) {
231
+ if ( ! url && valuesObj . CodefreshHost ) {
223
232
url = valuesObj . CodefreshHost ;
224
233
}
225
- if ( ! token && valuesObj . Token ) {
234
+ if ( ! token && valuesObj . Token ) {
226
235
token = valuesObj . Token ;
227
236
}
228
- if ( ! name && valuesObj . AgentId ) {
237
+ if ( ! name && valuesObj . AgentId ) {
229
238
name = valuesObj . AgentId ;
230
239
}
231
- if ( typeof _ . get ( valuesObj , " Monitor.Enabled" ) !== 'undefined' ) {
232
- installMonitor = _ . get ( valuesObj , " Monitor.Enabled" ) ;
233
- }
240
+ if ( typeof _ . get ( valuesObj , ' Monitor.Enabled' ) !== 'undefined' ) {
241
+ installMonitor = _ . get ( valuesObj , ' Monitor.Enabled' ) ;
242
+ }
234
243
}
235
244
if ( ! url ) {
236
245
url = DEFAULTS . URL ;
@@ -396,7 +405,7 @@ const initCmd = new Command({
396
405
installationPlan . addContext ( 'argv' , _argv ) ;
397
406
398
407
// run cluster acceptance tests
399
- if ( ! _ . get ( valuesObj , " SkipClusterTest" ) ) {
408
+ if ( ! _ . get ( valuesObj , ' SkipClusterTest' ) ) {
400
409
installationPlan . addStep ( {
401
410
name : 'run cluster acceptance tests' ,
402
411
func : runClusterAcceptanceTests ,
@@ -450,7 +459,7 @@ const initCmd = new Command({
450
459
envVars,
451
460
valuesFile, // --values
452
461
setValue, // --set-value
453
- setFile, // --set-file
462
+ setFile, // --set-file
454
463
} ) ;
455
464
} ,
456
465
installationEvent : installationProgress . events . AGENT_INSTALLED ,
@@ -584,6 +593,38 @@ const initCmd = new Command({
584
593
installationEvent : installationProgress . events . RUNTIME_INSTALLED ,
585
594
} ) ;
586
595
596
+ installationPlan . addStep ( {
597
+ name : 'install app-proxy' ,
598
+ func : async ( ) => {
599
+ const appProxyIP = await installAppProxy ( {
600
+ kubeContextName,
601
+ kubeNamespace,
602
+ verbose,
603
+ kubeConfigPath,
604
+ } ) ;
605
+ installationPlan . addContext ( 'appProxyIP' , appProxyIP ) ;
606
+ } ,
607
+ installationEvent : installationProgress . events . APP_PROXY_INSTALLED ,
608
+ condition : ! ! appProxy ,
609
+ } ) ;
610
+
611
+ // update runtime with ingress IP
612
+ installationPlan . addStep ( {
613
+ name : 'update runtime environment app proxy ip' ,
614
+ func : async ( ) => {
615
+ const reName = installationPlan . getContext ( 'runtimeName' ) ;
616
+ const re = await sdk . runtimeEnvs . get ( { name : reName } ) ;
617
+ const body = {
618
+ appProxy : {
619
+ externalIP : installationPlan . getContext ( 'appProxyIP' ) ,
620
+ } ,
621
+ } ;
622
+ await sdk . runtimeEnvs . update ( { name : reName } , _ . merge ( re , body ) ) ;
623
+ console . log ( `Runtime environment "${ colors . cyan ( reName ) } " has been updated with the app proxy` ) ;
624
+ } ,
625
+ condition : async ( ) => installationPlan . getContext ( 'appProxyIP' ) ,
626
+ } ) ;
627
+
587
628
// update agent with new runtime
588
629
installationPlan . addStep ( {
589
630
name : 'update agent with new runtime' ,
0 commit comments