Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/blobserve/configmap.go
2501 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package blobserve
6
7
import (
8
"fmt"
9
"time"
10
11
blobserve_config "github.com/gitpod-io/gitpod/blobserve/pkg/config"
12
"github.com/gitpod-io/gitpod/common-go/baseserver"
13
"github.com/gitpod-io/gitpod/common-go/util"
14
"github.com/gitpod-io/gitpod/installer/pkg/common"
15
"github.com/gitpod-io/gitpod/installer/pkg/components/workspace"
16
"github.com/gitpod-io/gitpod/installer/pkg/components/workspace/ide"
17
18
corev1 "k8s.io/api/core/v1"
19
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20
"k8s.io/apimachinery/pkg/runtime"
21
)
22
23
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
24
bscfg := blobserve_config.Config{
25
BlobServe: blobserve_config.BlobServe{
26
Port: ContainerPort,
27
Timeout: util.Duration(time.Second * 5),
28
Repos: map[string]blobserve_config.Repo{
29
ctx.RepoName(ctx.Config.Repository, ide.CodeIDEImage): {
30
PrePull: []string{},
31
Workdir: "/ide",
32
// TODO consider to provide it as a part of image label or rather inline ${ide} and ${supervisor} in index.html
33
// to decouple blobserve and code image
34
InlineStatic: []blobserve_config.InlineReplacement{{
35
Search: "{{WORKBENCH_WEB_BASE_URL}}",
36
Replacement: "${ide}",
37
}, {
38
Search: "{{WORKBENCH_NLS_FALLBACK_URL}}",
39
Replacement: "${ide}/out/nls.messages.js",
40
}, {
41
Search: "{{WORKBENCH_NLS_URL}}",
42
Replacement: "${ide}/out/nls.messages.js",
43
}, {
44
Search: "/_supervisor/frontend",
45
Replacement: "${supervisor}",
46
}},
47
},
48
ctx.RepoName(ctx.Config.Repository, workspace.SupervisorImage): {
49
PrePull: []string{},
50
Workdir: "/.supervisor/frontend",
51
},
52
ctx.RepoName(ctx.Config.Repository, ide.XtermIDEImage): {
53
PrePull: []string{},
54
Workdir: "/ide/xterm",
55
InlineStatic: []blobserve_config.InlineReplacement{{
56
Search: "/_supervisor/frontend",
57
Replacement: "${supervisor}",
58
}},
59
},
60
},
61
BlobSpace: blobserve_config.BlobSpace{
62
Location: "/mnt/cache/blobserve",
63
MaxSize: MaxSizeBytes,
64
},
65
},
66
AuthCfg: "/mnt/pull-secret/pull-secret.json",
67
PProfAddr: common.LocalhostAddressFromPort(baseserver.BuiltinDebugPort),
68
PrometheusAddr: common.LocalhostPrometheusAddr(),
69
ReadinessProbeAddr: fmt.Sprintf(":%v", ReadinessPort),
70
}
71
72
fc, err := common.ToJSONString(bscfg)
73
if err != nil {
74
return nil, fmt.Errorf("failed to marshal blobserve config: %w", err)
75
}
76
77
return []runtime.Object{
78
&corev1.ConfigMap{
79
TypeMeta: common.TypeMetaConfigmap,
80
ObjectMeta: metav1.ObjectMeta{
81
Name: Component,
82
Namespace: ctx.Namespace,
83
Labels: common.CustomizeLabel(ctx, Component, common.TypeMetaConfigmap),
84
Annotations: common.CustomizeAnnotation(ctx, Component, common.TypeMetaConfigmap),
85
},
86
Data: map[string]string{
87
"config.json": string(fc),
88
},
89
},
90
}, nil
91
}
92
93