Skip to content

Commit 9d9a1d3

Browse files
author
Simon Emms
committed
[installer]: general fixes for the workspace components
This now installs the workspace components to a cluster using an InCluster database and registry
1 parent 3ddc108 commit 9d9a1d3

File tree

25 files changed

+288
-161
lines changed

25 files changed

+288
-161
lines changed

installer/pkg/common/constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ const (
1515
InClusterMessageQueueTLS = "messagebus-certificates-secret-core"
1616
MonitoringChart = "monitoring"
1717
ProxyComponent = "proxy"
18+
RegistryFacadeComponent = "registry-facade"
19+
RegistryFacadeServicePort = 3000
1820
ServerComponent = "server"
1921
SystemNodeCritical = "system-node-critical"
22+
WSManagerComponent = "ws-manager"
23+
WSManagerBridgeComponent = "ws-manager-bridge"
24+
WSProxyComponent = "ws-proxy"
25+
WSSchedulerComponent = "ws-scheduler"
2026
)
2127

2228
const (

installer/pkg/common/objects.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package common
66

77
import (
88
"fmt"
9+
storageconfig "github.com/gitpod-io/gitpod/content-service/api/config"
910
corev1 "k8s.io/api/core/v1"
1011
rbacv1 "k8s.io/api/rbac/v1"
1112
"k8s.io/apimachinery/pkg/api/resource"
@@ -113,3 +114,28 @@ func GlobalObjects(ctx *RenderContext) ([]runtime.Object, error) {
113114
},
114115
}, nil
115116
}
117+
118+
func StorageConfiguration(ctx *RenderContext) (*storageconfig.StorageConfig, error) {
119+
accessKey, found := ctx.Values[ValueStorageAccessKey]
120+
if !found {
121+
return nil, fmt.Errorf("unknown value: %s", ValueStorageAccessKey)
122+
}
123+
secretKey, found := ctx.Values[ValueStorageSecretKey]
124+
if !found {
125+
return nil, fmt.Errorf("unknown value: %s", ValueStorageSecretKey)
126+
}
127+
128+
// todo(sje): support non-Minio storage configuration
129+
// todo(sje): this has been set up with only the default values - receive configuration
130+
return &storageconfig.StorageConfig{
131+
Kind: "minio",
132+
BlobQuota: 0,
133+
MinIOConfig: storageconfig.MinIOConfig{
134+
Endpoint: fmt.Sprintf("minio.%s", ctx.Config.Domain),
135+
AccessKeyID: accessKey,
136+
SecretAccessKey: secretKey,
137+
Secure: false,
138+
Region: "local",
139+
},
140+
}, nil
141+
}

installer/pkg/components/blobserve/deployment.go

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package blobserve
66

77
import (
88
"github.com/gitpod-io/gitpod/installer/pkg/common"
9-
9+
dockerregistry "github.com/gitpod-io/gitpod/installer/pkg/components/docker-registry"
1010
appsv1 "k8s.io/api/apps/v1"
1111
corev1 "k8s.io/api/core/v1"
1212
"k8s.io/apimachinery/pkg/api/resource"
@@ -18,6 +18,42 @@ import (
1818
func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
1919
labels := common.DefaultLabels(Component)
2020

21+
volumes := []corev1.Volume{{
22+
Name: "cache",
23+
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
24+
}, {
25+
Name: "config",
26+
VolumeSource: corev1.VolumeSource{
27+
ConfigMap: &corev1.ConfigMapVolumeSource{
28+
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
29+
},
30+
},
31+
}}
32+
33+
volumeMounts := []corev1.VolumeMount{{
34+
Name: "config",
35+
MountPath: "/mnt/config",
36+
ReadOnly: true,
37+
}, {
38+
Name: "cache",
39+
MountPath: "/mnt/cache",
40+
}}
41+
42+
if pointer.BoolDeref(ctx.Config.ContainerRegistry.InCluster, false) {
43+
volumeName := "pull-secret"
44+
volumes = append(volumes, corev1.Volume{
45+
Name: volumeName,
46+
VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{
47+
SecretName: dockerregistry.BuiltInRegistryAuth,
48+
}},
49+
})
50+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
51+
Name: volumeName,
52+
MountPath: "/mnt/pull-secret.json",
53+
SubPath: ".dockerconfigjson",
54+
})
55+
}
56+
2157
return []runtime.Object{
2258
&appsv1.Deployment{
2359
TypeMeta: common.TypeMetaDeployment,
@@ -41,22 +77,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
4177
Affinity: &corev1.Affinity{},
4278
ServiceAccountName: Component,
4379
EnableServiceLinks: pointer.Bool(false),
44-
Volumes: []corev1.Volume{{
45-
Name: "cache",
46-
VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}},
47-
}, {
48-
Name: "config",
49-
VolumeSource: corev1.VolumeSource{
50-
ConfigMap: &corev1.ConfigMapVolumeSource{
51-
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
52-
},
53-
},
54-
}, {
55-
Name: "pull-secret",
56-
VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{
57-
SecretName: "",
58-
}},
59-
}},
80+
Volumes: volumes,
6081
Containers: []corev1.Container{{
6182
Name: Component,
6283
Args: []string{"run", "-v", "/mnt/config/config.json"},
@@ -80,14 +101,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
80101
common.DefaultEnv(&ctx.Config),
81102
common.TracingEnv(&ctx.Config),
82103
),
83-
VolumeMounts: []corev1.VolumeMount{{
84-
Name: "config",
85-
MountPath: "/mnt/config",
86-
ReadOnly: true,
87-
}, {
88-
Name: "cache",
89-
MountPath: "/mnt/cache",
90-
}},
104+
VolumeMounts: volumeMounts,
91105
}, *common.KubeRBACProxyContainer()},
92106
},
93107
},

installer/pkg/components/registry-facade/configmap.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
4040
TLS: &tls,
4141
Store: "/mnt/cache/registry",
4242
RequireAuth: false,
43-
// todo(sje): figure out these values
4443
StaticLayer: []regfac.StaticLayerCfg{{
45-
Ref: common.ImageName(ctx.Config.Repository, Component, "todo"),
44+
Ref: common.ImageName(ctx.Config.Repository, SupervisorImage, ctx.VersionManifest.Components.Workspace.Supervisor.Version),
4645
Type: "image",
4746
}, {
48-
Ref: common.ImageName(ctx.Config.Repository, Component, "todo"),
47+
Ref: common.ImageName(ctx.Config.Repository, DockerUpImage, ctx.VersionManifest.Components.Workspace.DockerUp.Version),
4948
Type: "image",
5049
}},
5150
},

installer/pkg/components/registry-facade/constants.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44

55
package registryfacade
66

7+
import (
8+
"github.com/gitpod-io/gitpod/installer/pkg/common"
9+
"github.com/gitpod-io/gitpod/installer/pkg/components/workspace"
10+
)
11+
712
const (
8-
Component = "registry-facade"
13+
Component = common.RegistryFacadeComponent
914
ContainerPortName = "registry"
1015
ContainerPort = 32223
11-
ServicePort = 3000
16+
ServicePort = common.RegistryFacadeServicePort
17+
DockerUpImage = workspace.DockerUpImage
18+
SupervisorImage = workspace.SupervisorImage
1219
)

installer/pkg/components/registry-facade/podsecuritypolicy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package registryfacade
66

77
import (
8+
"fmt"
89
"github.com/gitpod-io/gitpod/installer/pkg/common"
910

1011
"k8s.io/api/policy/v1beta1"
@@ -16,7 +17,7 @@ func podsecuritypolicy(ctx *common.RenderContext) ([]runtime.Object, error) {
1617
return []runtime.Object{&v1beta1.PodSecurityPolicy{
1718
TypeMeta: common.TypeMetaPodSecurityPolicy,
1819
ObjectMeta: metav1.ObjectMeta{
19-
Name: Component,
20+
Name: fmt.Sprintf("%s-ns-%s", ctx.Namespace, Component),
2021
Namespace: ctx.Namespace,
2122
Labels: common.DefaultLabels(Component),
2223
Annotations: map[string]string{

installer/pkg/components/workspace/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package workspace
66

77
const (
8+
ContainerPort = 23000
89
DefaultWorkspaceImage = "gitpod/workspace-full"
910
DefaultWorkspaceImageVersion = "latest"
1011
IDEImageRepo = "ide/code" // todo(sje): does this need to be config driven?
12+
DockerUpImage = "docker-up"
13+
SupervisorImage = "supervisor"
14+
SupervisorPort = 22999
1115
)

installer/pkg/components/ws-daemon/clusterrole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func clusterrole(ctx *common.RenderContext) ([]runtime.Object, error) {
2121
&rbacv1.ClusterRole{
2222
TypeMeta: common.TypeMetaClusterRole,
2323
ObjectMeta: metav1.ObjectMeta{
24-
Name: Component,
24+
Name: fmt.Sprintf("%s-ns-%s", ctx.Namespace, Component),
2525
Namespace: ctx.Namespace,
2626
Labels: labels,
2727
},

installer/pkg/components/ws-daemon/configmap.go

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ import (
2727
"k8s.io/apimachinery/pkg/runtime"
2828
)
2929

30-
const (
31-
locContainerWorkingArea = "/mnt/workingarea"
32-
locNodeWorkingArea = "/mnt/disks/ssd0/workspaces"
33-
)
34-
3530
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
3631
var fsshift wsdapi.FSShiftMethod
3732
switch ctx.Config.Workspace.Runtime.FSShiftMethod {
@@ -46,26 +41,38 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
4641
wsdcfg := wsdconfig.Config{
4742
Daemon: daemon.Config{
4843
Runtime: daemon.RuntimeConfig{
44+
KubernetesNamespace: ctx.Namespace,
4945
Container: &container.Config{
5046
Runtime: container.RuntimeContainerd,
47+
Mapping: map[string]string{
48+
ctx.Config.Workspace.Runtime.ContainerDRuntimeDir: "/mnt/node0",
49+
},
5150
Mounts: container.NodeMountsLookupConfig{
52-
ProcLoc: "/mnt/rootfs/proc",
51+
ProcLoc: "/mnt/mounts",
5352
},
5453
Containerd: &container.ContainerdConfig{
55-
SocketPath: "/mnt/rootfs/run/containerd/containerd.sock",
54+
SocketPath: "/mnt/containerd.sock",
5655
},
5756
},
5857
},
5958
Content: content.Config{
60-
WorkingArea: locContainerWorkingArea,
61-
WorkingAreaNode: locNodeWorkingArea,
59+
WorkingArea: "/mnt/workingarea",
60+
WorkingAreaNode: HostWorkspacePath,
61+
TmpDir: "/tmp",
6262
UserNamespaces: content.UserNamespacesConfig{
6363
FSShift: content.FSShiftMethod(fsshift),
6464
},
6565
Storage: common.StorageConfig(&ctx.Config),
66+
Backup: content.BackupConfig{
67+
Timeout: util.Duration(time.Minute * 5),
68+
Attempts: 3,
69+
},
70+
Initializer: content.InitializerConfig{
71+
Command: "/app/content-initializer",
72+
},
6673
},
6774
Uidmapper: iws.UidmapperConfig{
68-
ProcLocation: "/mnt/rootfs/proc",
75+
ProcLocation: "/proc",
6976
RootRange: iws.UIDRange{
7077
Start: 33333,
7178
Size: 1,
@@ -84,7 +91,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
8491
},
8592
ControlPeriod: "15m",
8693
SamplingPeriod: "10s",
87-
CGroupsBasePath: "/mnt/rootfs/sys/fs/cgroup",
94+
CGroupsBasePath: "/mnt/node-cgroups",
8895
ProcessPriorities: map[resources.ProcessType]int{
8996
resources.ProcessSupervisor: 0,
9097
resources.ProcessTheia: 5,
@@ -94,7 +101,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
94101
},
95102
Hosts: hosts.Config{
96103
Enabled: true,
97-
NodeHostsFile: "/mnt/rootfs/etc/hosts",
104+
NodeHostsFile: "/mnt/hosts",
98105
FixedHosts: map[string][]hosts.Host{
99106
"registryFacade": {{
100107
Name: fmt.Sprintf("reg.%s", ctx.Config.Domain),
@@ -110,11 +117,19 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
110117
Enabled: true,
111118
Interval: util.Duration(5 * time.Minute),
112119
Locations: []diskguard.LocationConfig{{
113-
Path: locContainerWorkingArea,
120+
Path: "/mnt/wsdaemon-workingarea",
114121
MinBytesAvail: 21474836480,
115122
}},
116123
},
117124
},
125+
Service: wsdconfig.AddrTLS{
126+
Addr: fmt.Sprintf(":%d", ServicePort),
127+
TLS: &wsdconfig.TLS{
128+
Authority: "/certs/ca.crt",
129+
Certificate: "/certs/tls.crt",
130+
PrivateKey: "/certs/tls.key",
131+
},
132+
},
118133
Prometheus: wsdconfig.Addr{
119134
Addr: "localhost:9500",
120135
},

installer/pkg/components/ws-daemon/constants.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
package wsdaemon
66

77
const (
8-
Component = "ws-daemon"
9-
ServicePort = 8080
10-
TLSSecretName = "ws-daemon-tls"
11-
VolumeTLSCerts = "ws-daemon-tls-certs"
8+
Component = "ws-daemon"
9+
ServicePort = 8080
10+
HostWorkspacePath = "/var/gitpod/workspaces"
11+
TLSSecretName = "ws-daemon-tls"
12+
VolumeTLSCerts = "ws-daemon-tls-certs"
1213
)

0 commit comments

Comments
 (0)