@@ -27,6 +27,7 @@ const {
2727 runClusterAcceptanceTests,
2828 installAgent,
2929 installRuntime,
30+ installAppProxy,
3031 attachRuntime,
3132 newRuntimeName,
3233 newAgentName,
@@ -158,6 +159,11 @@ const initCmd = new Command({
158159 . option ( 'env-vars' , {
159160 describe : 'Addiontal env vars to be used in agent\'s pod' ,
160161 type : array ,
162+ } )
163+ . option ( 'app-proxy' , {
164+ describe : 'install app proxy component (default false)' ,
165+ default : false ,
166+ type : 'boolean' ,
161167 } ) ,
162168 handler : async ( argv ) => {
163169 let resumedInstallation = false ;
@@ -181,56 +187,59 @@ const initCmd = new Command({
181187 _argv = Object . assign ( oldInstallationPlan . getContext ( 'argv' ) , _argv ) ; // restore previous installation environment
182188 }
183189
184- let {
190+ const {
185191 'kube-node-selector' : kubeNodeSelector ,
186192 'build-node-selector' : buildNodeSelector ,
187193 tolerations,
188194 'kube-config-path' : kubeConfigPath ,
189195 'storage-class-name' : storageClassName ,
190- 'yes' : noQuestions ,
191196 verbose,
192- name, url,
193- token,
194- 'values' : valuesFile ,
197+ values : valuesFile ,
195198 'set-value' : setValue ,
196199 'set-file' : setFile ,
197200 'skip-cluster-test' : skipClusterTest ,
198- 'install-monitor' : installMonitor ,
199201 'docker-registry' : dockerRegistry ,
200-
202+ 'app-proxy' : appProxy ,
203+ } = _argv ;
204+ let {
205+ yes : noQuestions ,
201206 'kube-context-name' : kubeContextName ,
202207 'kube-namespace' : kubeNamespace ,
203208 'set-default-runtime' : shouldMakeDefaultRe ,
204209 'exec-demo-pipeline' : shouldExecutePipeline ,
205210 'env-vars' : envVars ,
206211 'http-proxy' : httpProxy ,
207212 'https-proxy' : httpsProxy ,
213+ url,
214+ token,
215+ name,
216+ 'install-monitor' : installMonitor ,
208217 } = _argv ;
209218
210219 let valuesObj ;
211220 if ( valuesFile ) {
212- let valuesFileStr = fs . readFileSync ( valuesFile , 'utf8' ) ;
221+ const valuesFileStr = fs . readFileSync ( valuesFile , 'utf8' ) ;
213222 valuesObj = YAML . parse ( valuesFileStr ) ;
214223 noQuestions = true ;
215224
216- if ( ! kubeNamespace && valuesObj . Namespace ) {
225+ if ( ! kubeNamespace && valuesObj . Namespace ) {
217226 kubeNamespace = valuesObj . Namespace ;
218227 }
219- if ( ! kubeContextName && valuesObj . Context ) {
228+ if ( ! kubeContextName && valuesObj . Context ) {
220229 kubeContextName = valuesObj . Context ;
221230 }
222- if ( ! url && valuesObj . CodefreshHost ) {
231+ if ( ! url && valuesObj . CodefreshHost ) {
223232 url = valuesObj . CodefreshHost ;
224233 }
225- if ( ! token && valuesObj . Token ) {
234+ if ( ! token && valuesObj . Token ) {
226235 token = valuesObj . Token ;
227236 }
228- if ( ! name && valuesObj . AgentId ) {
237+ if ( ! name && valuesObj . AgentId ) {
229238 name = valuesObj . AgentId ;
230239 }
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+ }
234243 }
235244 if ( ! url ) {
236245 url = DEFAULTS . URL ;
@@ -396,7 +405,7 @@ const initCmd = new Command({
396405 installationPlan . addContext ( 'argv' , _argv ) ;
397406
398407 // run cluster acceptance tests
399- if ( ! _ . get ( valuesObj , " SkipClusterTest" ) ) {
408+ if ( ! _ . get ( valuesObj , ' SkipClusterTest' ) ) {
400409 installationPlan . addStep ( {
401410 name : 'run cluster acceptance tests' ,
402411 func : runClusterAcceptanceTests ,
@@ -450,7 +459,7 @@ const initCmd = new Command({
450459 envVars,
451460 valuesFile, // --values
452461 setValue, // --set-value
453- setFile, // --set-file
462+ setFile, // --set-file
454463 } ) ;
455464 } ,
456465 installationEvent : installationProgress . events . AGENT_INSTALLED ,
@@ -584,6 +593,38 @@ const initCmd = new Command({
584593 installationEvent : installationProgress . events . RUNTIME_INSTALLED ,
585594 } ) ;
586595
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+
587628 // update agent with new runtime
588629 installationPlan . addStep ( {
589630 name : 'update agent with new runtime' ,
0 commit comments