-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[image-builder] Backport mkIII from gitpod-com #4547
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3d52016
[ws-manager] Add support for workspace annotations
csweichel acaa384
[image-builder] Backport mk3 from gitpod-com
csweichel 5de3d7f
[chart] Add image builder mk3
csweichel 5b97e57
[ws-manager] Handle AlreadyExists in StartWorkspace
csweichel dbf4488
[image-builder] Add integration tests
csweichel 3ebfe4e
[image-builder] Maintain local runnig build state
csweichel 6e98994
[server] Use image-builder-mk3 by default
csweichel b378f40
[server] Properly use image builder ref
csweichel 67f695e
[image-builder-mk3] Adapt to new log infrastructure
csweichel 6a7b542
[image-builder-mk3] Handle refs without tag
csweichel 106733f
[server] Support configuring image builder service
csweichel 0a4ae88
[ws-proxy] Disable compression on supervisor API
csweichel 1598876
[image-builder-mk3] Improve in-build log output
csweichel 36cca67
[image-builder-mk3] Rollback to buildkit v0.8.3
csweichel e520320
[ws-manager] Properly stop all headless workspaces
csweichel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: image-builder-mk3-authkey | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
type: Opaque | ||
data: | ||
keyfile: {{ randAlphaNum 32 | b64enc }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ $comp := .Values.components.imageBuilderMk3 -}} | ||
{{ $compImgbldr := .Values.components.imageBuilder -}} | ||
{{- $this := dict "root" . "gp" $.Values "comp" $comp "compImgbldr" $compImgbldr -}} | ||
|
||
{{- define "registry-name" -}} | ||
{{- $comp := .comp -}} | ||
{{- $compImgbldr := .compImgbldr -}} | ||
{{- $ := .root -}} | ||
{{- if eq (default $comp.registry $compImgbldr.registry).name "builtin" -}} | ||
{{ template "gitpod.builtinRegistry.name" $ }} | ||
{{- else -}} | ||
{{ (default $comp.registry $compImgbldr.registry).name }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- if not $comp.disabled -}} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: image-builder-mk3-config | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
release: "{{ .Release.Name }}" | ||
heritage: "{{ .Release.Service }}" | ||
data: | ||
image-builder.json: |- | ||
{ | ||
"orchestrator": { | ||
{{- if (default $comp.registry $compImgbldr.registry).secretName -}}"authFile": "/config/pull-secret.json",{{- end -}} | ||
"gitpodLayerLoc": "/app/workspace-image-layer.tar.gz", | ||
"baseImageRepository": "{{ or (default $comp.registry $compImgbldr.registry).baseImageName (print (include "registry-name" $this) "/base-images") }}", | ||
"workspaceImageRepository": "{{ or (default $comp.registry $compImgbldr.registry).workspaceImageName (print (include "registry-name" $this) "/workspace-images") }}", | ||
"imageBuildSalt": "{{ $comp.imageBuildSalt | default "" }}", | ||
{{- if $comp.wsman -}} | ||
{{ $comp.wsman | fromYaml | toJson }} | ||
{{- else -}} | ||
"wsman": { | ||
"address": "ws-manager:8080", | ||
"tls": { | ||
"ca": "/wsman-certs/ca.crt", | ||
"crt": "/wsman-certs/tls.crt", | ||
"key": "/wsman-certs/tls.key" | ||
} | ||
}, | ||
{{- end -}} | ||
"builderImage": "{{ template "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" $comp.builderImage) }}", | ||
"builderAuthKeyFile": "/config/authkey" | ||
}, | ||
"refCache": { | ||
"interval": "6h", | ||
"refs": ["{{ template "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.defaultImage) }}"] | ||
}, | ||
"pprof": { | ||
"address": ":6060" | ||
}, | ||
"prometheus": { | ||
"address": "127.0.0.1:9500" | ||
}, | ||
"service": { | ||
"address": ":8080" | ||
} | ||
} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ $comp := .Values.components.imageBuilderMk3 -}} | ||
{{ $compImgbldr := .Values.components.imageBuilder -}} | ||
{{- $this := dict "root" . "gp" $.Values "comp" $comp "compImgbldr" $compImgbldr -}} | ||
{{- if not $comp.disabled -}} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: image-builder-mk3 | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: deployment | ||
stage: {{ .Values.installation.stage }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: pod | ||
stage: {{ .Values.installation.stage }} | ||
replicas: {{ $comp.replicas | default 1 }} | ||
strategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 0 | ||
template: | ||
metadata: | ||
name: image-builder-mk3 | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: pod | ||
stage: {{ .Values.installation.stage }} | ||
annotations: | ||
{{- if index .Values "docker-registry" "enabled" }} | ||
checksum/builtin-registry-auth: {{ include (print $.Template.BasePath "/builtin-registry-auth-secret.yaml") . | sha256sum }} | ||
{{- end -}} | ||
{{ include "gitpod.pod.dependsOn" $this | indent 8 }} | ||
spec: | ||
{{ include "gitpod.workspaceAffinity" $this | indent 6 }} | ||
serviceAccountName: image-builder-mk3 | ||
volumes: | ||
- name: configuration | ||
configMap: | ||
name: {{ template "gitpod.comp.configMap" $this }} | ||
- name: authkey | ||
secret: | ||
secretName: image-builder-mk3-authkey | ||
{{- if (default $compImgbldr.registry).secretName }} | ||
- name: pull-secret | ||
secret: | ||
secretName: {{ (default $compImgbldr.registry).secretName }} | ||
{{- end }} | ||
{{- range $idx, $sec := (default $comp.registryCerts $compImgbldr.registryCerts) }} | ||
- name: docker-tls-certs-{{ $idx }} | ||
secret: | ||
secretName: {{ $sec.secret }} | ||
{{- end }} | ||
- name: wsman-tls-certs | ||
secret: | ||
secretName: {{ .Values.components.wsManager.tls.server.secretName }} | ||
enableServiceLinks: false | ||
containers: | ||
{{ include "gitpod.kube-rbac-proxy" $this | indent 6 }} | ||
- name: image-builder-mk3 | ||
{{ include "gitpod.container.defaultEnv" $this | indent 8 }} | ||
{{ include "gitpod.container.tracingEnv" $this | indent 8 }} | ||
image: {{ template "gitpod.comp.imageFull" $this }} | ||
args: | ||
- "run" | ||
- "-v" | ||
- "--config" | ||
- "/config/image-builder.json" | ||
{{ include "gitpod.container.imagePullPolicy" $this | indent 8 }} | ||
volumeMounts: | ||
- mountPath: /config/image-builder.json | ||
subPath: "image-builder.json" | ||
name: configuration | ||
- mountPath: /config/authkey | ||
subPath: "keyfile" | ||
name: authkey | ||
- mountPath: /wsman-certs | ||
name: wsman-tls-certs | ||
readOnly: true | ||
{{- if (default $comp $compImgbldr).registry }} | ||
{{- if (default $comp $compImgbldr).registry.secretName }} | ||
- mountPath: /config/pull-secret.json | ||
subPath: .dockerconfigjson | ||
name: pull-secret | ||
{{- end }} | ||
{{- end }} | ||
resources: | ||
requests: | ||
cpu: {{ $.Values.resources.default.cpu }} | ||
memory: {{ $.Values.resources.default.memory }} | ||
{{ include "gitpod.container.ports" $this | indent 8 }} | ||
securityContext: | ||
runAsUser: 33333 | ||
privileged: false | ||
{{ include "gitpod.container.defaultEnv" $this | indent 8 }} | ||
{{ include "gitpod.container.tracingEnv" $this | indent 8 }} | ||
{{ toYaml .Values.defaults | indent 6 }} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ if .Values.installNetworkPolicies -}} | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: image-builder-mk3 | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: networkpolicy | ||
stage: {{ .Values.installation.stage }} | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
ingress: | ||
# server | ||
- from: | ||
- podSelector: | ||
matchLabels: | ||
app: {{ template "gitpod.fullname" $ }} | ||
component: {{ .Values.components.server.name }} | ||
egress: | ||
- to: | ||
# Allow egress to everywhere, except... | ||
- ipBlock: | ||
cidr: 0.0.0.0/0 | ||
except: | ||
# Google Compute engine special, reserved VM metadata IP | ||
- 169.254.169.254/32 | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ if .Values.installPodSecurityPolicies -}} | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: {{ .Release.Namespace }}-ns-image-builder-mk3 | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: cluster | ||
kind: clusterrole | ||
stage: {{ .Values.installation.stage }} | ||
rules: | ||
- apiGroups: ["policy"] | ||
resources: ["podsecuritypolicies"] | ||
verbs: ["use"] | ||
resourceNames: | ||
- {{ .Release.Namespace }}-ns-privileged-unconfined | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: image-builder-mk3-rb | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: role-binding | ||
stage: {{ .Values.installation.stage }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: image-builder-mk3 | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ .Release.Namespace }}-ns-image-builder-mk3 | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
|
||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: {{ .Release.Namespace }}-image-builder-mk3-kube-rbac-proxy | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: role-binding | ||
stage: {{ .Values.installation.stage }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: image-builder-mk3 | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ .Release.Namespace }}-kube-rbac-proxy | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ template "gitpod.service.default" dict "root" . "gp" .Values "comp" .Values.components.imageBuilderMk3 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: image-builder-mk3 | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: image-builder-mk3 | ||
kind: service-account | ||
stage: {{ .Values.installation.stage }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is still used below (cmp. here). If we remove here the fallbacks should go away as well.