Skip to content

Commit c9bb2d8

Browse files
geroplroboquat
authored andcommitted
[installer] open-vsx: configure redis
1 parent 6015def commit c9bb2d8

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

install/installer/pkg/components/openvsx-proxy/configmap.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,31 @@ import (
1717
)
1818

1919
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
20-
// todo(sje): enable redis config
2120
imgcfg := openvsx.Config{
2221
LogDebug: false,
23-
CacheDurationRegular: util.Duration(time.Minute),
22+
CacheDurationRegular: util.Duration(time.Minute * 5),
2423
CacheDurationBackup: util.Duration(time.Hour * 72),
2524
URLUpstream: ctx.Config.OpenVSX.URL,
2625
URLLocal: fmt.Sprintf("https://open-vsx.%s", ctx.Config.Domain),
2726
MaxIdleConns: 1000,
2827
MaxIdleConnsPerHost: 1000,
2928
PrometheusAddr: fmt.Sprintf(":%d", PrometheusPort),
29+
RedisAddr: "localhost:6379",
3030
}
3131

32+
redisCfg := `
33+
maxmemory 100mb
34+
maxmemory-policy allkeys-lfu
35+
`
36+
3237
fc, err := common.ToJSONString(imgcfg)
3338
if err != nil {
3439
return nil, fmt.Errorf("failed to marshal openvsx config: %w", err)
3540
}
3641

3742
data := map[string]string{
3843
"config.json": string(fc),
44+
"redis.conf": redisCfg,
3945
}
4046

4147
return []runtime.Object{

install/installer/pkg/components/openvsx-proxy/statefulset.go

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,55 @@ func statefulset(ctx *common.RenderContext) ([]runtime.Object, error) {
9999
Env: common.MergeEnv(
100100
common.DefaultEnv(&ctx.Config),
101101
),
102-
}},
102+
}, {
103+
Name: "redis",
104+
Image: "redis:6.2",
105+
Command: []string{
106+
"redis-server",
107+
"/config/redis.conf",
108+
},
109+
Env: []v1.EnvVar{{
110+
Name: "MASTER",
111+
Value: "true",
112+
}},
113+
ImagePullPolicy: "IfNotPresent",
114+
Ports: []v1.ContainerPort{{
115+
ContainerPort: 6379,
116+
}},
117+
Resources: v1.ResourceRequirements{
118+
Requests: v1.ResourceList{
119+
"cpu": resource.MustParse("1m"),
120+
"memory": resource.MustParse("512Mi"),
121+
},
122+
},
123+
VolumeMounts: []v1.VolumeMount{{
124+
Name: "config",
125+
MountPath: "/config",
126+
}, {
127+
Name: "redis-data",
128+
MountPath: "/data",
129+
}},
130+
},
131+
},
132+
},
133+
},
134+
VolumeClaimTemplates: []v1.PersistentVolumeClaim{{
135+
ObjectMeta: metav1.ObjectMeta{
136+
Name: Component,
137+
Namespace: ctx.Namespace,
138+
Labels: labels,
103139
},
140+
Spec: v1.PersistentVolumeClaimSpec{
141+
AccessModes: []v1.PersistentVolumeAccessMode{
142+
v1.ReadWriteOnce,
143+
},
144+
Resources: v1.ResourceRequirements{
145+
Requests: v1.ResourceList{
146+
"storage": resource.MustParse("8Gi"),
147+
},
148+
},
149+
},
150+
},
104151
},
105152
},
106153
}}, nil

0 commit comments

Comments
 (0)