Skip to content

Commit e2b544f

Browse files
committed
[usage] Add server address to config
1 parent 2401a18 commit e2b544f

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

components/usage/pkg/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ type Config struct {
4343

4444
// StripePrices configure which Stripe Price IDs should be used
4545
StripePrices stripe.StripePrices `json:"stripePrices"`
46+
47+
// Where to find the gRPC/Connect APIs on the server component
48+
ServerAddress string `json:"serverAddress"`
4649
}
4750

4851
func Start(cfg Config, version string) error {

install/installer/pkg/common/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const (
4040
ServerComponent = "server"
4141
ServerIAMSessionPort = 9876
4242
ServerInstallationAdminPort = 9000
43+
ServerGRPCAPIPort = 9877
4344
SystemNodeCritical = "system-node-critical"
4445
PaymentEndpointComponent = "payment-endpoint"
4546
PublicApiComponent = "public-api-server"

install/installer/pkg/common/net.go

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

77
import (
88
"fmt"
9+
"net"
10+
"strconv"
911

1012
"github.com/gitpod-io/gitpod/common-go/baseserver"
1113
)
@@ -25,3 +27,11 @@ func LocalhostPrometheusAddr() string {
2527
func LocalhostPprofAddr() string {
2628
return LocalhostAddressFromPort(baseserver.BuiltinDebugPort)
2729
}
30+
31+
func ClusterAddress(serviceName string, namespace string, port int) string {
32+
return net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, namespace), strconv.Itoa(port))
33+
}
34+
35+
func ClusterURL(protocol string, serviceName string, namespace string, port int) string {
36+
return fmt.Sprintf("%s://%s", protocol, ClusterAddress(serviceName, namespace, port))
37+
}

install/installer/pkg/components/public-api-server/configmap.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ package public_api_server
66

77
import (
88
"fmt"
9-
"net"
10-
"strconv"
119

1210
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
1311
"k8s.io/utils/pointer"
@@ -52,15 +50,15 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
5250

5351
cfg := config.Configuration{
5452
PublicURL: fmt.Sprintf("https://api.%s", ctx.Config.Domain),
55-
GitpodServiceURL: fmt.Sprintf("ws://%s.%s.svc.cluster.local:%d", server.Component, ctx.Namespace, server.ContainerPort),
53+
GitpodServiceURL: common.ClusterURL("ws", server.Component, ctx.Namespace, server.ContainerPort),
5654
OIDCClientJWTSigningSecretPath: oidcClientJWTSigningSecretPath,
5755
StripeWebhookSigningSecretPath: stripeSecretPath,
5856
PersonalAccessTokenSigningKeyPath: personalAccessTokenSigningKeyPath,
59-
BillingServiceAddress: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", usage.Component, ctx.Namespace), strconv.Itoa(usage.GRPCServicePort)),
60-
SessionServiceAddress: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", common.ServerComponent, ctx.Namespace), strconv.Itoa(common.ServerIAMSessionPort)),
57+
BillingServiceAddress: common.ClusterAddress(usage.Component, ctx.Namespace, usage.GRPCServicePort),
58+
SessionServiceAddress: common.ClusterAddress(common.ServerComponent, ctx.Namespace, common.ServerIAMSessionPort),
6159
DatabaseConfigPath: databaseSecretMountPath,
6260
Redis: config.RedisConfiguration{
63-
Address: fmt.Sprintf("%s:%d", redis.Component, redis.Port),
61+
Address: common.ClusterAddress(redis.Component, ctx.Namespace, redis.Port),
6462
},
6563
Server: &baseserver.Configuration{
6664
Services: baseserver.ServicesConfiguration{

install/installer/pkg/components/server/configmap.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ package server
66

77
import (
88
"fmt"
9-
"net"
109
"path/filepath"
11-
"strconv"
1210
"strings"
1311

1412
"github.com/gitpod-io/gitpod/installer/pkg/common"
@@ -273,9 +271,9 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
273271
"shareSnapshot": {Group: "inWorkspaceUserAction"},
274272
},
275273
},
276-
ContentServiceAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", contentservice.Component, ctx.Namespace), strconv.Itoa(contentservice.RPCPort)),
277-
UsageServiceAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", usage.Component, ctx.Namespace), strconv.Itoa(usage.GRPCServicePort)),
278-
IDEServiceAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", ideservice.Component, ctx.Namespace), strconv.Itoa(ideservice.GRPCServicePort)),
274+
ContentServiceAddr: common.ClusterAddress(contentservice.Component, ctx.Namespace, contentservice.RPCPort),
275+
UsageServiceAddr: common.ClusterAddress(usage.Component, ctx.Namespace, usage.GRPCServicePort),
276+
IDEServiceAddr: common.ClusterAddress(ideservice.Component, ctx.Namespace, ideservice.GRPCServicePort),
279277
MaximumEventLoopLag: 0.35,
280278
CodeSync: CodeSync{},
281279
VSXRegistryUrl: fmt.Sprintf("https://open-vsx.%s", ctx.Config.Domain), // todo(sje): or "https://{{ .Values.vsxRegistry.host | default "open-vsx.org" }}" if not using OpenVSX proxy

install/installer/pkg/components/server/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ const (
3131
AdminCredentialsSecretKey = "admin.json"
3232

3333
GRPCAPIName = "grpc"
34-
GRPCAPIPort = 9877
34+
GRPCAPIPort = common.ServerGRPCAPIPort
3535
)

install/installer/pkg/components/usage/configmap.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
3737
ForUsers: 1_000_000_000,
3838
MinForUsersOnStripe: 0,
3939
},
40+
ServerAddress: common.ClusterAddress(common.ServerComponent, ctx.Namespace, common.ServerGRPCAPIPort),
4041
}
4142

4243
expWebAppConfig := common.ExperimentalWebappConfig(ctx)

0 commit comments

Comments
 (0)