@@ -82,8 +82,10 @@ type (
8282 RuntimeToken string
8383 RuntimeStoreIV string
8484 HostName string
85+ InternalHostName string
8586 IngressHost string
8687 IngressClass string
88+ InternalIngressHost string
8789 IngressController ingressutil.IngressController
8890 Insecure bool
8991 InstallDemoResources bool
@@ -102,6 +104,8 @@ type (
102104 versionStr string
103105 kubeContext string
104106 kubeconfig string
107+ InternalIngressAnnotation map [string ]string
108+ ExternalIngressAnnotation map [string ]string
105109 }
106110
107111 RuntimeUninstallOptions struct {
@@ -230,6 +234,10 @@ func NewRuntimeInstallCommand() *cobra.Command {
230234 "Installing demo resources" : strconv .FormatBool (installationOpts .InstallDemoResources ),
231235 }
232236
237+ if installationOpts .InternalIngressHost != "" {
238+ finalParameters ["Internal ingress host" ] = installationOpts .InternalIngressHost
239+ }
240+
233241 if err := getApprovalFromUser (cmd .Context (), finalParameters , "runtime install" ); err != nil {
234242 return err
235243 }
@@ -245,6 +253,7 @@ func NewRuntimeInstallCommand() *cobra.Command {
245253
246254 cmd .Flags ().StringVar (& installationOpts .IngressHost , "ingress-host" , "" , "The ingress host" )
247255 cmd .Flags ().StringVar (& installationOpts .IngressClass , "ingress-class" , "" , "The ingress class name" )
256+ cmd .Flags ().StringVar (& installationOpts .InternalIngressHost , "internal-ingress-host" , "" , "The internal ingress host (by default the external ingress will be used for both internal and external traffic)" )
248257 cmd .Flags ().StringVar (& installationOpts .GitIntegrationRegistrationOpts .Token , "personal-git-token" , "" , "The Personal git token for your user" )
249258 cmd .Flags ().StringVar (& installationOpts .versionStr , "version" , "" , "The runtime version to install (default: latest)" )
250259 cmd .Flags ().BoolVar (& installationOpts .InstallDemoResources , "demo-resources" , true , "Installs demo resources (default: true)" )
@@ -258,6 +267,8 @@ func NewRuntimeInstallCommand() *cobra.Command {
258267 cmd .Flags ().BoolVar (& store .Get ().SetDefaultResources , "set-default-resources" , false , "If true, will set default requests and limits on all of the runtime components" )
259268 cmd .Flags ().BoolVar (& installationOpts .FromRepo , "from-repo" , false , "Installs a runtime from an existing repo. Used for recovery after cluster failure" )
260269 cmd .Flags ().StringToStringVar (& installationOpts .NamespaceLabels , "namespace-labels" , nil , "Optional labels that will be set on the namespace resource. (e.g. \" key1=value1,key2=value2\" " )
270+ cmd .Flags ().StringToStringVar (& installationOpts .InternalIngressAnnotation , "internal-ingress-annotation" , nil , "Add annotations to the internal ingress" )
271+ cmd .Flags ().StringToStringVar (& installationOpts .ExternalIngressAnnotation , "external-ingress-annotation" , nil , "Add annotations to the external ingress" )
261272
262273 installationOpts .InsCloneOpts = apu .AddCloneFlags (cmd , & apu.CloneFlagsOptions {
263274 CreateIfNotExist : true ,
@@ -434,32 +445,57 @@ func ensureIngressHost(cmd *cobra.Command, opts *RuntimeInstallOptions) error {
434445 }
435446 }
436447
437- parsed , err := url .Parse (opts .IngressHost )
448+ if err := parseHostName (opts .IngressHost , & opts .HostName ); err != nil {
449+ return err
450+ }
451+
452+ if opts .InternalIngressHost != "" {
453+ if err := parseHostName (opts .InternalIngressHost , & opts .InternalHostName ); err != nil {
454+ return err
455+ }
456+ }
457+
458+ log .G (cmd .Context ()).Infof ("Using ingress host: %s" , opts .IngressHost )
459+
460+ if ! opts .SkipClusterChecks {
461+ return nil
462+ }
463+
464+ log .G (cmd .Context ()).Info ("Validating ingress host" )
465+
466+ if opts .InternalIngressHost != "" {
467+ if err := validateIngressHostCertificate (cmd , opts .InternalIngressHost ); err != nil {
468+ return err
469+ }
470+ log .G (cmd .Context ()).Infof ("Using internal ingress host: %s" , opts .InternalIngressHost )
471+ }
472+
473+ return validateIngressHostCertificate (cmd , opts .IngressHost )
474+ }
475+
476+ func parseHostName (ingressHost string , hostName * string ) error {
477+ parsed , err := url .Parse (ingressHost )
438478 if err != nil {
439479 return err
440480 }
441481
442482 isIP := util .IsIP (parsed .Host )
443483 if ! isIP {
444- opts . HostName , _ , err = net .SplitHostPort (parsed .Host )
484+ * hostName , _ , err = net .SplitHostPort (parsed .Host )
445485 if err != nil {
446486 if err .Error () == fmt .Sprintf ("address %s: missing port in address" , parsed .Host ) {
447- opts . HostName = parsed .Host
487+ * hostName = parsed .Host
448488 } else {
449489 return err
450490 }
451491 }
452492 }
453493
454- log .G (cmd .Context ()).Infof ("Using ingress host: %s" , opts .IngressHost )
455-
456- if ! opts .SkipClusterChecks {
457- return nil
458- }
459-
460- log .G (cmd .Context ()).Info ("Validating ingress host" )
494+ return nil
495+ }
461496
462- certValid , err := checkIngressHostCertificate (opts .IngressHost )
497+ func validateIngressHostCertificate (cmd * cobra.Command , ingressHost string ) error {
498+ certValid , err := checkIngressHostCertificate (ingressHost )
463499 if err != nil {
464500 log .G (cmd .Context ()).Fatalf ("failed to check ingress host: %v" , err )
465501 }
@@ -600,15 +636,16 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
600636 ingressControllerName := opts .IngressController .Name ()
601637
602638 token , iv , err := createRuntimeOnPlatform (ctx , & model.RuntimeInstallationArgs {
603- RuntimeName : opts .RuntimeName ,
604- Cluster : server ,
605- RuntimeVersion : runtimeVersion ,
606- IngressHost : & opts .IngressHost ,
607- IngressClass : & opts .IngressClass ,
608- IngressController : & ingressControllerName ,
609- ComponentNames : componentNames ,
610- Repo : & opts .InsCloneOpts .Repo ,
611- Recover : & opts .FromRepo ,
639+ RuntimeName : opts .RuntimeName ,
640+ Cluster : server ,
641+ RuntimeVersion : runtimeVersion ,
642+ IngressHost : & opts .IngressHost ,
643+ InternalIngressHost : & opts .InternalIngressHost ,
644+ IngressClass : & opts .IngressClass ,
645+ IngressController : & ingressControllerName ,
646+ ComponentNames : componentNames ,
647+ Repo : & opts .InsCloneOpts .Repo ,
648+ Recover : & opts .FromRepo ,
612649 })
613650 handleCliStep (reporter .InstallStepCreateRuntimeOnPlatform , "Creating runtime on platform" , err , false , true )
614651 if err != nil {
@@ -620,6 +657,7 @@ func RunRuntimeInstall(ctx context.Context, opts *RuntimeInstallOptions) error {
620657 rt .Spec .Cluster = server
621658 rt .Spec .IngressHost = opts .IngressHost
622659 rt .Spec .IngressClass = opts .IngressClass
660+ rt .Spec .InternalIngressHost = opts .InternalIngressHost
623661 rt .Spec .IngressController = string (opts .IngressController .Name ())
624662 rt .Spec .Repo = opts .InsCloneOpts .Repo
625663
@@ -814,15 +852,21 @@ func createMasterIngressResource(ctx context.Context, opts *RuntimeInstallOption
814852 return err
815853 }
816854
817- ingress := ingressutil . CreateIngress ( & ingressutil.CreateIngressOptions {
855+ ingressOptions := ingressutil.CreateIngressOptions {
818856 Name : opts .RuntimeName + store .Get ().MasterIngressName ,
819857 Namespace : opts .RuntimeName ,
820858 IngressClassName : opts .IngressClass ,
821859 Host : opts .HostName ,
822860 Annotations : map [string ]string {
823861 "nginx.org/mergeable-ingress-type" : "master" ,
824862 },
825- })
863+ }
864+
865+ if opts .ExternalIngressAnnotation != nil {
866+ mergeAnnotations (ingressOptions .Annotations , opts .ExternalIngressAnnotation )
867+ }
868+
869+ ingress := ingressutil .CreateIngress (& ingressOptions )
826870
827871 if err = fs .WriteYamls (fs .Join (store .Get ().InClusterPath , "master-ingress.yaml" ), ingress ); err != nil {
828872 return err
@@ -1329,6 +1373,7 @@ func RunRuntimeList(ctx context.Context) error {
13291373 healthMessage := "N/A"
13301374 installationStatus := rt .InstallationStatus
13311375 ingressHost := "N/A"
1376+ internalIngressHost := "N/A"
13321377 ingressClass := "N/A"
13331378
13341379 if rt .Metadata .Namespace != nil {
@@ -1351,11 +1396,15 @@ func RunRuntimeList(ctx context.Context) error {
13511396 ingressHost = * rt .IngressHost
13521397 }
13531398
1399+ if rt .InternalIngressHost != nil {
1400+ internalIngressHost = * rt .InternalIngressHost
1401+ }
1402+
13541403 if rt .IngressClass != nil {
13551404 ingressClass = * rt .IngressClass
13561405 }
13571406
1358- _ , err = fmt .Fprintf (tb , "%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\n " ,
1407+ _ , err = fmt .Fprintf (tb , "%s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s\t %s \ n " ,
13591408 name ,
13601409 namespace ,
13611410 cluster ,
@@ -1365,6 +1414,7 @@ func RunRuntimeList(ctx context.Context) error {
13651414 healthMessage ,
13661415 installationStatus ,
13671416 ingressHost ,
1417+ internalIngressHost ,
13681418 ingressClass ,
13691419 )
13701420 if err != nil {
@@ -1842,6 +1892,10 @@ func createWorkflowsIngress(ctx context.Context, opts *RuntimeInstallOptions, rt
18421892 },
18431893 }
18441894
1895+ if opts .ExternalIngressAnnotation != nil {
1896+ mergeAnnotations (ingressOptions .Annotations , opts .ExternalIngressAnnotation )
1897+ }
1898+
18451899 ingress := ingressutil .CreateIngress (& ingressOptions )
18461900 opts .IngressController .Decorate (ingress )
18471901
@@ -1881,6 +1935,12 @@ func createWorkflowsIngress(ctx context.Context, opts *RuntimeInstallOptions, rt
18811935 return apu .PushWithMessage (ctx , r , "Created Workflows Ingress" )
18821936}
18831937
1938+ func mergeAnnotations (annotation map [string ]string , newAnnotation map [string ]string ) {
1939+ for key , element := range newAnnotation {
1940+ annotation [key ] = element
1941+ }
1942+ }
1943+
18841944func configureAppProxy (ctx context.Context , opts * RuntimeInstallOptions , rt * runtime.Runtime ) error {
18851945 r , fs , err := opts .InsCloneOpts .GetRepo (ctx )
18861946 if err != nil {
@@ -1912,12 +1972,17 @@ func configureAppProxy(ctx context.Context, opts *RuntimeInstallOptions, rt *run
19121972 },
19131973 })
19141974
1975+ hostName := opts .HostName
1976+ if opts .InternalHostName != "" {
1977+ hostName = opts .InternalHostName
1978+ }
1979+
19151980 if ! store .Get ().SkipIngress {
19161981 ingressOptions := ingressutil.CreateIngressOptions {
19171982 Name : rt .Name + store .Get ().AppProxyIngressName ,
19181983 Namespace : rt .Namespace ,
19191984 IngressClassName : opts .IngressClass ,
1920- Host : opts . HostName ,
1985+ Host : hostName ,
19211986 Paths : []ingressutil.IngressPath {
19221987 {
19231988 Path : store .Get ().AppProxyIngressPath ,
@@ -1928,6 +1993,11 @@ func configureAppProxy(ctx context.Context, opts *RuntimeInstallOptions, rt *run
19281993 },
19291994 }
19301995
1996+ if opts .InternalIngressAnnotation != nil {
1997+ ingressOptions .Annotations = make (map [string ]string )
1998+ mergeAnnotations (ingressOptions .Annotations , opts .InternalIngressAnnotation )
1999+ }
2000+
19312001 ingress := ingressutil .CreateIngress (& ingressOptions )
19322002 opts .IngressController .Decorate (ingress )
19332003
@@ -1969,6 +2039,7 @@ func updateCodefreshCM(ctx context.Context, opts *RuntimeInstallOptions, rt *run
19692039 runtime .Spec .IngressClass = opts .IngressClass
19702040 runtime .Spec .IngressController = opts .IngressController .Name ()
19712041 runtime .Spec .IngressHost = opts .IngressHost
2042+ runtime .Spec .InternalIngressHost = opts .InternalIngressHost
19722043
19732044 marshalRuntime , err = yaml .Marshal (runtime )
19742045 if err != nil {
0 commit comments