Skip to content

Commit bdcae19

Browse files
Simon Emmsroboquat
authored andcommitted
[installer]: general fixes for the workspace components
This now installs the workspace components to a cluster using an InCluster database and registry
1 parent 2a78aa4 commit bdcae19

File tree

27 files changed

+327
-158
lines changed

27 files changed

+327
-158
lines changed

installer/pkg/common/constants.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ 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
)

installer/pkg/common/objects.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package common
66

77
import (
8+
"fmt"
9+
storageconfig "github.com/gitpod-io/gitpod/content-service/api/config"
810
corev1 "k8s.io/api/core/v1"
911
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1012
"k8s.io/apimachinery/pkg/runtime"
@@ -69,3 +71,28 @@ func GenerateService(component string, ports map[string]ServicePort, mod ...func
6971
}}, nil
7072
}
7173
}
74+
75+
func StorageConfiguration(ctx *RenderContext) (*storageconfig.StorageConfig, error) {
76+
accessKey := ctx.Values.StorageAccessKey
77+
if accessKey == "" {
78+
return nil, fmt.Errorf("unknown value: storage access key")
79+
}
80+
secretKey := ctx.Values.StorageSecretKey
81+
if secretKey == "" {
82+
return nil, fmt.Errorf("unknown value: storage secret key")
83+
}
84+
85+
// todo(sje): support non-Minio storage configuration
86+
// todo(sje): this has been set up with only the default values - receive configuration
87+
return &storageconfig.StorageConfig{
88+
Kind: "minio",
89+
BlobQuota: 0,
90+
MinIOConfig: storageconfig.MinIOConfig{
91+
Endpoint: fmt.Sprintf("minio.%s", ctx.Config.Domain),
92+
AccessKeyID: accessKey,
93+
SecretAccessKey: secretKey,
94+
Secure: false,
95+
Region: "local",
96+
},
97+
}, nil
98+
}

installer/pkg/components/blobserve/deployment.go

Lines changed: 41 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,44 @@ 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+
{
35+
Name: "config",
36+
MountPath: "/mnt/config",
37+
ReadOnly: true,
38+
}, {
39+
Name: "cache",
40+
MountPath: "/mnt/cache",
41+
},
42+
}
43+
44+
if pointer.BoolDeref(ctx.Config.ContainerRegistry.InCluster, false) {
45+
volumeName := "pull-secret"
46+
volumes = append(volumes, corev1.Volume{
47+
Name: volumeName,
48+
VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{
49+
SecretName: dockerregistry.BuiltInRegistryAuth,
50+
}},
51+
})
52+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
53+
Name: volumeName,
54+
MountPath: "/mnt/pull-secret.json",
55+
SubPath: ".dockerconfigjson",
56+
})
57+
}
58+
2159
return []runtime.Object{
2260
&appsv1.Deployment{
2361
TypeMeta: common.TypeMetaDeployment,
@@ -41,22 +79,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
4179
Affinity: &corev1.Affinity{},
4280
ServiceAccountName: Component,
4381
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-
}},
82+
Volumes: volumes,
6083
Containers: []corev1.Container{{
6184
Name: Component,
6285
Args: []string{"run", "-v", "/mnt/config/config.json"},
@@ -80,14 +103,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
80103
common.DefaultEnv(&ctx.Config),
81104
common.TracingEnv(&ctx.Config),
82105
),
83-
VolumeMounts: []corev1.VolumeMount{{
84-
Name: "config",
85-
MountPath: "/mnt/config",
86-
ReadOnly: true,
87-
}, {
88-
Name: "cache",
89-
MountPath: "/mnt/cache",
90-
}},
106+
VolumeMounts: volumeMounts,
91107
}, *common.KubeRBACProxyContainer()},
92108
},
93109
},

installer/pkg/components/docker-registry/secret.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"encoding/base64"
99
"encoding/json"
1010
"fmt"
11-
v1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
11+
certmanagerv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
1212
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
1313
"time"
1414

@@ -64,14 +64,14 @@ func secret(ctx *common.RenderContext) ([]runtime.Object, error) {
6464
"user": []byte(user),
6565
"password": []byte(password),
6666
},
67-
}, &v1.Certificate{
67+
}, &certmanagerv1.Certificate{
6868
TypeMeta: common.TypeMetaCertificate,
6969
ObjectMeta: metav1.ObjectMeta{
7070
Name: BuiltInRegistryCerts,
7171
Namespace: ctx.Namespace,
7272
Labels: common.DefaultLabels(Component),
7373
},
74-
Spec: v1.CertificateSpec{
74+
Spec: certmanagerv1.CertificateSpec{
7575
Duration: oneYear,
7676
SecretName: BuiltInRegistryCerts,
7777
IssuerRef: cmmeta.ObjectReference{

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
},

0 commit comments

Comments
 (0)