Skip to content

Commit cf1b4d4

Browse files
committed
[ws-manager] Respect imagebuild workspace template
1 parent 3e0bf75 commit cf1b4d4

File tree

4 files changed

+365
-8
lines changed

4 files changed

+365
-8
lines changed

chart/templates/ws-manager-configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ data:
7373
{{ if (or $wscomp.templates.prebuild $wscomp.affinity) -}}"prebuildPath": "/workspace-template/prebuild.yaml",{{- end }}
7474
{{ if (or $wscomp.templates.probe $wscomp.affinity) -}}"probePath": "/workspace-template/probe.yaml",{{- end }}
7575
{{ if (or $wscomp.templates.ghost $wscomp.affinity) -}}"ghostPath": "/workspace-template/ghost.yaml",{{- end }}
76+
{{ if (or $wscomp.templates.imagebuild $wscomp.affinity) -}}"imagebuildPath": "/workspace-template/imagebuild.yaml",{{- end }}
7677
{{ if (or $wscomp.templates.regular $wscomp.affinity) -}}"regularPath": "/workspace-template/regular.yaml",{{- end }}
7778
{{ end -}}
7879
"defaultPath": "/workspace-template/default.yaml"

components/ws-manager/pkg/manager/create_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ import (
2121

2222
func TestCreateDefiniteWorkspacePod(t *testing.T) {
2323
type fixture struct {
24-
Spec *json.RawMessage `json:"spec,omitempty"` // *api.StartWorkspaceSpec
25-
Request *json.RawMessage `json:"request,omitempty"` // *api.StartWorkspaceRequest
26-
Context *startWorkspaceContext `json:"context,omitempty"`
27-
DefaultTemplate *corev1.Pod `json:"defaultTemplate,omitempty"`
28-
PrebuildTemplate *corev1.Pod `json:"prebuildTemplate,omitempty"`
29-
ProbeTemplate *corev1.Pod `json:"probeTemplate,omitempty"`
30-
RegularTemplate *corev1.Pod `json:"regularTemplate,omitempty"`
31-
ResourceRequests *config.ResourceConfiguration `json:"resourceRequests,omitempty"`
24+
Spec *json.RawMessage `json:"spec,omitempty"` // *api.StartWorkspaceSpec
25+
Request *json.RawMessage `json:"request,omitempty"` // *api.StartWorkspaceRequest
26+
Context *startWorkspaceContext `json:"context,omitempty"`
27+
DefaultTemplate *corev1.Pod `json:"defaultTemplate,omitempty"`
28+
PrebuildTemplate *corev1.Pod `json:"prebuildTemplate,omitempty"`
29+
ProbeTemplate *corev1.Pod `json:"probeTemplate,omitempty"`
30+
ImagebuildTemplate *corev1.Pod `json:"imagebuildTemplate,omitempty"`
31+
RegularTemplate *corev1.Pod `json:"regularTemplate,omitempty"`
32+
ResourceRequests *config.ResourceConfiguration `json:"resourceRequests,omitempty"`
3233
}
3334
type gold struct {
3435
Pod corev1.Pod `json:"reason,omitempty"`
@@ -66,6 +67,7 @@ func TestCreateDefiniteWorkspacePod(t *testing.T) {
6667
{"default-template.yaml", fixture.DefaultTemplate, func(fn string) { manager.Config.WorkspacePodTemplate.DefaultPath = fn }},
6768
{"prebuild-template.yaml", fixture.PrebuildTemplate, func(fn string) { manager.Config.WorkspacePodTemplate.PrebuildPath = fn }},
6869
{"probe-template.yaml", fixture.ProbeTemplate, func(fn string) { manager.Config.WorkspacePodTemplate.ProbePath = fn }},
70+
{"imagebuild-template.yaml", fixture.ImagebuildTemplate, func(fn string) { manager.Config.WorkspacePodTemplate.ImagebuildPath = fn }},
6971
{"regular-template.yaml", fixture.RegularTemplate, func(fn string) { manager.Config.WorkspacePodTemplate.RegularPath = fn }},
7072
}
7173
for _, f := range files {
Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
{
2+
"reason": {
3+
"metadata": {
4+
"name": "imagebuild-foobar",
5+
"namespace": "default",
6+
"creationTimestamp": null,
7+
"labels": {
8+
"app": "gitpod",
9+
"component": "workspace",
10+
"gitpod.io/networkpolicy": "default",
11+
"gpwsman": "true",
12+
"headless": "true",
13+
"metaID": "foobar",
14+
"owner": "tester",
15+
"workspaceID": "foobar",
16+
"workspaceType": "imagebuild"
17+
},
18+
"annotations": {
19+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
20+
"container.apparmor.security.beta.kubernetes.io/workspace": "unconfined",
21+
"gitpod.io/requiredNodeServices": "ws-daemon,registry-facade",
22+
"gitpod/admission": "admit_owner_only",
23+
"gitpod/contentInitializer": "GmcKZXdvcmtzcGFjZXMvY3J5cHRpYy1pZC1nb2VzLWhlcmcvZmQ2MjgwNGItNGNhYi0xMWU5LTg0M2EtNGU2NDUzNzMwNDhlLnRhckBnaXRwb2QtZGV2LXVzZXItY2hyaXN0ZXN0aW5n",
24+
"gitpod/id": "foobar",
25+
"gitpod/imageSpec": "CrwBZXUuZ2NyLmlvL2dpdHBvZC1kZXYvd29ya3NwYWNlLWltYWdlcy9hYzFjMDc1NTAwNzk2NmU0ZDZlMDkwZWE4MjE3MjlhYzc0N2QyMmFjL2V1Lmdjci5pby9naXRwb2QtZGV2L3dvcmtzcGFjZS1iYXNlLWltYWdlcy9naXRodWIuY29tL3R5cGVmb3gvZ2l0cG9kOjgwYTdkNDI3YTFmY2QzNDZkNDIwNjAzZDgwYTMxZDU3Y2Y3NWE3YWYSNGV1Lmdjci5pby9naXRwb2QtY29yZS1kZXYvYnVpZC90aGVpYS1pZGU6c29tZXZlcnNpb24=",
26+
"gitpod/never-ready": "true",
27+
"gitpod/ownerToken": "%7J'[Of/8NDiWE+9F,I6^Jcj_1\u0026}-F8p",
28+
"gitpod/servicePrefix": "foobarservice",
29+
"gitpod/traceid": "",
30+
"gitpod/url": "foobar-foobarservice-gitpod.io",
31+
"prometheus.io/path": "/metrics",
32+
"prometheus.io/port": "23000",
33+
"prometheus.io/scrape": "true",
34+
"seccomp.security.alpha.kubernetes.io/pod": "localhost/workspace-default"
35+
}
36+
},
37+
"spec": {
38+
"volumes": [
39+
{
40+
"name": "vol-this-workspace",
41+
"hostPath": {
42+
"path": "/tmp/workspaces/foobar",
43+
"type": "DirectoryOrCreate"
44+
}
45+
},
46+
{
47+
"name": "daemon-mount",
48+
"hostPath": {
49+
"path": "/tmp/workspaces/foobar-daemon",
50+
"type": "DirectoryOrCreate"
51+
}
52+
}
53+
],
54+
"containers": [
55+
{
56+
"name": "workspace",
57+
"image": "registry-facade:8080/remote/foobar",
58+
"command": [
59+
"/.supervisor/workspacekit",
60+
"ring0"
61+
],
62+
"ports": [
63+
{
64+
"containerPort": 23000
65+
}
66+
],
67+
"env": [
68+
{
69+
"name": "GITPOD_REPO_ROOT",
70+
"value": "/workspace"
71+
},
72+
{
73+
"name": "GITPOD_CLI_APITOKEN",
74+
"value": "Ab=5=rRA*9:C'T{;RRB\u003e]vK2p6`fFfrS"
75+
},
76+
{
77+
"name": "GITPOD_WORKSPACE_ID",
78+
"value": "foobar"
79+
},
80+
{
81+
"name": "GITPOD_INSTANCE_ID",
82+
"value": "foobar"
83+
},
84+
{
85+
"name": "GITPOD_THEIA_PORT",
86+
"value": "23000"
87+
},
88+
{
89+
"name": "THEIA_WORKSPACE_ROOT",
90+
"value": "/workspace"
91+
},
92+
{
93+
"name": "GITPOD_HOST",
94+
"value": "gitpod.io"
95+
},
96+
{
97+
"name": "GITPOD_WORKSPACE_URL",
98+
"value": "foobar-foobarservice-gitpod.io"
99+
},
100+
{
101+
"name": "THEIA_SUPERVISOR_ENDPOINT",
102+
"value": ":22999"
103+
},
104+
{
105+
"name": "THEIA_WEBVIEW_EXTERNAL_ENDPOINT",
106+
"value": "webview-{{hostname}}"
107+
},
108+
{
109+
"name": "THEIA_MINI_BROWSER_HOST_PATTERN",
110+
"value": "browser-{{hostname}}"
111+
},
112+
{
113+
"name": "GITPOD_GIT_USER_NAME",
114+
"value": "usernameGoesHere"
115+
},
116+
{
117+
"name": "GITPOD_GIT_USER_EMAIL",
118+
"value": "[email protected]"
119+
},
120+
{
121+
"name": "foo",
122+
"value": "bar"
123+
},
124+
{
125+
"name": "GITPOD_INTERVAL",
126+
"value": "30000"
127+
},
128+
{
129+
"name": "GITPOD_MEMORY",
130+
"value": "999"
131+
},
132+
{
133+
"name": "GITPOD_HEADLESS",
134+
"value": "true"
135+
},
136+
{
137+
"name": "some-envvar",
138+
"value": "foofoo"
139+
}
140+
],
141+
"resources": {
142+
"limits": {
143+
"cpu": "900m",
144+
"memory": "1G"
145+
},
146+
"requests": {
147+
"cpu": "899m",
148+
"ephemeral-storage": "5Gi",
149+
"memory": "999M"
150+
}
151+
},
152+
"volumeMounts": [
153+
{
154+
"name": "vol-this-workspace",
155+
"mountPath": "/workspace",
156+
"mountPropagation": "HostToContainer"
157+
},
158+
{
159+
"name": "daemon-mount",
160+
"mountPath": "/.workspace",
161+
"mountPropagation": "HostToContainer"
162+
}
163+
],
164+
"readinessProbe": {
165+
"httpGet": {
166+
"path": "/_supervisor/v1/status/content/wait/true",
167+
"port": 22999,
168+
"scheme": "HTTP"
169+
},
170+
"initialDelaySeconds": 4,
171+
"timeoutSeconds": 1,
172+
"periodSeconds": 1,
173+
"successThreshold": 1,
174+
"failureThreshold": 600
175+
},
176+
"terminationMessagePolicy": "File",
177+
"imagePullPolicy": "IfNotPresent",
178+
"securityContext": {
179+
"capabilities": {
180+
"add": [
181+
"AUDIT_WRITE",
182+
"FSETID",
183+
"KILL",
184+
"NET_BIND_SERVICE",
185+
"SYS_PTRACE"
186+
],
187+
"drop": [
188+
"SETPCAP",
189+
"CHOWN",
190+
"NET_RAW",
191+
"DAC_OVERRIDE",
192+
"FOWNER",
193+
"SYS_CHROOT",
194+
"SETFCAP",
195+
"SETUID",
196+
"SETGID"
197+
]
198+
},
199+
"privileged": false,
200+
"runAsUser": 33333,
201+
"runAsGroup": 33333,
202+
"runAsNonRoot": true,
203+
"readOnlyRootFilesystem": false,
204+
"allowPrivilegeEscalation": true
205+
}
206+
}
207+
],
208+
"restartPolicy": "Never",
209+
"dnsPolicy": "None",
210+
"serviceAccountName": "workspace",
211+
"automountServiceAccountToken": false,
212+
"imagePullSecrets": [
213+
{
214+
"name": "dockerhub-gitpod"
215+
},
216+
{
217+
"name": "eu.gcr.io-gitpod"
218+
}
219+
],
220+
"affinity": {
221+
"nodeAffinity": {
222+
"requiredDuringSchedulingIgnoredDuringExecution": {
223+
"nodeSelectorTerms": [
224+
{
225+
"matchExpressions": [
226+
{
227+
"key": "gitpod.io/workload_imagebuild",
228+
"operator": "In",
229+
"values": [
230+
"true"
231+
]
232+
}
233+
]
234+
}
235+
]
236+
}
237+
}
238+
},
239+
"schedulerName": "workspace-scheduler",
240+
"tolerations": [
241+
{
242+
"key": "node.kubernetes.io/disk-pressure",
243+
"operator": "Exists",
244+
"effect": "NoExecute"
245+
},
246+
{
247+
"key": "node.kubernetes.io/memory-pressure",
248+
"operator": "Exists",
249+
"effect": "NoExecute"
250+
},
251+
{
252+
"key": "node.kubernetes.io/network-unavailable",
253+
"operator": "Exists",
254+
"effect": "NoExecute",
255+
"tolerationSeconds": 30
256+
}
257+
],
258+
"dnsConfig": {
259+
"nameservers": [
260+
"1.1.1.1",
261+
"8.8.8.8"
262+
]
263+
},
264+
"enableServiceLinks": false
265+
},
266+
"status": {}
267+
}
268+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"defaultTemplate": {
3+
"spec": {
4+
"dnsConfig": {
5+
"nameservers": [
6+
"1.1.1.1",
7+
"8.8.8.8"
8+
]
9+
},
10+
"dnsPolicy": "None",
11+
"imagePullSecrets": [
12+
{
13+
"name": "dockerhub-gitpod"
14+
},
15+
{
16+
"name": "eu.gcr.io-gitpod"
17+
}
18+
],
19+
"containers": [
20+
{
21+
"name": "workspace",
22+
"env": [
23+
{ "name": "some-envvar", "value": "foofoo" }
24+
]
25+
}
26+
]
27+
}
28+
},
29+
"imagebuildTemplate": {
30+
"spec": {
31+
"affinity": {
32+
"nodeAffinity": {
33+
"requiredDuringSchedulingIgnoredDuringExecution": {
34+
"nodeSelectorTerms": [
35+
{
36+
"matchExpressions": [
37+
{
38+
"key": "gitpod.io/workload_imagebuild",
39+
"operator": "In",
40+
"values": [
41+
"true"
42+
]
43+
}
44+
]
45+
}
46+
]
47+
}
48+
}
49+
}
50+
}
51+
},
52+
"request": {
53+
"id": "foobar",
54+
"type": 4,
55+
"metadata": {
56+
"owner": "tester",
57+
"metaId": "foobar"
58+
},
59+
"servicePrefix": "foobarservice",
60+
"spec": {
61+
"ideImage": "eu.gcr.io/gitpod-core-dev/buid/theia-ide:someversion",
62+
"workspaceImage": "eu.gcr.io/gitpod-dev/workspace-images/ac1c0755007966e4d6e090ea821729ac747d22ac/eu.gcr.io/gitpod-dev/workspace-base-images/github.com/typefox/gitpod:80a7d427a1fcd346d420603d80a31d57cf75a7af",
63+
"initializer": {
64+
"snapshot": {
65+
"snapshot": "workspaces/cryptic-id-goes-herg/fd62804b-4cab-11e9-843a-4e645373048e.tar@gitpod-dev-user-christesting"
66+
}
67+
},
68+
"ports": [
69+
{
70+
"port": 8080,
71+
"target": 38080
72+
}
73+
],
74+
"envvars": [
75+
{
76+
"name": "foo",
77+
"value": "bar"
78+
}
79+
],
80+
"git": {
81+
"username": "usernameGoesHere",
82+
"email": "[email protected]"
83+
}
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)