From ba0fc861f303cebc04b41569b5caee1c613b1af3 Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Mon, 1 Aug 2022 14:09:15 +0000 Subject: [PATCH] [installer]: set proxy server configuration in installer --- install/installer/pkg/common/common.go | 55 ++++++++++++++----- install/installer/pkg/common/constants.go | 1 + .../manifests/gitpod-installation-status.yaml | 2 +- .../kots/manifests/gitpod-installation.yaml | 1 + .../kots/manifests/gitpod-installer-job.yaml | 2 +- .../kots/manifests/gitpod-proxy-server.yaml | 15 +++++ 6 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 install/kots/manifests/gitpod-proxy-server.yaml diff --git a/install/installer/pkg/common/common.go b/install/installer/pkg/common/common.go index 5ed0c8c8b85160..3feb5b789dba9b 100644 --- a/install/installer/pkg/common/common.go +++ b/install/installer/pkg/common/common.go @@ -28,6 +28,30 @@ import ( "sigs.k8s.io/yaml" ) +func getProxyServerEnvvar(cfg *config.Config, envvarName string, key string) []corev1.EnvVar { + env := corev1.EnvVar{ + Name: strings.ToUpper(envvarName), + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: ProxyServerConfigMap, + }, + Key: key, + Optional: pointer.Bool(true), + }, + }, + } + + return []corev1.EnvVar{ + env, + func() corev1.EnvVar { + // Set envvar with both upper and lowercase as there's no agreed standard + env.Name = strings.ToLower(env.Name) + return env + }(), + } +} + func DefaultLabels(component string) map[string]string { return map[string]string{ "app": AppName, @@ -48,19 +72,24 @@ func DefaultEnv(cfg *config.Config) []corev1.EnvVar { logLevel = string(cfg.Observability.LogLevel) } - return []corev1.EnvVar{ - {Name: "GITPOD_DOMAIN", Value: cfg.Domain}, - {Name: "GITPOD_INSTALLATION_SHORTNAME", Value: cfg.Metadata.InstallationShortname}, - {Name: "GITPOD_REGION", Value: cfg.Metadata.Region}, - {Name: "HOST_URL", Value: "https://" + cfg.Domain}, - {Name: "KUBE_NAMESPACE", ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.namespace", - }, - }}, - {Name: "KUBE_DOMAIN", Value: "svc.cluster.local"}, - {Name: "LOG_LEVEL", Value: strings.ToLower(logLevel)}, - } + return MergeEnv( + []corev1.EnvVar{ + {Name: "GITPOD_DOMAIN", Value: cfg.Domain}, + {Name: "GITPOD_INSTALLATION_SHORTNAME", Value: cfg.Metadata.InstallationShortname}, + {Name: "GITPOD_REGION", Value: cfg.Metadata.Region}, + {Name: "HOST_URL", Value: "https://" + cfg.Domain}, + {Name: "KUBE_NAMESPACE", ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "metadata.namespace", + }, + }}, + {Name: "KUBE_DOMAIN", Value: "svc.cluster.local"}, + {Name: "LOG_LEVEL", Value: strings.ToLower(logLevel)}, + }, + getProxyServerEnvvar(cfg, "HTTP_PROXY", "httpProxy"), + getProxyServerEnvvar(cfg, "HTTPS_PROXY", "httpsProxy"), + getProxyServerEnvvar(cfg, "NO_PROXY", "noProxy"), + ) } func WorkspaceTracingEnv(context *RenderContext) (res []corev1.EnvVar) { diff --git a/install/installer/pkg/common/constants.go b/install/installer/pkg/common/constants.go index e70bae6d0d7d5f..f7ddbc709ea19c 100644 --- a/install/installer/pkg/common/constants.go +++ b/install/installer/pkg/common/constants.go @@ -27,6 +27,7 @@ const ( KubeRBACProxyTag = "v0.12.0" MinioServiceAPIPort = 9000 MonitoringChart = "monitoring" + ProxyServerConfigMap = "proxy-server" // Not related to proxy component, but where proxy server values stored ProxyComponent = "proxy" ProxyContainerHTTPPort = 80 ProxyContainerHTTPName = "http" diff --git a/install/kots/manifests/gitpod-installation-status.yaml b/install/kots/manifests/gitpod-installation-status.yaml index eb9d3763e5b400..64bf9eb6287466 100644 --- a/install/kots/manifests/gitpod-installation-status.yaml +++ b/install/kots/manifests/gitpod-installation-status.yaml @@ -30,7 +30,7 @@ spec: containers: - name: installation-status # This will normally be the release tag - image: "eu.gcr.io/gitpod-core-dev/build/installer:nvn-fix-11408.15" + image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-proxy-server.2" command: - /bin/sh - -c diff --git a/install/kots/manifests/gitpod-installation.yaml b/install/kots/manifests/gitpod-installation.yaml index aa50b5c3e5eaa2..b221cc7ca6eb51 100644 --- a/install/kots/manifests/gitpod-installation.yaml +++ b/install/kots/manifests/gitpod-installation.yaml @@ -13,6 +13,7 @@ data: channelName: repl{{ ChannelName | quote }} cursor: repl{{ Cursor | quote }} isAirgap: repl{{ IsAirgap | quote }} + kotsVersion: repl{{ KotsVersion | quote }} releaseNotes: repl{{ ReleaseNotes | quote }} sequence: repl{{ Sequence | quote }} version: repl{{ VersionLabel | quote }} diff --git a/install/kots/manifests/gitpod-installer-job.yaml b/install/kots/manifests/gitpod-installer-job.yaml index bad00875199c1a..6dafc7687df8cf 100644 --- a/install/kots/manifests/gitpod-installer-job.yaml +++ b/install/kots/manifests/gitpod-installer-job.yaml @@ -28,7 +28,7 @@ spec: containers: - name: installer # This will normally be the release tag - image: "eu.gcr.io/gitpod-core-dev/build/installer:nvn-fix-11408.15" + image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-proxy-server.2" volumeMounts: - mountPath: /config-patch name: config-patch diff --git a/install/kots/manifests/gitpod-proxy-server.yaml b/install/kots/manifests/gitpod-proxy-server.yaml new file mode 100644 index 00000000000000..3bc7087b8f30c8 --- /dev/null +++ b/install/kots/manifests/gitpod-proxy-server.yaml @@ -0,0 +1,15 @@ +# Copyright (c) 2022 Gitpod GmbH. All rights reserved. +# Licensed under the MIT License. See License-MIT.txt in the project root for license information. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: proxy-server # Name set in /install/installer/pkg/common/constants.go + labels: + app: gitpod + component: gitpod-installer + annotations: + kots.io/when: 'false' +data: + httpProxy: repl{{ HTTPProxy | quote }} + noProxy: repl{{ NoProxy | quote }}