Skip to content

Commit

Permalink
[usage-controller] Initial installer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed May 25, 2022
1 parent ef24eb0 commit d296035
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 239 deletions.
5 changes: 5 additions & 0 deletions .werft/jobs/build/installer/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class Installer {
this.configureAuthProviders(slice)
this.configureSSHGateway(slice)
this.configurePublicAPIServer(slice)
this.configureUsage(slice)

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

private configureUsage(slice: string) {
exec(`yq w -i ${this.options.installerConfigPath} experimental.webapp.usage.enabled true`, { slice: slice })
}

private includeAnalytics(slice: string): void {
exec(`yq w -i ${this.options.installerConfigPath} analytics.writer segment`, { slice: slice });
exec(`yq w -i ${this.options.installerConfigPath} analytics.segmentKey ${this.options.analytics.token}`, { slice: slice });
Expand Down
30 changes: 0 additions & 30 deletions components/usage-controller/BUILD.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions components/usage-controller/cmd/root.go

This file was deleted.

52 changes: 0 additions & 52 deletions components/usage-controller/cmd/run.go

This file was deleted.

67 changes: 0 additions & 67 deletions components/usage-controller/go.mod

This file was deleted.

23 changes: 0 additions & 23 deletions components/usage-controller/go.sum

This file was deleted.

23 changes: 0 additions & 23 deletions components/usage-controller/leeway.Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions components/usage-controller/main.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
public_api_server "github.com/gitpod-io/gitpod/installer/pkg/components/public-api-server"
"github.com/gitpod-io/gitpod/installer/pkg/components/rabbitmq"
"github.com/gitpod-io/gitpod/installer/pkg/components/server"
"github.com/gitpod-io/gitpod/installer/pkg/components/usage"
wsmanagerbridge "github.com/gitpod-io/gitpod/installer/pkg/components/ws-manager-bridge"
)

Expand All @@ -33,6 +34,7 @@ var Objects = common.CompositeRenderFunc(
server.Objects,
wsmanagerbridge.Objects,
public_api_server.Objects,
usage.Objects,
)

var Helm = common.CompositeHelmFunc(
Expand Down
9 changes: 9 additions & 0 deletions install/installer/pkg/components/usage/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package usage

const (
Component = "usage"
)
102 changes: 102 additions & 0 deletions install/installer/pkg/components/usage/deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the MIT License. See License-MIT.txt in the project root for license information.

package usage

import (
"fmt"

"github.com/gitpod-io/gitpod/common-go/baseserver"
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
"github.com/gitpod-io/gitpod/installer/pkg/common"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
)

func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
labels := common.DefaultLabels(Component)
return []runtime.Object{
&appsv1.Deployment{
TypeMeta: common.TypeMetaDeployment,
ObjectMeta: metav1.ObjectMeta{
Name: Component,
Namespace: ctx.Namespace,
Labels: labels,
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
Replicas: common.Replicas(ctx, Component),
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType,
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: Component,
Namespace: ctx.Namespace,
Labels: labels,
},
Spec: corev1.PodSpec{
Affinity: common.NodeAffinity(cluster.AffinityLabelMeta),
ServiceAccountName: Component,
EnableServiceLinks: pointer.Bool(false),
DNSPolicy: "ClusterFirst",
RestartPolicy: "Always",
TerminationGracePeriodSeconds: pointer.Int64(30),
Containers: []corev1.Container{{
Name: Component,
Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Usage.Version),
Args: []string{
"run",
},
ImagePullPolicy: corev1.PullIfNotPresent,
Resources: common.ResourceRequirements(ctx, Component, Component, corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("64Mi"),
},
}),
Ports: []corev1.ContainerPort{},
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(false),
},
Env: common.MergeEnv(
common.DefaultEnv(&ctx.Config),
),
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/live",
Port: intstr.IntOrString{IntVal: baseserver.BuiltinHealthPort},
Scheme: corev1.URISchemeHTTP,
},
},
FailureThreshold: 3,
SuccessThreshold: 1,
TimeoutSeconds: 1,
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/ready",
Port: intstr.IntOrString{IntVal: baseserver.BuiltinHealthPort},
Scheme: corev1.URISchemeHTTP,
},
},
FailureThreshold: 3,
SuccessThreshold: 1,
TimeoutSeconds: 1,
},
},
*common.KubeRBACProxyContainerWithConfig(ctx, 9500, fmt.Sprintf("http://127.0.0.1:%d/", baseserver.BuiltinMetricsPort)),
},
},
},
},
},
}, nil
}
Loading

0 comments on commit d296035

Please sign in to comment.