Skip to content

Commit 2524442

Browse files
committed
[ws-manager] Introduce GITPOD_DOCKERD_PROXY_ENABLED and if set, run docker-proxy in enclave and have supervisor configure dockerd for it
Tool: gitpod/catfood.gitpod.cloud
1 parent 6839b7d commit 2524442

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

components/ws-manager-mk2/controllers/create.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
wsk8s "github.com/gitpod-io/gitpod/common-go/kubernetes"
2727
"github.com/gitpod-io/gitpod/common-go/tracing"
28+
"github.com/gitpod-io/gitpod/common-go/util"
2829
csapi "github.com/gitpod-io/gitpod/content-service/api"
2930
regapi "github.com/gitpod-io/gitpod/registry-facade/api"
3031
"github.com/gitpod-io/gitpod/ws-manager-mk2/pkg/constants"
@@ -574,6 +575,23 @@ func createWorkspaceEnvironment(sctx *startWorkspaceContext) ([]corev1.EnvVar, e
574575
result = append(result, corev1.EnvVar{Name: "GIT_SSL_CAINFO", Value: customCAMountPath})
575576
}
576577

578+
if sctx.Workspace.Annotations[wsk8s.WorkspaceDockerdProxyAnnotation] == util.BooleanTrueString {
579+
var imageAuth string
580+
for _, ev := range sctx.Workspace.Spec.UserEnvVars {
581+
if ev.Name == "GITPOD_IMAGE_AUTH" {
582+
imageAuth = ev.Value
583+
break
584+
}
585+
}
586+
if imageAuth != "" {
587+
// Start the dockerd-proxy which injects all HTTP(S) requests with the credentials we got in GITPOD_IMAGE_AUTH
588+
result = append(result, corev1.EnvVar{Name: "WORKSPACEKIT_RING2_ENCLAVE", Value: "/.supervisor/supervisor dockerd-proxy"})
589+
result = append(result, corev1.EnvVar{Name: "WORKSPACEKIT_GITPOD_IMAGE_AUTH", Value: string(imageAuth)})
590+
// Trigger supervisor to configure dockerd to use this proxy
591+
result = append(result, corev1.EnvVar{Name: "GITPOD_DOCKERD_PROXY_ENABLED", Value: "true"})
592+
}
593+
}
594+
577595
// System level env vars
578596
for _, e := range sctx.Workspace.Spec.SysEnvVars {
579597
env := corev1.EnvVar{

components/ws-manager-mk2/service/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ func (wsm *WorkspaceManagerServer) StartWorkspace(ctx context.Context, req *wsma
225225
}
226226
}
227227

228+
for _, ev := range req.Spec.Envvars {
229+
if ev.Name == "GITPOD_DOCKERD_PROXY_ENABLED" {
230+
annotations[wsk8s.WorkspaceDockerdProxyAnnotation] = util.BooleanTrueString
231+
break
232+
}
233+
}
234+
228235
envSecretName := fmt.Sprintf("%s-%s", req.Id, "env")
229236
userEnvVars, envData := extractWorkspaceUserEnv(envSecretName, req.Spec.Envvars, req.Spec.SysEnvvars)
230237
sysEnvVars := extractWorkspaceSysEnv(req.Spec.SysEnvvars)

0 commit comments

Comments
 (0)