74
74
RuntimeStoreIV string
75
75
IngressHost string
76
76
IngressClass string
77
+ IngressController string
77
78
Insecure bool
78
79
InstallDemoResources bool
79
80
Version * semver.Version
@@ -190,7 +191,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
190
191
"Runtime name" : installationOpts .RuntimeName ,
191
192
"Repository URL" : installationOpts .InsCloneOpts .Repo ,
192
193
"Ingress host" : installationOpts .IngressHost ,
193
- "IngressClass " : installationOpts .IngressClass ,
194
+ "Ingress class " : installationOpts .IngressClass ,
194
195
"Installing demo resources" : strconv .FormatBool (installationOpts .InstallDemoResources ),
195
196
}
196
197
@@ -225,8 +226,8 @@ func NewRuntimeInstallCommand() *cobra.Command {
225
226
})
226
227
installationOpts .KubeFactory = kube .AddFlags (cmd .Flags ())
227
228
228
- util .Die (cmd .MarkFlagRequired ("ingress-host" ))
229
229
util .Die (cmd .Flags ().MarkHidden ("bypass-ingress-class-check" ))
230
+ util .Die (cmd .Flags ().MarkHidden ("ingress-host" ))
230
231
231
232
return cmd
232
233
}
@@ -282,20 +283,20 @@ func runtimeInstallCommandPreRunHandler(cmd *cobra.Command, opts *RuntimeInstall
282
283
return err
283
284
}
284
285
285
- err = ensureRepo (cmd , opts . RuntimeName , opts . InsCloneOpts , false )
286
- handleCliStep (reporter .InstallStepPreCheckEnsureRuntimeRepo , "Getting runtime repo " , err , false )
286
+ err = ensureIngressHost (cmd , opts )
287
+ handleCliStep (reporter .InstallStepPreCheckEnsureIngressHost , "Getting ingressHost " , err , false )
287
288
if err != nil {
288
289
return err
289
290
}
290
291
291
- err = ensureGitToken (cmd , opts .InsCloneOpts )
292
- handleCliStep (reporter .InstallStepPreCheckEnsureGitToken , "Getting git token " , err , false )
292
+ err = ensureRepo (cmd , opts .RuntimeName , opts . InsCloneOpts , false )
293
+ handleCliStep (reporter .InstallStepPreCheckEnsureRuntimeRepo , "Getting runtime repo " , err , false )
293
294
if err != nil {
294
295
return err
295
296
}
296
297
297
- err = ensureIngressHost (cmd , opts )
298
- handleCliStep (reporter .InstallStepPreCheckEnsureIngressHost , "Getting ingressHost " , err , false )
298
+ err = ensureGitToken (cmd , opts . InsCloneOpts )
299
+ handleCliStep (reporter .InstallStepPreCheckEnsureGitToken , "Getting git token " , err , false )
299
300
if err != nil {
300
301
return err
301
302
}
@@ -381,17 +382,18 @@ func runtimeUpgradeCommandPreRunHandler(cmd *cobra.Command, args []string, clone
381
382
}
382
383
383
384
func ensureIngressHost (cmd * cobra.Command , opts * RuntimeInstallOptions ) error {
384
- if err := getIngressHostFromUserInput ( cmd , & opts .IngressHost ); err != nil {
385
- return err
385
+ if opts .IngressHost != "" { // ingress host provided by hidden flag (for our tests)
386
+ return nil
386
387
}
387
388
388
- isValid , err := IsValidIngressHost (opts .IngressHost )
389
- if err != nil {
390
- log .G (cmd .Context ()).Fatal ("failed to check the validity of the ingress host" )
391
- } else if ! isValid {
392
- log .G (cmd .Context ()).Fatal ("ingress host must begin with a protocol http:// or https://" )
389
+ if err := getIngressHostFromCluster (cmd .Context (), opts ); err != nil {
390
+ return err
393
391
}
394
392
393
+ log .G (cmd .Context ()).Infof ("Using ingress host: %s" , opts .IngressHost )
394
+
395
+ log .G (cmd .Context ()).Info ("Validating ingress host" )
396
+
395
397
certValid , err := checkIngressHostCertificate (cmd .Context (), opts .IngressHost )
396
398
if err != nil {
397
399
log .G (cmd .Context ()).Fatalf ("failed to check ingress host: %v" , err )
@@ -410,8 +412,8 @@ func ensureIngressClass(ctx context.Context, opts *RuntimeInstallOptions) error
410
412
if store .Get ().BypassIngressClassCheck {
411
413
return nil
412
414
}
413
-
414
- fmt . Print ("Retrieving ingress class info from your cluster...\n " )
415
+
416
+ log . G ( ctx ). Info ("Retrieving ingress class info from your cluster...\n " )
415
417
416
418
cs := opts .KubeFactory .KubernetesClientSetOrDie ()
417
419
ingressClassList , err := cs .NetworkingV1 ().IngressClasses ().List (ctx , metav1.ListOptions {})
@@ -420,18 +422,21 @@ func ensureIngressClass(ctx context.Context, opts *RuntimeInstallOptions) error
420
422
}
421
423
422
424
var ingressClassNames []string
425
+ ingressClassNameToController := make (map [string ]string )
423
426
var isValidClass bool
424
427
for _ , ic := range ingressClassList .Items {
425
428
if ic .ObjectMeta .Labels ["app.kubernetes.io/name" ] == "ingress-nginx" {
426
429
ingressClassNames = append (ingressClassNames , ic .Name )
430
+ ingressClassNameToController [ic .Name ] = fmt .Sprintf ("%s-controller" , getControllerName (ic .Spec .Controller ))
427
431
if opts .IngressClass == ic .Name {
428
432
isValidClass = true
429
433
}
430
434
}
431
435
}
432
436
433
437
if opts .IngressClass != "" { //if user provided ingress class by flag
434
- if isValidClass {
438
+ if isValidClass {
439
+ opts .IngressController = ingressClassNameToController [opts .IngressClass ]
435
440
return nil
436
441
}
437
442
return fmt .Errorf ("Ingress Class '%s' is not supported. Only the ingress class of type NGINX is supported. for more information: %s" , opts .IngressClass , store .Get ().RequirementsLink )
@@ -444,11 +449,18 @@ func ensureIngressClass(ctx context.Context, opts *RuntimeInstallOptions) error
444
449
if len (ingressClassNames ) == 1 {
445
450
log .G (ctx ).Info ("Using ingress class: " , ingressClassNames [0 ])
446
451
opts .IngressClass = ingressClassNames [0 ]
452
+ opts .IngressController = ingressClassNameToController [opts .IngressClass ]
447
453
return nil
448
454
}
449
455
450
456
if ! store .Get ().Silent {
451
- return getIngressClassFromUserSelect (ctx , ingressClassNames , & opts .IngressClass )
457
+ err = getIngressClassFromUserSelect (ctx , ingressClassNames , & opts .IngressClass )
458
+ if err != nil {
459
+ return err
460
+ }
461
+
462
+ opts .IngressController = ingressClassNameToController [opts .IngressClass ]
463
+ return nil
452
464
}
453
465
454
466
return fmt .Errorf ("Please add the --ingress-class flag and define its value" )
0 commit comments