Skip to content

Commit d296035

Browse files
committed
[usage-controller] Initial installer configuration
1 parent ef24eb0 commit d296035

File tree

15 files changed

+220
-239
lines changed

15 files changed

+220
-239
lines changed

.werft/jobs/build/installer/installer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class Installer {
6767
this.configureAuthProviders(slice)
6868
this.configureSSHGateway(slice)
6969
this.configurePublicAPIServer(slice)
70+
this.configureUsage(slice)
7071

7172
if (this.options.analytics) {
7273
this.includeAnalytics(slice)
@@ -164,6 +165,10 @@ export class Installer {
164165
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.publicApi.enabled true`, { slice: slice })
165166
}
166167

168+
private configureUsage(slice: string) {
169+
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.usage.enabled true`, { slice: slice })
170+
}
171+
167172
private includeAnalytics(slice: string): void {
168173
exec(`yq w -i ${this.options.installerConfigPath} analytics.writer segment`, { slice: slice });
169174
exec(`yq w -i ${this.options.installerConfigPath} analytics.segmentKey ${this.options.analytics.token}`, { slice: slice });

components/usage-controller/BUILD.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

components/usage-controller/cmd/root.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

components/usage-controller/cmd/run.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

components/usage-controller/go.mod

Lines changed: 0 additions & 67 deletions
This file was deleted.

components/usage-controller/go.sum

Lines changed: 0 additions & 23 deletions
This file was deleted.

components/usage-controller/leeway.Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

components/usage-controller/main.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

install/installer/pkg/components/components-webapp/components.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
public_api_server "github.com/gitpod-io/gitpod/installer/pkg/components/public-api-server"
1818
"github.com/gitpod-io/gitpod/installer/pkg/components/rabbitmq"
1919
"github.com/gitpod-io/gitpod/installer/pkg/components/server"
20+
"github.com/gitpod-io/gitpod/installer/pkg/components/usage"
2021
wsmanagerbridge "github.com/gitpod-io/gitpod/installer/pkg/components/ws-manager-bridge"
2122
)
2223

@@ -33,6 +34,7 @@ var Objects = common.CompositeRenderFunc(
3334
server.Objects,
3435
wsmanagerbridge.Objects,
3536
public_api_server.Objects,
37+
usage.Objects,
3638
)
3739

3840
var Helm = common.CompositeHelmFunc(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 usage
6+
7+
const (
8+
Component = "usage"
9+
)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
package usage
5+
6+
import (
7+
"fmt"
8+
9+
"github.com/gitpod-io/gitpod/common-go/baseserver"
10+
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
11+
"github.com/gitpod-io/gitpod/installer/pkg/common"
12+
appsv1 "k8s.io/api/apps/v1"
13+
corev1 "k8s.io/api/core/v1"
14+
"k8s.io/apimachinery/pkg/api/resource"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/runtime"
17+
"k8s.io/apimachinery/pkg/util/intstr"
18+
"k8s.io/utils/pointer"
19+
)
20+
21+
func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
22+
labels := common.DefaultLabels(Component)
23+
return []runtime.Object{
24+
&appsv1.Deployment{
25+
TypeMeta: common.TypeMetaDeployment,
26+
ObjectMeta: metav1.ObjectMeta{
27+
Name: Component,
28+
Namespace: ctx.Namespace,
29+
Labels: labels,
30+
},
31+
Spec: appsv1.DeploymentSpec{
32+
Selector: &metav1.LabelSelector{MatchLabels: labels},
33+
Replicas: common.Replicas(ctx, Component),
34+
Strategy: appsv1.DeploymentStrategy{
35+
Type: appsv1.RecreateDeploymentStrategyType,
36+
},
37+
Template: corev1.PodTemplateSpec{
38+
ObjectMeta: metav1.ObjectMeta{
39+
Name: Component,
40+
Namespace: ctx.Namespace,
41+
Labels: labels,
42+
},
43+
Spec: corev1.PodSpec{
44+
Affinity: common.NodeAffinity(cluster.AffinityLabelMeta),
45+
ServiceAccountName: Component,
46+
EnableServiceLinks: pointer.Bool(false),
47+
DNSPolicy: "ClusterFirst",
48+
RestartPolicy: "Always",
49+
TerminationGracePeriodSeconds: pointer.Int64(30),
50+
Containers: []corev1.Container{{
51+
Name: Component,
52+
Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Usage.Version),
53+
Args: []string{
54+
"run",
55+
},
56+
ImagePullPolicy: corev1.PullIfNotPresent,
57+
Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{
58+
Requests: corev1.ResourceList{
59+
"cpu": resource.MustParse("100m"),
60+
"memory": resource.MustParse("64Mi"),
61+
},
62+
}),
63+
Ports: []corev1.ContainerPort{},
64+
SecurityContext: &corev1.SecurityContext{
65+
Privileged: pointer.Bool(false),
66+
},
67+
Env: common.MergeEnv(
68+
common.DefaultEnv(&ctx.Config),
69+
),
70+
LivenessProbe: &corev1.Probe{
71+
ProbeHandler: corev1.ProbeHandler{
72+
HTTPGet: &corev1.HTTPGetAction{
73+
Path: "/live",
74+
Port: intstr.IntOrString{IntVal: baseserver.BuiltinHealthPort},
75+
Scheme: corev1.URISchemeHTTP,
76+
},
77+
},
78+
FailureThreshold: 3,
79+
SuccessThreshold: 1,
80+
TimeoutSeconds: 1,
81+
},
82+
ReadinessProbe: &corev1.Probe{
83+
ProbeHandler: corev1.ProbeHandler{
84+
HTTPGet: &corev1.HTTPGetAction{
85+
Path: "/ready",
86+
Port: intstr.IntOrString{IntVal: baseserver.BuiltinHealthPort},
87+
Scheme: corev1.URISchemeHTTP,
88+
},
89+
},
90+
FailureThreshold: 3,
91+
SuccessThreshold: 1,
92+
TimeoutSeconds: 1,
93+
},
94+
},
95+
*common.KubeRBACProxyContainerWithConfig(ctx, 9500, fmt.Sprintf("http://127.0.0.1:%d/", baseserver.BuiltinMetricsPort)),
96+
},
97+
},
98+
},
99+
},
100+
},
101+
}, nil
102+
}

0 commit comments

Comments
 (0)