diff --git a/install/installer/pkg/components/agent-smith/configmap.go b/install/installer/pkg/components/agent-smith/configmap.go index 32ce582bd8f2bc..dd80cb95bcbff4 100644 --- a/install/installer/pkg/components/agent-smith/configmap.go +++ b/install/installer/pkg/components/agent-smith/configmap.go @@ -49,9 +49,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/agent-smith/daemonset.go b/install/installer/pkg/components/agent-smith/daemonset.go index b11589b6040aff..43a607c516d91f 100644 --- a/install/installer/pkg/components/agent-smith/daemonset.go +++ b/install/installer/pkg/components/agent-smith/daemonset.go @@ -17,7 +17,7 @@ import ( ) func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDaemonset) configHash, err := common.ObjectHash(configmap(ctx)) if err != nil { @@ -30,16 +30,19 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: appsv1.DaemonSetSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Labels: labels, + Name: Component, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelWorkspacesRegular, cluster.AffinityLabelWorkspacesHeadless), @@ -64,7 +67,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { Name: "config", MountPath: "/config", }}, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), []corev1.EnvVar{{ @@ -73,7 +76,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { FieldRef: &corev1.ObjectFieldSelector{FieldPath: "spec.nodeName"}, }, }}, - ), + )), SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(true), ProcMount: func() *corev1.ProcMountType { r := corev1.DefaultProcMount; return &r }(), diff --git a/install/installer/pkg/components/blobserve/configmap.go b/install/installer/pkg/components/blobserve/configmap.go index 83f25aad8188e7..0d5a7071384e07 100644 --- a/install/installer/pkg/components/blobserve/configmap.go +++ b/install/installer/pkg/components/blobserve/configmap.go @@ -113,9 +113,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/blobserve/deployment.go b/install/installer/pkg/components/blobserve/deployment.go index 1ab7ab6cb78698..afbdef3aa427d6 100644 --- a/install/installer/pkg/components/blobserve/deployment.go +++ b/install/installer/pkg/components/blobserve/deployment.go @@ -20,7 +20,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) volumeName := "pull-secret" var secretName string @@ -54,9 +54,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -67,9 +68,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelWorkspaceServices), @@ -110,10 +113,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Privileged: pointer.Bool(false), RunAsUser: pointer.Int64(1000), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), - ), + )), VolumeMounts: []corev1.VolumeMount{{ Name: "config", MountPath: "/mnt/config", diff --git a/install/installer/pkg/components/content-service/configmap.go b/install/installer/pkg/components/content-service/configmap.go index 871c0a26469843..bda4dde5add6a7 100644 --- a/install/installer/pkg/components/content-service/configmap.go +++ b/install/installer/pkg/components/content-service/configmap.go @@ -6,6 +6,7 @@ package content_service import ( "fmt" + "github.com/gitpod-io/gitpod/common-go/baseserver" "github.com/gitpod-io/gitpod/content-service/api/config" @@ -32,9 +33,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{&corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/content-service/deployment.go b/install/installer/pkg/components/content-service/deployment.go index 1b4516da8e0653..f13d8e40302996 100644 --- a/install/installer/pkg/components/content-service/deployment.go +++ b/install/installer/pkg/components/content-service/deployment.go @@ -17,7 +17,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) configHash, err := common.ObjectHash(configmap(ctx)) if err != nil { @@ -65,14 +65,14 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Privileged: pointer.Bool(false), RunAsUser: pointer.Int64(1000), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), []corev1.EnvVar{{ Name: "GRPC_GO_RETRY", Value: "on", }}, - ), + )), VolumeMounts: []corev1.VolumeMount{{ Name: "config", MountPath: "/config", @@ -90,9 +90,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &v1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: v1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -103,9 +104,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: podSpec, }, diff --git a/install/installer/pkg/components/dashboard/deployment.go b/install/installer/pkg/components/dashboard/deployment.go index 3b19d18e4b2628..4b3db9d4608ff4 100644 --- a/install/installer/pkg/components/dashboard/deployment.go +++ b/install/installer/pkg/components/dashboard/deployment.go @@ -18,15 +18,16 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) return []runtime.Object{ &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -34,9 +35,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Strategy: common.DeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -62,9 +64,9 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), - ), + )), ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ diff --git a/install/installer/pkg/components/database/cloudsql/deployment.go b/install/installer/pkg/components/database/cloudsql/deployment.go index 05796e1d7a2558..84bf95a2367502 100644 --- a/install/installer/pkg/components/database/cloudsql/deployment.go +++ b/install/installer/pkg/components/database/cloudsql/deployment.go @@ -6,6 +6,7 @@ package cloudsql import ( "fmt" + "github.com/gitpod-io/gitpod/installer/pkg/cluster" "github.com/gitpod-io/gitpod/installer/pkg/common" appsv1 "k8s.io/api/apps/v1" @@ -17,15 +18,16 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) return []runtime.Object{ &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-cloud-sql-proxy", Component), - Namespace: ctx.Namespace, - Labels: labels, + Name: fmt.Sprintf("%s-cloud-sql-proxy", Component), + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Strategy: appsv1.DeploymentStrategy{ @@ -39,9 +41,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Replicas: common.Replicas(ctx, Component), Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ @@ -84,6 +87,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { MountPath: "/credentials", Name: "gcloud-sql-token", }}, + Env: common.CustomOverrideEnvvar(ctx, Component, []corev1.EnvVar{}), }}, }, }, diff --git a/install/installer/pkg/components/database/incluster/configmap.go b/install/installer/pkg/components/database/incluster/configmap.go index a5a34e874953c4..e39d0c3a7bb3ad 100644 --- a/install/installer/pkg/components/database/incluster/configmap.go +++ b/install/installer/pkg/components/database/incluster/configmap.go @@ -51,9 +51,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: SQLInitScripts, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: SQLInitScripts, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "init.sql": initScriptData, diff --git a/install/installer/pkg/components/database/incluster/service.go b/install/installer/pkg/components/database/incluster/service.go index 834532601e10b1..7cceab34250230 100644 --- a/install/installer/pkg/components/database/incluster/service.go +++ b/install/installer/pkg/components/database/incluster/service.go @@ -15,14 +15,15 @@ import ( // service this doesn't use the common.GenerateService function // because it's more complex than this caters for func service(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaService) return []runtime.Object{&corev1.Service{ TypeMeta: common.TypeMetaService, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaService), }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{{ diff --git a/install/installer/pkg/components/database/init/configmap.go b/install/installer/pkg/components/database/init/configmap.go index cbb5cf3f0b045a..2996ae2ad30a77 100644 --- a/install/installer/pkg/components/database/init/configmap.go +++ b/install/installer/pkg/components/database/init/configmap.go @@ -47,9 +47,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: sqlInitScripts, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: sqlInitScripts, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "init.sql": initScriptData, diff --git a/install/installer/pkg/components/database/init/job.go b/install/installer/pkg/components/database/init/job.go index 0cfa0231e9f6cf..76179969349adc 100644 --- a/install/installer/pkg/components/database/init/job.go +++ b/install/installer/pkg/components/database/init/job.go @@ -25,9 +25,10 @@ func job(ctx *common.RenderContext) ([]runtime.Object, error) { } objectMeta := metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-session", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-session", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaBatchJob), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaBatchJob), } return []runtime.Object{&batchv1.Job{ diff --git a/install/installer/pkg/components/ide-proxy/deployment.go b/install/installer/pkg/components/ide-proxy/deployment.go index 375e40ff99e526..ba66bdde78d50a 100644 --- a/install/installer/pkg/components/ide-proxy/deployment.go +++ b/install/installer/pkg/components/ide-proxy/deployment.go @@ -18,15 +18,16 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) return []runtime.Object{ &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -34,9 +35,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Strategy: common.DeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -62,9 +64,9 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), - ), + )), ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ diff --git a/install/installer/pkg/components/image-builder-mk3/configmap.go b/install/installer/pkg/components/image-builder-mk3/configmap.go index 74f647b6c161a0..92d696e4e2e6a9 100644 --- a/install/installer/pkg/components/image-builder-mk3/configmap.go +++ b/install/installer/pkg/components/image-builder-mk3/configmap.go @@ -81,9 +81,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "image-builder.json": string(fc), diff --git a/install/installer/pkg/components/image-builder-mk3/deployment.go b/install/installer/pkg/components/image-builder-mk3/deployment.go index ea12aaf97827dc..ab892147e623c1 100644 --- a/install/installer/pkg/components/image-builder-mk3/deployment.go +++ b/install/installer/pkg/components/image-builder-mk3/deployment.go @@ -34,7 +34,7 @@ func pullSecretName(ctx *common.RenderContext) (string, error) { } func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) var hashObj []runtime.Object if objs, err := configmap(ctx); err != nil { @@ -112,9 +112,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{&appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -125,9 +126,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -149,10 +152,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { "--config", "/config/image-builder.json", }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), - ), + )), Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{ Requests: corev1.ResourceList{ "cpu": resource.MustParse("100m"), diff --git a/install/installer/pkg/components/migrations/job.go b/install/installer/pkg/components/migrations/job.go index 83ba044b65c729..221793fe596d32 100644 --- a/install/installer/pkg/components/migrations/job.go +++ b/install/installer/pkg/components/migrations/job.go @@ -20,9 +20,10 @@ func job(ctx *common.RenderContext) ([]runtime.Object, error) { } objectMeta := metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaBatchJob), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaBatchJob), } return []runtime.Object{&batchv1.Job{ @@ -43,9 +44,9 @@ func job(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Image: ctx.ImageName(ctx.Config.Repository, "db-migrations", ctx.VersionManifest.Components.DBMigrations.Version), ImagePullPolicy: corev1.PullIfNotPresent, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DatabaseEnv(&ctx.Config), - ), + )), Command: []string{ "sh", "-c", diff --git a/install/installer/pkg/components/openvsx-proxy/configmap.go b/install/installer/pkg/components/openvsx-proxy/configmap.go index aee063a49ed418..080e661ae6935d 100644 --- a/install/installer/pkg/components/openvsx-proxy/configmap.go +++ b/install/installer/pkg/components/openvsx-proxy/configmap.go @@ -48,9 +48,10 @@ maxmemory-policy allkeys-lfu &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: data, }, diff --git a/install/installer/pkg/components/openvsx-proxy/statefulset.go b/install/installer/pkg/components/openvsx-proxy/statefulset.go index 766ef954dee940..fd8996d0a75983 100644 --- a/install/installer/pkg/components/openvsx-proxy/statefulset.go +++ b/install/installer/pkg/components/openvsx-proxy/statefulset.go @@ -20,7 +20,7 @@ import ( ) func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaStatefulSet) // todo(sje): add redis configHash, err := common.ObjectHash(configmap(ctx)) @@ -32,9 +32,10 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{&appsv1.StatefulSet{ TypeMeta: common.TypeMetaStatefulSet, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Spec: appsv1.StatefulSetSpec{ Selector: &metav1.LabelSelector{ @@ -48,9 +49,11 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: v1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelIDE), @@ -97,9 +100,9 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) { Name: "config", MountPath: "/config", }}, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), - ), + )), }, { Name: redisContainerName, Image: ctx.ImageName(common.ThirdPartyContainerRepo(ctx.Config.Repository, common.DockerRegistryURL), "library/redis", "6.2"), diff --git a/install/installer/pkg/components/proxy/configmap.go b/install/installer/pkg/components/proxy/configmap.go index 3455c9af774c21..c9ce0aff557555 100644 --- a/install/installer/pkg/components/proxy/configmap.go +++ b/install/installer/pkg/components/proxy/configmap.go @@ -159,9 +159,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: data, }, diff --git a/install/installer/pkg/components/proxy/deployment.go b/install/installer/pkg/components/proxy/deployment.go index 28b9e62d74c4ee..c12feef136fb0a 100644 --- a/install/installer/pkg/components/proxy/deployment.go +++ b/install/installer/pkg/components/proxy/deployment.go @@ -22,7 +22,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) var hashObj []runtime.Object if objs, err := configmap(ctx); err != nil { @@ -123,9 +123,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -136,9 +137,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ @@ -241,13 +244,13 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { FailureThreshold: 3, }, VolumeMounts: volumeMounts, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), []corev1.EnvVar{{ Name: "PROXY_DOMAIN", Value: ctx.Config.Domain, }}, - ), + )), }}, }, }, diff --git a/install/installer/pkg/components/public-api-server/configmap.go b/install/installer/pkg/components/public-api-server/configmap.go index 541d676a9d6edb..a47d3e01a6816b 100644 --- a/install/installer/pkg/components/public-api-server/configmap.go +++ b/install/installer/pkg/components/public-api-server/configmap.go @@ -6,6 +6,7 @@ package public_api_server import ( "fmt" + "github.com/gitpod-io/gitpod/common-go/baseserver" "github.com/gitpod-io/gitpod/public-api/config" @@ -40,9 +41,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ configJSONFilename: string(fc), diff --git a/install/installer/pkg/components/public-api-server/configmap_test.go b/install/installer/pkg/components/public-api-server/configmap_test.go index 900bf1d8593f12..e91ab1b2f4e2a4 100644 --- a/install/installer/pkg/components/public-api-server/configmap_test.go +++ b/install/installer/pkg/components/public-api-server/configmap_test.go @@ -5,13 +5,14 @@ package public_api_server import ( "fmt" + "testing" + "github.com/gitpod-io/gitpod/common-go/baseserver" "github.com/gitpod-io/gitpod/installer/pkg/common" "github.com/gitpod-io/gitpod/public-api/config" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) func TestConfigMap(t *testing.T) { @@ -39,9 +40,10 @@ func TestConfigMap(t *testing.T) { require.Equal(t, &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(expectedJSON), diff --git a/install/installer/pkg/components/public-api-server/deployment.go b/install/installer/pkg/components/public-api-server/deployment.go index c366efca259236..5c3c11ee586a60 100644 --- a/install/installer/pkg/components/public-api-server/deployment.go +++ b/install/installer/pkg/components/public-api-server/deployment.go @@ -31,7 +31,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { return nil, err } - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) return []runtime.Object{ &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, @@ -39,9 +39,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -49,9 +51,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Strategy: common.DeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -85,9 +88,9 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), - ), + )), LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ diff --git a/install/installer/pkg/components/registry-facade/configmap.go b/install/installer/pkg/components/registry-facade/configmap.go index 05bc046dd04083..42d85037676d47 100644 --- a/install/installer/pkg/components/registry-facade/configmap.go +++ b/install/installer/pkg/components/registry-facade/configmap.go @@ -101,9 +101,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/registry-facade/daemonset.go b/install/installer/pkg/components/registry-facade/daemonset.go index 3cd1f8cf0abb4f..67ac1b21bc882a 100644 --- a/install/installer/pkg/components/registry-facade/daemonset.go +++ b/install/installer/pkg/components/registry-facade/daemonset.go @@ -23,7 +23,7 @@ import ( ) func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDaemonset) var hashObj []runtime.Object if objs, err := configmap(ctx); err != nil { @@ -187,9 +187,10 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{&appsv1.DaemonSet{ TypeMeta: common.TypeMetaDaemonset, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset), }, Spec: appsv1.DaemonSetSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -197,9 +198,11 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { ObjectMeta: metav1.ObjectMeta{ Name: Component, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ PriorityClassName: common.SystemNodeCritical, @@ -230,7 +233,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { Privileged: pointer.Bool(false), RunAsUser: pointer.Int64(1000), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), []corev1.EnvVar{ @@ -248,7 +251,7 @@ func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { }, }, envvars, - ), + )), VolumeMounts: append( []corev1.VolumeMount{ { diff --git a/install/installer/pkg/components/server/configmap.go b/install/installer/pkg/components/server/configmap.go index f5dce6c905f555..78e3082bcbdc25 100644 --- a/install/installer/pkg/components/server/configmap.go +++ b/install/installer/pkg/components/server/configmap.go @@ -244,9 +244,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/server/deployment.go b/install/installer/pkg/components/server/deployment.go index d468ce842fd699..196d37b3928375 100644 --- a/install/installer/pkg/components/server/deployment.go +++ b/install/installer/pkg/components/server/deployment.go @@ -26,7 +26,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) var hashObj []runtime.Object if objs, err := configmap(ctx); err != nil { @@ -281,9 +281,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -294,9 +295,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ @@ -369,7 +372,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }, }, // todo(sje): do we need to cater for serverContainer.env from values.yaml? - Env: env, + Env: common.CustomOverrideEnvvar(ctx, Component, env), // todo(sje): do we need to cater for serverContainer.volumeMounts from values.yaml? VolumeMounts: append( []corev1.VolumeMount{ diff --git a/install/installer/pkg/components/server/ide/configmap.go b/install/installer/pkg/components/server/ide/configmap.go index 91ade226fb6830..2844762b603477 100644 --- a/install/installer/pkg/components/server/ide/configmap.go +++ b/install/installer/pkg/components/server/ide/configmap.go @@ -146,9 +146,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-ide-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-ide-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/usage/configmap.go b/install/installer/pkg/components/usage/configmap.go index ec01a37788f9a0..0f6bef5efa515a 100644 --- a/install/installer/pkg/components/usage/configmap.go +++ b/install/installer/pkg/components/usage/configmap.go @@ -26,9 +26,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "schedule": schedule, diff --git a/install/installer/pkg/components/usage/deployment.go b/install/installer/pkg/components/usage/deployment.go index 87114bbedc2e27..ea9f7390e2601a 100644 --- a/install/installer/pkg/components/usage/deployment.go +++ b/install/installer/pkg/components/usage/deployment.go @@ -20,7 +20,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) var volumes []corev1.Volume var volumeMounts []corev1.VolumeMount @@ -51,9 +51,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -61,9 +62,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Strategy: common.DeploymentStrategy, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -93,7 +95,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.DatabaseEnv(&ctx.Config), []corev1.EnvVar{{ @@ -105,7 +107,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { }, }, }}, - ), + )), VolumeMounts: volumeMounts, LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ diff --git a/install/installer/pkg/components/ws-daemon/configmap.go b/install/installer/pkg/components/ws-daemon/configmap.go index cfcbe5106fe636..10957ab6fa522c 100644 --- a/install/installer/pkg/components/ws-daemon/configmap.go +++ b/install/installer/pkg/components/ws-daemon/configmap.go @@ -145,9 +145,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{&corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/ws-daemon/daemonset.go b/install/installer/pkg/components/ws-daemon/daemonset.go index 260d9d6bdf0be0..a0b5e07a6ec12a 100644 --- a/install/installer/pkg/components/ws-daemon/daemonset.go +++ b/install/installer/pkg/components/ws-daemon/daemonset.go @@ -22,7 +22,7 @@ import ( func daemonset(ctx *common.RenderContext) ([]runtime.Object, error) { cfg := ctx.Config - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDaemonset) configHash, err := common.ObjectHash(configmap(ctx)) if err != nil { @@ -201,7 +201,7 @@ fi HostPort: ServicePort, ContainerPort: ServicePort, }}, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&cfg), common.WorkspaceTracingEnv(ctx), []corev1.EnvVar{{ @@ -212,7 +212,7 @@ fi }, }, }}, - ), + )), Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{Requests: corev1.ResourceList{ "cpu": resource.MustParse("1m"), "memory": resource.MustParse("1Mi"), @@ -351,19 +351,22 @@ fi return []runtime.Object{&appsv1.DaemonSet{ TypeMeta: common.TypeMetaDaemonset, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset), }, Spec: appsv1.DaemonSetSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: labels, - Annotations: map[string]string{ - "seccomp.security.alpha.kubernetes.io/shiftfs-module-loader": "unconfined", - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDaemonset, func() map[string]string { + return map[string]string{ + "seccomp.security.alpha.kubernetes.io/shiftfs-module-loader": "unconfined", + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: podSpec, }, diff --git a/install/installer/pkg/components/ws-manager-bridge/configmap.go b/install/installer/pkg/components/ws-manager-bridge/configmap.go index e276519d0f17e9..c4b353759b5f4d 100644 --- a/install/installer/pkg/components/ws-manager-bridge/configmap.go +++ b/install/installer/pkg/components/ws-manager-bridge/configmap.go @@ -44,9 +44,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-config", Component), - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: fmt.Sprintf("%s-config", Component), + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "ws-manager-bridge.json": string(fc), diff --git a/install/installer/pkg/components/ws-manager-bridge/deployment.go b/install/installer/pkg/components/ws-manager-bridge/deployment.go index f197d6adcaec87..d00351b79465fc 100644 --- a/install/installer/pkg/components/ws-manager-bridge/deployment.go +++ b/install/installer/pkg/components/ws-manager-bridge/deployment.go @@ -20,7 +20,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) var hashObj []runtime.Object if objs, err := configmap(ctx); err != nil { @@ -66,9 +66,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -79,9 +80,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ Affinity: common.NodeAffinity(cluster.AffinityLabelMeta), @@ -121,7 +124,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Privileged: pointer.Bool(false), RunAsUser: pointer.Int64(31001), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), common.AnalyticsEnv(&ctx.Config), @@ -131,7 +134,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: "WSMAN_BRIDGE_CONFIGPATH", Value: "/config/ws-manager-bridge.json", }}, - ), + )), Ports: []corev1.ContainerPort{ { ContainerPort: 9500, diff --git a/install/installer/pkg/components/ws-manager/configmap.go b/install/installer/pkg/components/ws-manager/configmap.go index cda799e995151b..35731eae1f6bbe 100644 --- a/install/installer/pkg/components/ws-manager/configmap.go +++ b/install/installer/pkg/components/ws-manager/configmap.go @@ -207,9 +207,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/ws-manager/deployment.go b/install/installer/pkg/components/ws-manager/deployment.go index 751b6524b8905f..56bc4ad164c33f 100644 --- a/install/installer/pkg/components/ws-manager/deployment.go +++ b/install/installer/pkg/components/ws-manager/deployment.go @@ -52,11 +52,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), []corev1.EnvVar{{Name: "GRPC_GO_RETRY", Value: "on"}}, - ), + )), VolumeMounts: []corev1.VolumeMount{ { Name: VolumeConfig, diff --git a/install/installer/pkg/components/ws-proxy/configmap.go b/install/installer/pkg/components/ws-proxy/configmap.go index b22421a2491ffe..a7d2882322c366 100644 --- a/install/installer/pkg/components/ws-proxy/configmap.go +++ b/install/installer/pkg/components/ws-proxy/configmap.go @@ -89,9 +89,10 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { &corev1.ConfigMap{ TypeMeta: common.TypeMetaConfigmap, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: common.DefaultLabels(Component), + Name: Component, + Namespace: ctx.Namespace, + Labels: common.CustomOverrideLabel(ctx, Component, common.TypeMetaConfigmap), + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaConfigmap), }, Data: map[string]string{ "config.json": string(fc), diff --git a/install/installer/pkg/components/ws-proxy/deployment.go b/install/installer/pkg/components/ws-proxy/deployment.go index 400e540712d9e0..8d4f9d551e657c 100644 --- a/install/installer/pkg/components/ws-proxy/deployment.go +++ b/install/installer/pkg/components/ws-proxy/deployment.go @@ -20,7 +20,7 @@ import ( ) func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { - labels := common.DefaultLabels(Component) + labels := common.CustomOverrideLabel(ctx, Component, common.TypeMetaDeployment) configHash, err := common.ObjectHash(configmap(ctx)) if err != nil { @@ -64,9 +64,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { &appsv1.Deployment{ TypeMeta: common.TypeMetaDeployment, ObjectMeta: metav1.ObjectMeta{ - Name: Component, - Namespace: ctx.Namespace, - Labels: labels, + Name: Component, + Namespace: ctx.Namespace, + Labels: labels, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment), }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, @@ -77,9 +78,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { Name: Component, Namespace: ctx.Namespace, Labels: labels, - Annotations: map[string]string{ - common.AnnotationConfigChecksum: configHash, - }, + Annotations: common.CustomOverrideAnnotation(ctx, Component, common.TypeMetaDeployment, func() map[string]string { + return map[string]string{ + common.AnnotationConfigChecksum: configHash, + } + }), }, Spec: corev1.PodSpec{ PriorityClassName: common.SystemNodeCritical, @@ -136,11 +139,11 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), }, - Env: common.MergeEnv( + Env: common.CustomOverrideEnvvar(ctx, Component, common.MergeEnv( common.DefaultEnv(&ctx.Config), common.WorkspaceTracingEnv(ctx), common.AnalyticsEnv(&ctx.Config), - ), + )), ReadinessProbe: &corev1.Probe{ InitialDelaySeconds: int32(2), PeriodSeconds: int32(5),