diff --git a/install/installer/cmd/mirror_list.go b/install/installer/cmd/mirror_list.go index d75a7460ef345d..d75be508bd606a 100644 --- a/install/installer/cmd/mirror_list.go +++ b/install/installer/cmd/mirror_list.go @@ -15,6 +15,7 @@ import ( "github.com/gitpod-io/gitpod/installer/pkg/common" configv1 "github.com/gitpod-io/gitpod/installer/pkg/config/v1" "github.com/spf13/cobra" + "k8s.io/utils/pointer" ) type mirrorListRepo struct { @@ -85,6 +86,117 @@ func init() { mirrorListCmd.Flags().StringVarP(&mirrorListOpts.ConfigFN, "config", "c", os.Getenv("GITPOD_INSTALLER_CONFIG"), "path to the config file") } +func renderAllKubernetesObject(cfgVersion string, cfg *configv1.Config) ([]string, error) { + fns := []func() ([]string, error){ + func() ([]string, error) { + // Render for in-cluster dependencies + return renderKubernetesObjects(cfgVersion, cfg) + }, + func() ([]string, error) { + // Render for external depedencies - AWS + cfg.Database = configv1.Database{ + InCluster: pointer.Bool(false), + External: &configv1.DatabaseExternal{ + Certificate: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + cfg.ContainerRegistry = configv1.ContainerRegistry{ + InCluster: pointer.Bool(false), + External: &configv1.ContainerRegistryExternal{ + URL: "some-url", + Certificate: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + S3Storage: &configv1.S3Storage{ + Bucket: "some-bucket", + Certificate: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + cfg.ObjectStorage = configv1.ObjectStorage{ + InCluster: pointer.Bool(false), + S3: &configv1.ObjectStorageS3{ + Endpoint: "endpoint", + Credentials: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + return renderKubernetesObjects(cfgVersion, cfg) + }, + func() ([]string, error) { + // Render for external depedencies - Azure + cfg.Database.CloudSQL = nil + cfg.ContainerRegistry = configv1.ContainerRegistry{ + InCluster: pointer.Bool(false), + External: &configv1.ContainerRegistryExternal{ + URL: "some-url", + Certificate: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + cfg.ObjectStorage = configv1.ObjectStorage{ + InCluster: pointer.Bool(false), + Azure: &configv1.ObjectStorageAzure{ + Credentials: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + + return renderKubernetesObjects(cfgVersion, cfg) + }, + func() ([]string, error) { + // Render for external depedencies - GCP + cfg.Database = configv1.Database{ + InCluster: pointer.Bool(false), + CloudSQL: &configv1.DatabaseCloudSQL{ + Instance: "value", + ServiceAccount: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + cfg.ObjectStorage = configv1.ObjectStorage{ + InCluster: pointer.Bool(false), + CloudStorage: &configv1.ObjectStorageCloudStorage{ + Project: "project", + ServiceAccount: configv1.ObjectRef{ + Kind: configv1.ObjectRefSecret, + Name: "value", + }, + }, + } + + return renderKubernetesObjects(cfgVersion, cfg) + }, + } + + var k8s []string + for _, fn := range fns { + data, err := fn() + if err != nil { + return nil, err + } + + k8s = append(k8s, data...) + } + + return k8s, nil +} + func generateMirrorList(cfgVersion string, cfg *configv1.Config) ([]mirrorListRepo, error) { // Throw error if set to the default Gitpod repository if cfg.Repository == common.GitpodContainerRegistry { @@ -97,7 +209,7 @@ func generateMirrorList(cfgVersion string, cfg *configv1.Config) ([]mirrorListRe // Use the default Gitpod registry to pull from cfg.Repository = common.GitpodContainerRegistry - k8s, err := renderKubernetesObjects(cfgVersion, cfg) + k8s, err := renderAllKubernetesObject(cfgVersion, cfg) if err != nil { return nil, err } diff --git a/install/installer/pkg/common/ca.go b/install/installer/pkg/common/ca.go index 42b5a0202d977c..da20780aed091d 100644 --- a/install/installer/pkg/common/ca.go +++ b/install/installer/pkg/common/ca.go @@ -39,7 +39,7 @@ func InternalCAContainer(ctx *RenderContext, mod ...func(*corev1.Container)) *co res := &corev1.Container{ Name: "update-ca-certificates", // It's not possible to use images based on alpine due to errors running update-ca-certificates - Image: ImageName(ctx.Config.Repository, "ca-updater", ctx.VersionManifest.Components.CAUpdater.Version), + Image: ctx.ImageName(ctx.Config.Repository, "ca-updater", ctx.VersionManifest.Components.CAUpdater.Version), ImagePullPolicy: corev1.PullIfNotPresent, Command: []string{ "bash", "-c", diff --git a/install/installer/pkg/common/common.go b/install/installer/pkg/common/common.go index 806b81c1b47d5c..65a8829af00041 100644 --- a/install/installer/pkg/common/common.go +++ b/install/installer/pkg/common/common.go @@ -16,7 +16,6 @@ import ( config "github.com/gitpod-io/gitpod/installer/pkg/config/v1" "github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental" - "github.com/docker/distribution/reference" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" @@ -248,7 +247,7 @@ func DatabaseEnv(cfg *config.Config) (res []corev1.EnvVar) { func DatabaseWaiterContainer(ctx *RenderContext) *corev1.Container { return &corev1.Container{ Name: "database-waiter", - Image: ImageName(ctx.Config.Repository, "service-waiter", ctx.VersionManifest.Components.ServiceWaiter.Version), + Image: ctx.ImageName(ctx.Config.Repository, "service-waiter", ctx.VersionManifest.Components.ServiceWaiter.Version), Args: []string{ "-v", "database", @@ -266,7 +265,7 @@ func DatabaseWaiterContainer(ctx *RenderContext) *corev1.Container { func MessageBusWaiterContainer(ctx *RenderContext) *corev1.Container { return &corev1.Container{ Name: "msgbus-waiter", - Image: ImageName(ctx.Config.Repository, "service-waiter", ctx.VersionManifest.Components.ServiceWaiter.Version), + Image: ctx.ImageName(ctx.Config.Repository, "service-waiter", ctx.VersionManifest.Components.ServiceWaiter.Version), Args: []string{ "-v", "messagebus", @@ -284,7 +283,7 @@ func MessageBusWaiterContainer(ctx *RenderContext) *corev1.Container { func KubeRBACProxyContainer(ctx *RenderContext) *corev1.Container { return &corev1.Container{ Name: "kube-rbac-proxy", - Image: ImageName(ThirdPartyContainerRepo(ctx.Config.Repository, KubeRBACProxyRepo), KubeRBACProxyImage, KubeRBACProxyTag), + Image: ctx.ImageName(ThirdPartyContainerRepo(ctx.Config.Repository, KubeRBACProxyRepo), KubeRBACProxyImage, KubeRBACProxyTag), Args: []string{ "--v=5", "--logtostderr", @@ -339,33 +338,6 @@ func Affinity(orLabels ...string) *corev1.Affinity { } } -func RepoName(repo, name string) string { - var ref string - if repo == "" { - ref = name - } else { - ref = fmt.Sprintf("%s/%s", strings.TrimSuffix(repo, "/"), name) - } - pref, err := reference.ParseNormalizedNamed(ref) - if err != nil { - panic(fmt.Sprintf("cannot parse image repo %s: %v", ref, err)) - } - return pref.String() -} - -func ImageName(repo, name, tag string) string { - ref := fmt.Sprintf("%s:%s", RepoName(repo, name), tag) - pref, err := reference.ParseNamed(ref) - if err != nil { - panic(fmt.Sprintf("cannot parse image ref %s: %v", ref, err)) - } - if _, ok := pref.(reference.Tagged); !ok { - panic(fmt.Sprintf("image ref %s has no tag: %v", ref, err)) - } - - return ref -} - // ObjectHash marshals the objects to YAML and produces a sha256 hash of the output. // This function is useful for restarting pods when the config changes. // Takes an error as argument to make calling it more conventient. If that error is not nil, diff --git a/install/installer/pkg/common/common_test.go b/install/installer/pkg/common/common_test.go deleted file mode 100644 index 8ba4236c47833d..00000000000000 --- a/install/installer/pkg/common/common_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2021 Gitpod GmbH. All rights reserved. -// Licensed under the GNU Affero General Public License (AGPL). -// See License-AGPL.txt in the project root for license information. - -package common_test - -import ( - "github.com/gitpod-io/gitpod/installer/pkg/common" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestRepoName(t *testing.T) { - type Expectation struct { - Result string - Panics bool - } - tests := []struct { - Repo string - Name string - Expectation Expectation - }{ - { - Name: "gitpod-io/workspace-full", - Expectation: Expectation{ - Result: "docker.io/gitpod-io/workspace-full", - }, - }, - { - Repo: "some-repo.com", - Name: "some-image", - Expectation: Expectation{ - Result: "some-repo.com/some-image", - }, - }, - { - Repo: "some-repo", - Name: "not@avalid#image-name", - Expectation: Expectation{ - Panics: true, - }, - }, - } - - for _, test := range tests { - t.Run(test.Repo+"/"+test.Name, func(t *testing.T) { - var act Expectation - func() { - defer func() { - if recover() != nil { - act.Panics = true - } - }() - act.Result = common.RepoName(test.Repo, test.Name) - }() - - if diff := cmp.Diff(test.Expectation, act); diff != "" { - t.Errorf("RepoName() mismatch (-want +got):\n%s", diff) - } - }) - } -} diff --git a/install/installer/pkg/common/render.go b/install/installer/pkg/common/render.go index 9ba0883512210f..1044fc93f06654 100644 --- a/install/installer/pkg/common/render.go +++ b/install/installer/pkg/common/render.go @@ -5,12 +5,17 @@ package common import ( + "fmt" + "strings" + + "github.com/docker/distribution/reference" "github.com/gitpod-io/gitpod/installer/pkg/config/v1" "github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental" "github.com/gitpod-io/gitpod/installer/pkg/config/versions" "helm.sh/helm/v3/pkg/cli/values" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/pointer" ) // Renderable turns the config into a set of Kubernetes runtime objects @@ -85,6 +90,39 @@ func (r *RenderContext) WithExperimental(mod func(ucfg *experimental.Config) err return mod(r.experimentalConfig) } +func (r *RenderContext) RepoName(repo, name string) string { + var ref string + if repo == "" { + ref = name + } else { + ref = fmt.Sprintf("%s/%s", strings.TrimSuffix(repo, "/"), name) + } + pref, err := reference.ParseNormalizedNamed(ref) + if err != nil { + panic(fmt.Sprintf("cannot parse image repo %s: %v", ref, err)) + } + + if pointer.BoolDeref(r.Config.DropImageRepo, false) { + segs := strings.Split(reference.Path(pref), "/") + return fmt.Sprintf("%s/%s", r.Config.Repository, segs[len(segs)-1]) + } + + return pref.String() +} + +func (r *RenderContext) ImageName(repo, name, tag string) string { + ref := fmt.Sprintf("%s:%s", r.RepoName(repo, name), tag) + pref, err := reference.ParseNamed(ref) + if err != nil { + panic(fmt.Sprintf("cannot parse image ref %s: %v", ref, err)) + } + if _, ok := pref.(reference.Tagged); !ok { + panic(fmt.Sprintf("image ref %s has no tag: %v", ref, err)) + } + + return ref +} + // generateValues generates the random values used throughout the context // todo(sje): find a way of persisting these values for updates func (r *RenderContext) generateValues() error { diff --git a/install/installer/pkg/common/render_test.go b/install/installer/pkg/common/render_test.go index f1b419921940af..2dcf60283d82bb 100644 --- a/install/installer/pkg/common/render_test.go +++ b/install/installer/pkg/common/render_test.go @@ -4,11 +4,14 @@ package common import ( + "testing" + "github.com/gitpod-io/gitpod/installer/pkg/config/v1" "github.com/gitpod-io/gitpod/installer/pkg/config/versions" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/runtime" - "testing" + "k8s.io/utils/pointer" ) func TestCompositeRenderFunc_NilObjectsNilError(t *testing.T) { @@ -24,3 +27,117 @@ func TestCompositeRenderFunc_NilObjectsNilError(t *testing.T) { require.NoError(t, err) require.Len(t, objects, 0) } + +func TestRepoName(t *testing.T) { + type Expectation struct { + Result string + Panics bool + } + tests := []struct { + Repo string + Name string + Expectation Expectation + CfgRepo string + DropImageRepo *bool + }{ + { + Name: "gitpod-io/workspace-full", + Expectation: Expectation{ + Result: "docker.io/gitpod-io/workspace-full", + }, + }, + { + Repo: "some-repo.com", + Name: "some-image", + Expectation: Expectation{ + Result: "some-repo.com/some-image", + }, + }, + { + Repo: "some-repo", + Name: "not@avalid#image-name", + Expectation: Expectation{ + Panics: true, + }, + }, + // Drop repo, no namespace + { + Name: "gitpod-io/workspace-full", + Expectation: Expectation{ + Result: "some.registry.com/workspace-full", + }, + CfgRepo: "some.registry.com", + DropImageRepo: pointer.Bool(true), + }, + { + Repo: "some-repo.com", + Name: "some-image", + Expectation: Expectation{ + Result: "some.registry.com/some-image", + }, + CfgRepo: "some.registry.com", + DropImageRepo: pointer.Bool(true), + }, + { + Repo: "some-repo", + Name: "not@avalid#image-name", + Expectation: Expectation{ + Panics: true, + }, + CfgRepo: "some.registry.com", + DropImageRepo: pointer.Bool(true), + }, + // Drop repo, namespace + { + Name: "gitpod-io/workspace-full", + Expectation: Expectation{ + Result: "some.registry.com/gitpod/workspace-full", + }, + CfgRepo: "some.registry.com/gitpod", + DropImageRepo: pointer.Bool(true), + }, + { + Repo: "some-repo.com", + Name: "some-image", + Expectation: Expectation{ + Result: "some.registry.com/gitpod/some-image", + }, + CfgRepo: "some.registry.com/gitpod", + DropImageRepo: pointer.Bool(true), + }, + { + Repo: "some-repo", + Name: "not@avalid#image-name", + Expectation: Expectation{ + Panics: true, + }, + CfgRepo: "some.registry.com/gitpod", + DropImageRepo: pointer.Bool(true), + }, + } + + for _, test := range tests { + t.Run(test.Repo+"/"+test.Name, func(t *testing.T) { + var act Expectation + func() { + defer func() { + if recover() != nil { + act.Panics = true + } + }() + + ctx, err := NewRenderContext(config.Config{ + DropImageRepo: test.DropImageRepo, + Repository: test.CfgRepo, + }, versions.Manifest{}, "test_namespace") + require.NoError(t, err) + + act.Result = ctx.RepoName(test.Repo, test.Name) + }() + + if diff := cmp.Diff(test.Expectation, act); diff != "" { + t.Errorf("RepoName() mismatch (-want +got):\n%s", diff) + } + }) + } +} diff --git a/install/installer/pkg/components/agent-smith/daemonset.go b/install/installer/pkg/components/agent-smith/daemonset.go index 77feb29829d8c4..caf0eee4f4ae00 100644 --- a/install/installer/pkg/components/agent-smith/daemonset.go +++ b/install/installer/pkg/components/agent-smith/daemonset.go @@ -51,7 +51,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { TerminationGracePeriodSeconds: pointer.Int64(30), Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.AgentSmith.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.AgentSmith.Version), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{"run", "--config", "/config/config.json"}, Resources: corev1.ResourceRequirements{ diff --git a/install/installer/pkg/components/blobserve/configmap.go b/install/installer/pkg/components/blobserve/configmap.go index bf63eeec5704c1..83f25aad8188e7 100644 --- a/install/installer/pkg/components/blobserve/configmap.go +++ b/install/installer/pkg/components/blobserve/configmap.go @@ -35,7 +35,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Port: ContainerPort, Timeout: util.Duration(time.Second * 5), Repos: map[string]blobserve.Repo{ - common.RepoName(ctx.Config.Repository, ide.CodeIDEImage): { + ctx.RepoName(ctx.Config.Repository, ide.CodeIDEImage): { PrePull: []string{}, Workdir: "/ide", Replacements: []blobserve.StringReplacement{{ @@ -88,7 +88,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Replacement: "${supervisor}", }}, }, - common.RepoName(ctx.Config.Repository, workspace.SupervisorImage): { + ctx.RepoName(ctx.Config.Repository, workspace.SupervisorImage): { PrePull: []string{}, Workdir: "/.supervisor/frontend", }, diff --git a/install/installer/pkg/components/blobserve/deployment.go b/install/installer/pkg/components/blobserve/deployment.go index dac76e434ca770..10c5a6479467e8 100644 --- a/install/installer/pkg/components/blobserve/deployment.go +++ b/install/installer/pkg/components/blobserve/deployment.go @@ -94,7 +94,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Containers: []corev1.Container{{ Name: Component, Args: []string{"run", "/mnt/config/config.json"}, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Blobserve.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Blobserve.Version), ImagePullPolicy: corev1.PullIfNotPresent, Ports: []corev1.ContainerPort{{ Name: ServicePortName, diff --git a/install/installer/pkg/components/content-service/deployment.go b/install/installer/pkg/components/content-service/deployment.go index e6906ad2768324..3b36f122d52cce 100644 --- a/install/installer/pkg/components/content-service/deployment.go +++ b/install/installer/pkg/components/content-service/deployment.go @@ -41,7 +41,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }}, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ContentService.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ContentService.Version), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "run", diff --git a/install/installer/pkg/components/dashboard/deployment.go b/install/installer/pkg/components/dashboard/deployment.go index 270a4bc45ac276..286aef3e75fb47 100644 --- a/install/installer/pkg/components/dashboard/deployment.go +++ b/install/installer/pkg/components/dashboard/deployment.go @@ -48,7 +48,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { TerminationGracePeriodSeconds: pointer.Int64(30), Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Dashboard.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Dashboard.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/database/cloudsql/deployment.go b/install/installer/pkg/components/database/cloudsql/deployment.go index 9ed634fd38e18e..c39057252015ac 100644 --- a/install/installer/pkg/components/database/cloudsql/deployment.go +++ b/install/installer/pkg/components/database/cloudsql/deployment.go @@ -65,7 +65,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Privileged: pointer.Bool(false), RunAsNonRoot: pointer.Bool(false), }, - Image: common.ImageName(ImageRepo, ImageName, ImageVersion), + Image: ctx.ImageName(ImageRepo, ImageName, ImageVersion), Command: []string{ "/cloud_sql_proxy", "-dir=/cloudsql", diff --git a/install/installer/pkg/components/database/incluster/helm.go b/install/installer/pkg/components/database/incluster/helm.go index 8bb44cd1397aab..6fae3cbe60ec37 100644 --- a/install/installer/pkg/components/database/incluster/helm.go +++ b/install/installer/pkg/components/database/incluster/helm.go @@ -34,12 +34,15 @@ var Helm = common.CompositeHelmFunc( helm.KeyValue("mysql.initdbScriptsConfigMap", SQLInitScripts), helm.KeyValue("mysql.serviceAccount.name", Component), helm.ImagePullSecrets("mysql.image.pullSecrets", cfg), - helm.KeyValue("mysql.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("mysql.image.registry", ""), + helm.KeyValue("mysql.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/mysql")), helm.ImagePullSecrets("mysql.metrics.image.pullSecrets", cfg), - helm.KeyValue("mysql.metrics.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("mysql.metrics.image.registry", ""), + helm.KeyValue("mysql.metrics.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/mysqld-exporter")), helm.ImagePullSecrets("mysql.volumePermissions.image.pullSecrets", cfg), helm.KeyValue("mysql.volumePermissions.image.pullPolicy", "IfNotPresent"), - helm.KeyValue("mysql.volumePermissions.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("mysql.volumePermissions.image.registry", ""), + helm.KeyValue("mysql.volumePermissions.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/bitnami-shell")), // improve start time helm.KeyValue("mysql.primary.startupProbe.enabled", "false"), diff --git a/install/installer/pkg/components/database/init/job.go b/install/installer/pkg/components/database/init/job.go index 4feda70b099b1d..ec2f2725240a90 100644 --- a/install/installer/pkg/components/database/init/job.go +++ b/install/installer/pkg/components/database/init/job.go @@ -47,7 +47,7 @@ func job(ctx *common.RenderContext) ([]runtime.Object, error) { InitContainers: []corev1.Container{*common.DatabaseWaiterContainer(ctx)}, Containers: []corev1.Container{{ Name: fmt.Sprintf("%s-session", Component), - Image: common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), dbSessionsImage, dbSessionsTag), + Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), dbSessionsImage, dbSessionsTag), ImagePullPolicy: corev1.PullIfNotPresent, Env: common.MergeEnv( common.DatabaseEnv(&ctx.Config), diff --git a/install/installer/pkg/components/docker-registry/helm.go b/install/installer/pkg/components/docker-registry/helm.go index dca86783252bf4..b6fc543437558f 100644 --- a/install/installer/pkg/components/docker-registry/helm.go +++ b/install/installer/pkg/components/docker-registry/helm.go @@ -23,7 +23,7 @@ var Helm = common.CompositeHelmFunc( return nil, err } - repository := fmt.Sprintf("%s/library/registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)) + repository := cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "library/registry") registryValues := []string{ helm.KeyValue(fmt.Sprintf("docker-registry.podAnnotations.%s", strings.Replace(common.AnnotationConfigChecksum, ".", "\\.", -1)), secretHash), diff --git a/install/installer/pkg/components/gitpod/cronjob.go b/install/installer/pkg/components/gitpod/cronjob.go index 0dfb8a3e80b545..dcc5ca53885d69 100644 --- a/install/installer/pkg/components/gitpod/cronjob.go +++ b/install/installer/pkg/components/gitpod/cronjob.go @@ -53,7 +53,7 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) { Containers: []v1.Container{ { Name: installationTelemetryComponent, - Image: common.ImageName(ctx.Config.Repository, "installation-telemetry", ctx.VersionManifest.Components.InstallationTelemetry.Version), + Image: ctx.ImageName(ctx.Config.Repository, "installation-telemetry", ctx.VersionManifest.Components.InstallationTelemetry.Version), ImagePullPolicy: v1.PullIfNotPresent, Args: []string{ "send", diff --git a/install/installer/pkg/components/ide-proxy/deployment.go b/install/installer/pkg/components/ide-proxy/deployment.go index bf8fd4e50beb1d..20d4de6e5d59c5 100644 --- a/install/installer/pkg/components/ide-proxy/deployment.go +++ b/install/installer/pkg/components/ide-proxy/deployment.go @@ -48,7 +48,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { TerminationGracePeriodSeconds: pointer.Int64(30), Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.IDEProxy.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.IDEProxy.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/image-builder-mk3/configmap.go b/install/installer/pkg/components/image-builder-mk3/configmap.go index d8af2a55a2eaa8..74f647b6c161a0 100644 --- a/install/installer/pkg/components/image-builder-mk3/configmap.go +++ b/install/installer/pkg/components/image-builder-mk3/configmap.go @@ -49,7 +49,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { PullSecret: secretName, PullSecretFile: PullSecretFile, BaseImageRepository: fmt.Sprintf("%s/base-images", registryName), - BuilderImage: common.ImageName(ctx.Config.Repository, BuilderImage, ctx.VersionManifest.Components.ImageBuilderMk3.BuilderImage.Version), + BuilderImage: ctx.ImageName(ctx.Config.Repository, BuilderImage, ctx.VersionManifest.Components.ImageBuilderMk3.BuilderImage.Version), WorkspaceImageRepository: fmt.Sprintf("%s/workspace-images", registryName), } @@ -58,7 +58,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { RefCache: config.RefCacheConfig{ Interval: util.Duration(time.Hour * 6).String(), Refs: []string{ - common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), workspace.DefaultWorkspaceImage, workspace.DefaultWorkspaceImageVersion), + ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), workspace.DefaultWorkspaceImage, workspace.DefaultWorkspaceImageVersion), }, }, Service: config.Service{ diff --git a/install/installer/pkg/components/image-builder-mk3/deployment.go b/install/installer/pkg/components/image-builder-mk3/deployment.go index 8888dd9d869932..5419235ab43b4d 100644 --- a/install/installer/pkg/components/image-builder-mk3/deployment.go +++ b/install/installer/pkg/components/image-builder-mk3/deployment.go @@ -143,7 +143,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ImageBuilderMk3.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ImageBuilderMk3.Version), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "run", diff --git a/install/installer/pkg/components/migrations/job.go b/install/installer/pkg/components/migrations/job.go index c96726928bf370..596a8251a3fb7e 100644 --- a/install/installer/pkg/components/migrations/job.go +++ b/install/installer/pkg/components/migrations/job.go @@ -37,7 +37,7 @@ func job(ctx *common.RenderContext) ([]runtime.Object, error) { InitContainers: []corev1.Container{*common.DatabaseWaiterContainer(ctx)}, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, "db-migrations", ctx.VersionManifest.Components.DBMigrations.Version), + Image: ctx.ImageName(ctx.Config.Repository, "db-migrations", ctx.VersionManifest.Components.DBMigrations.Version), ImagePullPolicy: corev1.PullIfNotPresent, Env: common.MergeEnv( common.DatabaseEnv(&ctx.Config), diff --git a/install/installer/pkg/components/minio/helm.go b/install/installer/pkg/components/minio/helm.go index 62b56ae36562e7..49124ca6bf5c68 100644 --- a/install/installer/pkg/components/minio/helm.go +++ b/install/installer/pkg/components/minio/helm.go @@ -18,9 +18,11 @@ var Helm = common.CompositeHelmFunc( func(cfg *common.RenderContext) ([]string, error) { commonHelmValues := []string{ helm.ImagePullSecrets("minio.image.pullSecrets", cfg), - helm.KeyValue("minio.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("minio.image.registry", ""), + helm.KeyValue("minio.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/minio")), helm.ImagePullSecrets("minio.volumePermissions.image.pullSecrets", cfg), - helm.KeyValue("minio.volumePermissions.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("minio.volumePermissions.image.registry", ""), + helm.KeyValue("minio.volumePermissions.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/bitnami-shell")), } if pointer.BoolDeref(cfg.Config.ObjectStorage.InCluster, false) { diff --git a/install/installer/pkg/components/openvsx-proxy/statefulset.go b/install/installer/pkg/components/openvsx-proxy/statefulset.go index 3ab43134840b57..ae038218c08d01 100644 --- a/install/installer/pkg/components/openvsx-proxy/statefulset.go +++ b/install/installer/pkg/components/openvsx-proxy/statefulset.go @@ -68,7 +68,7 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { }}, Containers: []v1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.OpenVSXProxy.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.OpenVSXProxy.Version), Args: []string{"/config/config.json"}, ReadinessProbe: &v1.Probe{ ProbeHandler: v1.ProbeHandler{ @@ -101,7 +101,7 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { ), }, { Name: "redis", - Image: common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), "library/redis", "6.2"), + Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), "library/redis", "6.2"), Command: []string{ "redis-server", "/config/redis.conf", diff --git a/install/installer/pkg/components/proxy/deployment.go b/install/installer/pkg/components/proxy/deployment.go index 8efd35c7c92857..c64d3d78034a53 100644 --- a/install/installer/pkg/components/proxy/deployment.go +++ b/install/installer/pkg/components/proxy/deployment.go @@ -130,7 +130,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Volumes: volumes, InitContainers: []corev1.Container{{ Name: "sysctl", - Image: common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), InitContainerImage, InitContainerTag), + Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), InitContainerImage, InitContainerTag), ImagePullPolicy: corev1.PullIfNotPresent, SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(true), @@ -143,7 +143,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }}, Containers: []corev1.Container{{ Name: "kube-rbac-proxy", - Image: common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, KubeRBACProxyRepo), KubeRBACProxyImage, KubeRBACProxyTag), + Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, KubeRBACProxyRepo), KubeRBACProxyImage, KubeRBACProxyTag), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{ "--v=10", @@ -178,7 +178,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }, }, { Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Proxy.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Proxy.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/public-api-server/deployment.go b/install/installer/pkg/components/public-api-server/deployment.go index dd17a666f431ca..97b5e94c1c080f 100644 --- a/install/installer/pkg/components/public-api-server/deployment.go +++ b/install/installer/pkg/components/public-api-server/deployment.go @@ -61,7 +61,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { TerminationGracePeriodSeconds: pointer.Int64(30), Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.PublicAPIServer.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.PublicAPIServer.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/rabbitmq/helm.go b/install/installer/pkg/components/rabbitmq/helm.go index 003033ff080792..543fbf39bea10b 100644 --- a/install/installer/pkg/components/rabbitmq/helm.go +++ b/install/installer/pkg/components/rabbitmq/helm.go @@ -196,9 +196,11 @@ var Helm = common.CompositeHelmFunc( helm.KeyValue(fmt.Sprintf("rabbitmq.extraSecrets.%s.username", InClusterDbSecret), username), helm.KeyValue(fmt.Sprintf("rabbitmq.extraSecrets.%s.password", InClusterDbSecret), password), helm.ImagePullSecrets("rabbitmq.image.pullSecrets", cfg), - helm.KeyValue("rabbitmq.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("rabbitmq.image.registry", ""), + helm.KeyValue("rabbitmq.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/rabbitmq")), helm.ImagePullSecrets("volumePermissions.image.pullSecrets", cfg), - helm.KeyValue("rabbitmq.volumePermissions.image.registry", common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL)), + helm.KeyValue("rabbitmq.volumePermissions.image.registry", ""), + helm.KeyValue("rabbitmq.volumePermissions.image.repository", cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "bitnami/bitnami-shell")), helm.KeyValue("rabbitmq.livenessProbe.initialDelaySeconds", "30"), }, diff --git a/install/installer/pkg/components/registry-facade/configmap.go b/install/installer/pkg/components/registry-facade/configmap.go index 2ba9d11924045c..05bc046dd04083 100644 --- a/install/installer/pkg/components/registry-facade/configmap.go +++ b/install/installer/pkg/components/registry-facade/configmap.go @@ -71,15 +71,15 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { RequireAuth: false, StaticLayer: []regfac.StaticLayerCfg{ { - Ref: common.ImageName(ctx.Config.Repository, SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), + Ref: ctx.ImageName(ctx.Config.Repository, SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), Type: "image", }, { - Ref: common.ImageName(ctx.Config.Repository, WorkspacekitImage, ctx.VersionManifest.Components.Workspace.Workspacekit.Version), + Ref: ctx.ImageName(ctx.Config.Repository, WorkspacekitImage, ctx.VersionManifest.Components.Workspace.Workspacekit.Version), Type: "image", }, { - Ref: common.ImageName(ctx.Config.Repository, DockerUpImage, ctx.VersionManifest.Components.Workspace.DockerUp.Version), + Ref: ctx.ImageName(ctx.Config.Repository, DockerUpImage, ctx.VersionManifest.Components.Workspace.DockerUp.Version), Type: "image", }, }, diff --git a/install/installer/pkg/components/registry-facade/daemonset.go b/install/installer/pkg/components/registry-facade/daemonset.go index d972a69a7dd5ef..ac37d623c39f7e 100644 --- a/install/installer/pkg/components/registry-facade/daemonset.go +++ b/install/installer/pkg/components/registry-facade/daemonset.go @@ -179,7 +179,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { }, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.RegistryFacade.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.RegistryFacade.Version), ImagePullPolicy: corev1.PullIfNotPresent, Args: []string{"run", "/mnt/config/config.json"}, Resources: corev1.ResourceRequirements{ diff --git a/install/installer/pkg/components/server/configmap.go b/install/installer/pkg/components/server/configmap.go index 85c9753ad5ec29..50c0889ca093c8 100644 --- a/install/installer/pkg/components/server/configmap.go +++ b/install/installer/pkg/components/server/configmap.go @@ -32,7 +32,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { license = licenseFilePath } - workspaceImage := common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), workspace.DefaultWorkspaceImage, workspace.DefaultWorkspaceImageVersion) + workspaceImage := ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, ""), workspace.DefaultWorkspaceImage, workspace.DefaultWorkspaceImageVersion) _ = ctx.WithExperimental(func(cfg *experimental.Config) error { if cfg.WebApp != nil && cfg.WebApp.Server != nil && cfg.WebApp.Server.WorkspaceDefaults.WorkspaceImage != "" { workspaceImage = cfg.WebApp.Server.WorkspaceDefaults.WorkspaceImage diff --git a/install/installer/pkg/components/server/deployment.go b/install/installer/pkg/components/server/deployment.go index dc141d017b5f32..8e3fa3b04c706f 100644 --- a/install/installer/pkg/components/server/deployment.go +++ b/install/installer/pkg/components/server/deployment.go @@ -224,7 +224,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { InitContainers: []corev1.Container{*common.DatabaseWaiterContainer(ctx), *common.MessageBusWaiterContainer(ctx)}, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Server.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Server.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/server/ide/configmap.go b/install/installer/pkg/components/server/ide/configmap.go index 757f85256e10b7..91ade226fb6830 100644 --- a/install/installer/pkg/components/server/ide/configmap.go +++ b/install/installer/pkg/components/server/ide/configmap.go @@ -42,13 +42,13 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { return nil }) if resolveLatest { - return common.ImageName(ctx.Config.Repository, name, tag) + return ctx.ImageName(ctx.Config.Repository, name, tag) } - return common.ImageName(ctx.Config.Repository, name, bundledLatest.Version) + return ctx.ImageName(ctx.Config.Repository, name, bundledLatest.Version) } idecfg := IDEConfig{ - SupervisorImage: common.ImageName(ctx.Config.Repository, workspace.SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), + SupervisorImage: ctx.ImageName(ctx.Config.Repository, workspace.SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), IDEOptions: IDEOptions{ IDEClients: map[string]IDEClient{ "vscode": { @@ -80,7 +80,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Type: typeBrowser, Label: pointer.String("Browser"), Logo: getIdeLogoPath("vscode"), - Image: common.ImageName(ctx.Config.Repository, ide.CodeIDEImage, ide.CodeIDEImageStableVersion), + Image: ctx.ImageName(ctx.Config.Repository, ide.CodeIDEImage, ide.CodeIDEImageStableVersion), LatestImage: resolveLatestImage(ide.CodeIDEImage, "nightly", ctx.VersionManifest.Components.Workspace.CodeImage), }, codeDesktop: { @@ -88,15 +88,15 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Title: "VS Code", Type: typeDesktop, Logo: getIdeLogoPath("vscode"), - Image: common.ImageName(ctx.Config.Repository, ide.CodeDesktopIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.CodeDesktopImage.Version), - LatestImage: common.ImageName(ctx.Config.Repository, ide.CodeDesktopInsidersIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.CodeDesktopImageInsiders.Version), + Image: ctx.ImageName(ctx.Config.Repository, ide.CodeDesktopIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.CodeDesktopImage.Version), + LatestImage: ctx.ImageName(ctx.Config.Repository, ide.CodeDesktopInsidersIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.CodeDesktopImageInsiders.Version), }, intellij: { OrderKey: pointer.String("04"), Title: "IntelliJ IDEA", Type: typeDesktop, Logo: getIdeLogoPath("intellijIdeaLogo"), - Image: common.ImageName(ctx.Config.Repository, ide.IntelliJDesktopIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.IntelliJImage.Version), + Image: ctx.ImageName(ctx.Config.Repository, ide.IntelliJDesktopIDEImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.IntelliJImage.Version), LatestImage: resolveLatestImage(ide.IntelliJDesktopIDEImage, "latest", ctx.VersionManifest.Components.Workspace.DesktopIdeImages.IntelliJLatestImage), }, goland: { @@ -104,7 +104,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Title: "GoLand", Type: typeDesktop, Logo: getIdeLogoPath("golandLogo"), - Image: common.ImageName(ctx.Config.Repository, ide.GoLandDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.GoLandImage.Version), + Image: ctx.ImageName(ctx.Config.Repository, ide.GoLandDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.GoLandImage.Version), LatestImage: resolveLatestImage(ide.GoLandDesktopIdeImage, "latest", ctx.VersionManifest.Components.Workspace.DesktopIdeImages.GoLandLatestImage), }, pycharm: { @@ -112,7 +112,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Title: "PyCharm", Type: typeDesktop, Logo: getIdeLogoPath("pycharmLogo"), - Image: common.ImageName(ctx.Config.Repository, ide.PyCharmDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PyCharmImage.Version), + Image: ctx.ImageName(ctx.Config.Repository, ide.PyCharmDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PyCharmImage.Version), LatestImage: resolveLatestImage(ide.PyCharmDesktopIdeImage, "latest", ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PyCharmLatestImage), }, phpstorm: { @@ -120,7 +120,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { Title: "PhpStorm", Type: typeDesktop, Logo: getIdeLogoPath("phpstormLogo"), - Image: common.ImageName(ctx.Config.Repository, ide.PhpStormDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PhpStormImage.Version), + Image: ctx.ImageName(ctx.Config.Repository, ide.PhpStormDesktopIdeImage, ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PhpStormImage.Version), LatestImage: resolveLatestImage(ide.PhpStormDesktopIdeImage, "latest", ctx.VersionManifest.Components.Workspace.DesktopIdeImages.PhpStormLatestImage), }, }, diff --git a/install/installer/pkg/components/ws-daemon/daemonset.go b/install/installer/pkg/components/ws-daemon/daemonset.go index a6c814fb248d92..ae79f08852b8f3 100644 --- a/install/installer/pkg/components/ws-daemon/daemonset.go +++ b/install/installer/pkg/components/ws-daemon/daemonset.go @@ -32,7 +32,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { initContainers := []corev1.Container{ { Name: "disable-kube-health-monitor", - Image: common.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), "library/ubuntu", "20.04"), + Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), "library/ubuntu", "20.04"), Command: []string{ "/usr/bin/nsenter", "-t", @@ -61,7 +61,7 @@ fi }, { Name: "seccomp-profile-installer", - Image: common.ImageName(cfg.Repository, "seccomp-profile-installer", ctx.VersionManifest.Components.WSDaemon.UserNamespaces.SeccompProfileInstaller.Version), + Image: ctx.ImageName(cfg.Repository, "seccomp-profile-installer", ctx.VersionManifest.Components.WSDaemon.UserNamespaces.SeccompProfileInstaller.Version), Command: []string{ "/bin/sh", "-c", @@ -75,7 +75,7 @@ fi }, { Name: "sysctl", - Image: common.ImageName(cfg.Repository, "ws-daemon", ctx.VersionManifest.Components.WSDaemon.Version), + Image: ctx.ImageName(cfg.Repository, "ws-daemon", ctx.VersionManifest.Components.WSDaemon.Version), Command: []string{ "sh", "-c", @@ -97,7 +97,7 @@ fi if cfg.Workspace.Runtime.FSShiftMethod == config.FSShiftShiftFS { initContainers = append(initContainers, corev1.Container{ Name: "shiftfs-module-loader", - Image: common.ImageName(cfg.Repository, "shiftfs-module-loader", ctx.VersionManifest.Components.WSDaemon.UserNamespaces.ShiftFSModuleLoader.Version), + Image: ctx.ImageName(cfg.Repository, "shiftfs-module-loader", ctx.VersionManifest.Components.WSDaemon.UserNamespaces.ShiftFSModuleLoader.Version), VolumeMounts: []corev1.VolumeMount{{ Name: "node-linux-src", ReadOnly: true, @@ -190,7 +190,7 @@ fi Containers: []corev1.Container{ { Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSDaemon.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSDaemon.Version), Args: []string{ "run", "--config", diff --git a/install/installer/pkg/components/ws-manager-bridge/deployment.go b/install/installer/pkg/components/ws-manager-bridge/deployment.go index eee21ab66e6d1e..9892ceaf9ec4f8 100644 --- a/install/installer/pkg/components/ws-manager-bridge/deployment.go +++ b/install/installer/pkg/components/ws-manager-bridge/deployment.go @@ -109,7 +109,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { InitContainers: []corev1.Container{*common.DatabaseWaiterContainer(ctx), *common.MessageBusWaiterContainer(ctx)}, Containers: []corev1.Container{{ Name: Component, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManagerBridge.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManagerBridge.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/ws-manager/deployment.go b/install/installer/pkg/components/ws-manager/deployment.go index 48fce468c53967..f94c20f07372cb 100644 --- a/install/installer/pkg/components/ws-manager/deployment.go +++ b/install/installer/pkg/components/ws-manager/deployment.go @@ -35,7 +35,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Containers: []corev1.Container{{ Name: Component, Args: []string{"run", "--config", "/config/config.json"}, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManager.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSManager.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/components/ws-proxy/configmap.go b/install/installer/pkg/components/ws-proxy/configmap.go index 0ba07f50faf551..0501990fe454a9 100644 --- a/install/installer/pkg/components/ws-proxy/configmap.go +++ b/install/installer/pkg/components/ws-proxy/configmap.go @@ -56,7 +56,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { WorkspacePodConfig: &proxy.WorkspacePodConfig{ TheiaPort: workspace.ContainerPort, SupervisorPort: workspace.SupervisorPort, - SupervisorImage: common.ImageName(ctx.Config.Repository, workspace.SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), + SupervisorImage: ctx.ImageName(ctx.Config.Repository, workspace.SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version), }, BuiltinPages: proxy.BuiltinPagesConfig{ Location: "/app/public", diff --git a/install/installer/pkg/components/ws-proxy/deployment.go b/install/installer/pkg/components/ws-proxy/deployment.go index 216f2a2bbaf9ed..333aba5bda76f1 100644 --- a/install/installer/pkg/components/ws-proxy/deployment.go +++ b/install/installer/pkg/components/ws-proxy/deployment.go @@ -116,7 +116,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Containers: []corev1.Container{{ Name: Component, Args: []string{"run", "/config/config.json"}, - Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSProxy.Version), + Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.WSProxy.Version), ImagePullPolicy: corev1.PullIfNotPresent, Resources: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ diff --git a/install/installer/pkg/config/v1/config.go b/install/installer/pkg/config/v1/config.go index 13cf07b1185795..2cec06b9f13c59 100644 --- a/install/installer/pkg/config/v1/config.go +++ b/install/installer/pkg/config/v1/config.go @@ -97,6 +97,8 @@ type Config struct { CustomCACert *ObjectRef `json:"customCACert,omitempty"` + DropImageRepo *bool `json:"dropImageRepo,omitempty"` + Experimental *experimental.Config `json:"experimental,omitempty"` } diff --git a/install/kots/Makefile b/install/kots/Makefile index f9e885446fd80f..2dded77720ba66 100644 --- a/install/kots/Makefile +++ b/install/kots/Makefile @@ -16,7 +16,7 @@ create_dev_release: exit 1; \ fi - replicated release create --lint --ensure-channel --yaml-dir ${YAML_DIR} --promote ${REPLICATED_DEV_CHANNEL} + replicated release create --lint --ensure-channel --yaml-dir ${YAML_DIR} --promote ${REPLICATED_DEV_CHANNEL} --version="$(shell date +%s)" .PHONY: create_dev_release create_unstable_release: diff --git a/install/kots/manifests/gitpod-installer-job.yaml b/install/kots/manifests/gitpod-installer-job.yaml index bb5cfe3177a44e..53d6693a454df9 100644 --- a/install/kots/manifests/gitpod-installer-job.yaml +++ b/install/kots/manifests/gitpod-installer-job.yaml @@ -24,7 +24,7 @@ spec: containers: - name: installer # This will normally be the release tag - using this tag as need the license evaluator - image: 'eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-mini-config.0' + image: 'eu.gcr.io/gitpod-core-dev/build/installer:sje-airgapped.0' volumeMounts: - mountPath: /config-patch name: config-patch @@ -70,6 +70,7 @@ spec: yq e -i '.domain = "{{repl ConfigOption "domain" }}"' "${CONFIG_FILE}" yq e -i '.license.kind = "secret"' "${CONFIG_FILE}" yq e -i '.license.name = "gitpod-license"' "${CONFIG_FILE}" + yq e -i '.dropImageRepo = true' "${CONFIG_FILE}" if [ '{{repl and (ConfigOptionEquals "db_incluster" "0") (ConfigOptionEquals "db_cloudsql_enabled" "1") }}' = "true" ]; then @@ -90,7 +91,18 @@ spec: yq e -i ".database.external.certificate.name = \"database\"" "${CONFIG_FILE}" fi - if [ '{{repl ConfigOptionEquals "reg_incluster" "0" }}' = "true" ]; + if [ '{{repl HasLocalRegistry }}' = "true" ]; + then + echo "Gitpod: configuring mirrored container registry" + + yq e -i ".containerRegistry.inCluster = false" "${CONFIG_FILE}" + yq e -i ".containerRegistry.external.url = \"{{repl LocalRegistryAddress }}\"" "${CONFIG_FILE}" + yq e -i ".containerRegistry.external.certificate.kind = \"secret\"" "${CONFIG_FILE}" + yq e -i ".containerRegistry.external.certificate.name = \"{{repl ImagePullSecretName }}\"" "${CONFIG_FILE}" + yq e -i ".repository = \"{{repl LocalRegistryAddress }}\"" "${CONFIG_FILE}" + yq e -i ".imagePullSecrets[0].kind = \"secret\"" "${CONFIG_FILE}" + yq e -i ".imagePullSecrets[0].name = \"{{repl ImagePullSecretName }}\"" "${CONFIG_FILE}" + elif [ '{{repl ConfigOptionEquals "reg_incluster" "0" }}' = "true" ]; then echo "Gitpod: configuring external container registry" @@ -99,7 +111,7 @@ spec: yq e -i ".containerRegistry.external.certificate.kind = \"secret\"" "${CONFIG_FILE}" yq e -i ".containerRegistry.external.certificate.name = \"container-registry\"" "${CONFIG_FILE}" - if [ '{{repl ConfigOptionEquals "reg_s3storage" "1" }}' = "true" ]; + if [ '{{repl ConfigOptionEquals "reg_s3storage" "1" }}' = "true" ]; then echo "Gitpod: configuring container registry S3 backend" diff --git a/install/kots/manifests/gitpod-registry-secret.yaml b/install/kots/manifests/gitpod-registry-secret.yaml index 5d863f0582527f..121f940ce6be5a 100644 --- a/install/kots/manifests/gitpod-registry-secret.yaml +++ b/install/kots/manifests/gitpod-registry-secret.yaml @@ -6,7 +6,7 @@ kind: Secret metadata: name: container-registry annotations: - kots.io/when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + kots.io/when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' type: kubernetes.io/dockerconfigjson data: .dockerconfigjson: '{{repl printf "{\"auths\": {\"%s\": {\"username\": \"%s\", \"password\": %s, \"auth\": \"%s\"}}}" (ConfigOption "reg_server" | default (ConfigOption "reg_url")) (ConfigOption "reg_username") (ConfigOption "reg_password" | toJson) (printf "%s:%s" (ConfigOption "reg_username") (ConfigOption "reg_password") | Base64Encode) | Base64Encode }}' diff --git a/install/kots/manifests/kots-config.yaml b/install/kots/manifests/kots-config.yaml index 9d02807693d8d3..b14366f1683a4f 100644 --- a/install/kots/manifests/kots-config.yaml +++ b/install/kots/manifests/kots-config.yaml @@ -24,6 +24,7 @@ spec: - name: reg_incluster title: Use in-cluster container registry type: bool + when: '{{repl eq HasLocalRegistry false }}' default: "1" help_text: You may either use an in-cluster container registry or configure your own external container registry for better performance. This container registry must be accessible from your Kubernetes cluster. recommended: false @@ -31,27 +32,27 @@ spec: - name: reg_url title: Container registry URL type: text - when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' required: true help_text: The container registry URL. This will usually be the fully qualified domain of your registry. - name: reg_server title: Container registry server type: text - when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' help_text: The container registry server. This is used when [generating your credentials](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line). Depending upon your provider, this may or may not be the same as the registry URL. If not specified, the URL will be used. - name: reg_username title: Container registry username type: text - when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' required: true help_text: The username for your container registry. - name: reg_password title: Container registry password type: password - when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' required: true help_text: The password for your container registry. @@ -59,27 +60,27 @@ spec: title: Use S3 storage for your container registry type: bool default: "0" - when: '{{repl ConfigOptionEquals "reg_incluster" "0" }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") }}' help_text: If using AWS as your container registry, you must configure an S3 storage backend. - name: reg_bucketname title: S3 bucket name type: text - when: '{{repl and (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' required: true help_text: The name of the bucket to act as your S3 storage backend. - name: reg_accesskey title: S3 access key type: text - when: '{{repl and (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' required: true help_text: The access key to use for authentication of your S3 storage backend. - name: reg_secretkey title: S3 secret key type: password - when: '{{repl and (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' + when: '{{repl and (eq HasLocalRegistry false) (ConfigOptionEquals "reg_incluster" "0") (ConfigOptionEquals "reg_s3storage" "1") }}' required: true help_text: The secret key to use for authentication of your S3 storage backend.