Skip to content

Commit

Permalink
[installer]: set proxy server configuration in installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Emms committed Aug 1, 2022
1 parent 91d6ced commit ba0fc86
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 15 deletions.
55 changes: 42 additions & 13 deletions install/installer/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions install/installer/pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installation-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions install/kots/manifests/gitpod-installation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions install/kots/manifests/gitpod-proxy-server.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit ba0fc86

Please sign in to comment.