Skip to content

Commit 1ab9631

Browse files
CR-14554-ir (#593)
* add internal router manifests + remove ingresses * add port * configure liveness/readyness * fixes * fix * fix * support internal and external ingress host * fixes * move argo-server to internal router + add upgrade command * return argo wf to external + add check for gateway installation on upgrade * small fix * fix comments + set correct version for go-sdk * change tunneller chart * fix argo workflows configuration * small fix * update version + scale down internal router * fix * fixes * fixes * fixes * fixes * fixes * fixes * update version * fixed missing tunnel client in tunnel mode * updated version to 0.0.542 * fixed upgrade command * fix Co-authored-by: Noam Gal <noam.gal@codefresh.io>
1 parent b6ec49c commit 1ab9631

File tree

19 files changed

+445
-247
lines changed

19 files changed

+445
-247
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.541
1+
VERSION=v0.0.542
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ var (
4747
die = util.Die
4848
exit = os.Exit
4949

50-
//go:embed assets/workflows-ingress-patch.json
51-
workflowsIngressPatch []byte
50+
//go:embed assets/workflows-route-patch.json
51+
workflowsRoutePatch []byte
5252

5353
cfConfig *config.Config
5454

cmd/commands/git-source.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
260260
AppName: opts.GsName,
261261
AppSpecifier: appSpecifier,
262262
DestServer: store.Get().InCluster,
263-
DestNamespace: opts.RuntimeName,
263+
DestNamespace: &opts.RuntimeName,
264264
IsInternal: &isInternal,
265265
Include: &opts.Include,
266266
Exclude: &opts.Exclude,
@@ -755,23 +755,6 @@ func createDemoCalendarTrigger() sensorsv1alpha1.Trigger {
755755
}
756756

757757
func createDemoGitPipeline(opts *gitSourceGitDemoPipelineOptions) error {
758-
if !opts.skipIngress && opts.accessMode == platmodel.AccessModeIngress {
759-
// Create an ingress that will manage external access to the git eventsource service
760-
routeOpts := routingutil.CreateRouteOpts{
761-
RuntimeName: opts.runtimeName,
762-
IngressClass: opts.ingressClass,
763-
Hostname: opts.hostName,
764-
IngressController: opts.ingressController,
765-
GatewayName: opts.gatewayName,
766-
GatewayNamespace: opts.gatewayNamespace,
767-
}
768-
routeName, route := routingutil.CreateDemoPipelinesRoute(&routeOpts, opts.useGatewayAPI)
769-
routeFilePath := fmt.Sprintf("%s.%s.yaml", store.Get().DemoPipelinesIngressObjectName, routeName)
770-
if err := writeObjectToYaml(opts.gsFs, routeFilePath, &route, cleanUpFieldsIngress); err != nil {
771-
return fmt.Errorf("failed to write yaml of demo pipeline ingress. Error: %w", err)
772-
}
773-
}
774-
775758
gitProviderType := opts.gitProvider.Type()
776759
switch gitProviderType {
777760
case "github":

cmd/commands/runtime.go

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"sync"
2828
"time"
2929

30+
routingutil "github.com/codefresh-io/cli-v2/pkg/util/routing"
31+
3032
"github.com/codefresh-io/cli-v2/pkg/log"
3133
"github.com/codefresh-io/cli-v2/pkg/reporter"
3234
"github.com/codefresh-io/cli-v2/pkg/runtime"
@@ -69,13 +71,13 @@ type (
6971

7072
RuntimeUpgradeOptions struct {
7173
RuntimeName string
72-
Version *semver.Version
7374
CloneOpts *apgit.CloneOptions
7475
CommonConfig *runtime.CommonConfig
7576
SuggestedSharedConfigRepo string
7677
DisableTelemetry bool
7778
runtimeDef string
7879

80+
versionStr string
7981
featuresToInstall []runtime.InstallFeature
8082
}
8183

@@ -787,6 +789,11 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
787789
finalParameters["Version"] = versionStr
788790
}
789791

792+
err = validateVersionIfExists(opts.versionStr)
793+
if err != nil {
794+
return err
795+
}
796+
790797
err = getApprovalFromUser(ctx, finalParameters, "runtime upgrade")
791798
if err != nil {
792799
return err
@@ -799,13 +806,6 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
799806
var err error
800807
ctx := cmd.Context()
801808

802-
if versionStr != "" {
803-
opts.Version, err = semver.NewVersion(versionStr)
804-
if err != nil {
805-
return err
806-
}
807-
}
808-
809809
opts.CommonConfig = &runtime.CommonConfig{
810810
CodefreshBaseURL: cfConfig.GetCurrentContext().URL,
811811
}
@@ -816,7 +816,7 @@ func NewRuntimeUpgradeCommand() *cobra.Command {
816816
},
817817
}
818818

819-
cmd.Flags().StringVar(&versionStr, "version", "", "The runtime version to upgrade to, defaults to latest")
819+
cmd.Flags().StringVar(&opts.versionStr, "version", "", "The runtime version to upgrade to, defaults to latest")
820820
cmd.Flags().StringVar(&opts.SuggestedSharedConfigRepo, "shared-config-repo", "", "URL to the shared configurations repo. (default: <installation-repo> or the existing one for this account)")
821821
cmd.Flags().BoolVar(&opts.DisableTelemetry, "disable-telemetry", false, "If true, will disable analytics reporting for the upgrade process")
822822
cmd.Flags().BoolVar(&store.Get().SetDefaultResources, "set-default-resources", false, "If true, will set default requests and limits on all of the runtime components")
@@ -834,7 +834,7 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
834834

835835
log.G(ctx).Info("Downloading runtime definition")
836836

837-
runtimeDef := getRuntimeDef(opts.runtimeDef, opts.Version.String())
837+
runtimeDef := getRuntimeDef(opts.runtimeDef, opts.versionStr)
838838
newRt, err := runtime.Download(runtimeDef, opts.RuntimeName, opts.featuresToInstall)
839839
handleCliStep(reporter.UpgradeStepDownloadRuntimeDefinition, "Downloading runtime definition", err, true, false)
840840
if err != nil {
@@ -897,6 +897,21 @@ func runRuntimeUpgrade(ctx context.Context, opts *RuntimeUpgradeOptions) error {
897897

898898
handleCliStep(reporter.UpgradeStepInstallNewComponents, "Install new components", err, false, false)
899899

900+
needsInternalRouter := curRt.Spec.Version.LessThan(semver.MustParse("v0.0.542"))
901+
isIngress := curRt.Spec.AccessMode == platmodel.AccessModeIngress
902+
isNotAlb := curRt.Spec.IngressController != string(routingutil.IngressControllerALB)
903+
904+
if needsInternalRouter && isIngress && isNotAlb {
905+
log.G(ctx).Info("Migrating to Internal Router ")
906+
907+
err = migrateInternalRouter(ctx, opts, newRt)
908+
if err != nil {
909+
return fmt.Errorf("failed to migrate internal router: %w", err)
910+
}
911+
912+
handleCliStep(reporter.UpgradeStepMigrateInternalRouter, "Migrate internal router", err, false, false)
913+
}
914+
900915
log.G(ctx).Infof("Runtime upgraded to version: v%s", newRt.Spec.Version)
901916

902917
return nil
@@ -922,6 +937,55 @@ func NewRuntimeLogsCommand() *cobra.Command {
922937
return cmd
923938
}
924939

940+
func migrateInternalRouter(ctx context.Context, opts *RuntimeUpgradeOptions, newRt *runtime.Runtime) error {
941+
dbRuntime, err := getRuntime(ctx, opts.RuntimeName)
942+
if err != nil {
943+
return fmt.Errorf("failed to get runtime: %s. Error: %w", opts.RuntimeName, err)
944+
}
945+
946+
gatewayName := ""
947+
gatewaysNamespace := ""
948+
949+
if dbRuntime.GatewayName != nil {
950+
gatewayName = *dbRuntime.GatewayName
951+
}
952+
953+
if dbRuntime.GatewayNamespace != nil {
954+
gatewaysNamespace = *dbRuntime.GatewayNamespace
955+
}
956+
957+
createOpts := &CreateIngressOptions{
958+
IngressHost: newRt.Spec.IngressHost,
959+
IngressClass: newRt.Spec.IngressClass,
960+
InternalIngressHost: newRt.Spec.InternalIngressHost,
961+
IngressController: routingutil.GetIngressController(newRt.Spec.IngressController),
962+
InsCloneOpts: opts.CloneOpts,
963+
useGatewayAPI: gatewayName != "",
964+
GatewayName: gatewayName,
965+
GatewayNamespace: gatewaysNamespace,
966+
}
967+
968+
if err = parseHostName(newRt.Spec.IngressHost, &createOpts.HostName); err != nil {
969+
return err
970+
}
971+
972+
if createOpts.InternalIngressHost != "" {
973+
if err := parseHostName(newRt.Spec.InternalIngressHost, &createOpts.InternalHostName); err != nil {
974+
return err
975+
}
976+
}
977+
978+
if err := util.Retry(ctx, &util.RetryOptions{
979+
Func: func() error {
980+
return CreateInternalRouterIngress(ctx, createOpts, newRt)
981+
},
982+
}); err != nil {
983+
return fmt.Errorf("failed to patch Internal Router ingress: %w", err)
984+
}
985+
986+
return nil
987+
}
988+
925989
func isAllRequiredFlagsForDownloadRuntimeLogs() bool {
926990
return store.Get().IsDownloadRuntimeLogs && store.Get().IngressHost != ""
927991
}

0 commit comments

Comments
 (0)