Skip to content

Commit 398c331

Browse files
Simon Emmsroboquat
authored andcommitted
[installer]: remove duplicate storage config function
1 parent 184c12e commit 398c331

File tree

5 files changed

+66
-97
lines changed

5 files changed

+66
-97
lines changed

installer/pkg/common/objects.go

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

77
import (
8-
"fmt"
9-
storageconfig "github.com/gitpod-io/gitpod/content-service/api/config"
108
corev1 "k8s.io/api/core/v1"
119
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1210
"k8s.io/apimachinery/pkg/runtime"
@@ -75,31 +73,6 @@ func GenerateService(component string, ports map[string]ServicePort, mod ...func
7573
}
7674
}
7775

78-
func StorageConfiguration(ctx *RenderContext) (*storageconfig.StorageConfig, error) {
79-
accessKey := ctx.Values.StorageAccessKey
80-
if accessKey == "" {
81-
return nil, fmt.Errorf("unknown value: storage access key")
82-
}
83-
secretKey := ctx.Values.StorageSecretKey
84-
if secretKey == "" {
85-
return nil, fmt.Errorf("unknown value: storage secret key")
86-
}
87-
88-
// todo(sje): support non-Minio storage configuration
89-
// todo(sje): this has been set up with only the default values - receive configuration
90-
return &storageconfig.StorageConfig{
91-
Kind: "minio",
92-
BlobQuota: 0,
93-
MinIOConfig: storageconfig.MinIOConfig{
94-
Endpoint: fmt.Sprintf("minio.%s.svc.cluster.local:%d", ctx.Namespace, MinioServiceAPIPort),
95-
AccessKeyID: accessKey,
96-
SecretAccessKey: secretKey,
97-
Secure: false,
98-
Region: "local",
99-
},
100-
}, nil
101-
}
102-
10376
// DockerRegistryHash creates a sample pod spec that can be converted into a hash for annotations
10477
func DockerRegistryHash(ctx *RenderContext) ([]runtime.Object, error) {
10578
if !pointer.BoolDeref(ctx.Config.ContainerRegistry.InCluster, false) {

installer/pkg/common/storage.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package common
66

77
import (
88
"fmt"
9-
109
storageconfig "github.com/gitpod-io/gitpod/content-service/api/config"
1110

1211
corev1 "k8s.io/api/core/v1"
@@ -47,7 +46,7 @@ func StorageConfig(context *RenderContext) storageconfig.StorageConfig {
4746
res = &storageconfig.StorageConfig{
4847
Kind: storageconfig.MinIOStorage,
4948
MinIOConfig: storageconfig.MinIOConfig{
50-
Endpoint: "minio:9000",
49+
Endpoint: fmt.Sprintf("minio.%s.svc.cluster.local:%d", context.Namespace, MinioServiceAPIPort),
5150
AccessKeyID: context.Values.StorageAccessKey,
5251
SecretAccessKey: context.Values.StorageSecretKey,
5352
Secure: false,

installer/pkg/components/content-service/configmap.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ import (
1717
)
1818

1919
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
20-
storageConfig, err := common.StorageConfiguration(ctx)
21-
if err != nil {
22-
return nil, err
23-
}
24-
2520
cscfg := config.ServiceConfig{
2621
Service: config.Service{
2722
Addr: fmt.Sprintf(":%d", RPCPort),
@@ -32,7 +27,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
3227
PProf: config.PProf{
3328
Addr: fmt.Sprintf(":%d", PProfPort),
3429
},
35-
Storage: *storageConfig,
30+
Storage: common.StorageConfig(ctx),
3631
}
3732

3833
fc, err := json.MarshalIndent(cscfg, "", " ")

installer/pkg/components/content-service/deployment.go

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,68 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
2323
return nil, err
2424
}
2525

26+
podSpec := corev1.PodSpec{
27+
Affinity: &corev1.Affinity{},
28+
ServiceAccountName: Component,
29+
EnableServiceLinks: pointer.Bool(false),
30+
DNSPolicy: "ClusterFirst",
31+
RestartPolicy: "Always",
32+
TerminationGracePeriodSeconds: pointer.Int64(30),
33+
Volumes: []corev1.Volume{{
34+
Name: "config",
35+
VolumeSource: corev1.VolumeSource{
36+
ConfigMap: &corev1.ConfigMapVolumeSource{
37+
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
38+
},
39+
},
40+
}},
41+
Containers: []corev1.Container{{
42+
Name: Component,
43+
Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ContentService.Version),
44+
ImagePullPolicy: corev1.PullIfNotPresent,
45+
Args: []string{
46+
"run",
47+
"--config",
48+
"/config/config.json",
49+
},
50+
Resources: corev1.ResourceRequirements{
51+
Requests: corev1.ResourceList{
52+
"cpu": resource.MustParse("100m"),
53+
"memory": resource.MustParse("32Mi"),
54+
},
55+
},
56+
Ports: []corev1.ContainerPort{{
57+
Name: RPCServiceName,
58+
ContainerPort: RPCPort,
59+
}, {
60+
ContainerPort: PrometheusPort,
61+
Name: PrometheusName,
62+
}},
63+
SecurityContext: &corev1.SecurityContext{
64+
Privileged: pointer.Bool(false),
65+
RunAsUser: pointer.Int64(1000),
66+
},
67+
Env: common.MergeEnv(
68+
common.DefaultEnv(&ctx.Config),
69+
common.TracingEnv(&ctx.Config),
70+
[]corev1.EnvVar{{
71+
Name: "GRPC_GO_RETRY",
72+
Value: "on",
73+
}},
74+
),
75+
VolumeMounts: []corev1.VolumeMount{{
76+
Name: "config",
77+
MountPath: "/config",
78+
ReadOnly: true,
79+
}},
80+
}},
81+
}
82+
83+
err = common.AddStorageMounts(ctx, &podSpec, Component)
84+
if err != nil {
85+
return nil, err
86+
}
87+
2688
return []runtime.Object{
2789
&v1.Deployment{
2890
TypeMeta: common.TypeMetaDeployment,
@@ -44,62 +106,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
44106
common.AnnotationConfigChecksum: configHash,
45107
},
46108
},
47-
Spec: corev1.PodSpec{
48-
Affinity: &corev1.Affinity{},
49-
ServiceAccountName: Component,
50-
EnableServiceLinks: pointer.Bool(false),
51-
DNSPolicy: "ClusterFirst",
52-
RestartPolicy: "Always",
53-
TerminationGracePeriodSeconds: pointer.Int64(30),
54-
Volumes: []corev1.Volume{{
55-
Name: "config",
56-
VolumeSource: corev1.VolumeSource{
57-
ConfigMap: &corev1.ConfigMapVolumeSource{
58-
LocalObjectReference: corev1.LocalObjectReference{Name: Component},
59-
},
60-
},
61-
}},
62-
Containers: []corev1.Container{{
63-
Name: Component,
64-
Image: common.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.ContentService.Version),
65-
ImagePullPolicy: corev1.PullIfNotPresent,
66-
Args: []string{
67-
"run",
68-
"--config",
69-
"/config/config.json",
70-
},
71-
Resources: corev1.ResourceRequirements{
72-
Requests: corev1.ResourceList{
73-
"cpu": resource.MustParse("100m"),
74-
"memory": resource.MustParse("32Mi"),
75-
},
76-
},
77-
Ports: []corev1.ContainerPort{{
78-
Name: RPCServiceName,
79-
ContainerPort: RPCPort,
80-
}, {
81-
ContainerPort: PrometheusPort,
82-
Name: PrometheusName,
83-
}},
84-
SecurityContext: &corev1.SecurityContext{
85-
Privileged: pointer.Bool(false),
86-
RunAsUser: pointer.Int64(1000),
87-
},
88-
Env: common.MergeEnv(
89-
common.DefaultEnv(&ctx.Config),
90-
common.TracingEnv(&ctx.Config),
91-
[]corev1.EnvVar{{
92-
Name: "GRPC_GO_RETRY",
93-
Value: "on",
94-
}},
95-
),
96-
VolumeMounts: []corev1.VolumeMount{{
97-
Name: "config",
98-
MountPath: "/config",
99-
ReadOnly: true,
100-
}},
101-
}},
102-
},
109+
Spec: podSpec,
103110
},
104111
},
105112
},

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
3939
return (&q).String()
4040
}
4141

42-
storage, err := common.StorageConfiguration(ctx)
43-
if err != nil {
44-
return nil, err
45-
}
46-
4742
wsmcfg := config.ServiceConfiguration{
4843
Manager: config.Configuration{
4944
Namespace: ctx.Namespace,
@@ -104,7 +99,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
10499
},
105100
Content: struct {
106101
Storage storageconfig.StorageConfig `json:"storage"`
107-
}{Storage: *storage},
102+
}{Storage: common.StorageConfig(ctx)},
108103
RPCServer: struct {
109104
Addr string `json:"addr"`
110105
TLS struct {

0 commit comments

Comments
 (0)