Skip to content

Commit f4c8cf3

Browse files
committed
[installer] support service type in experimental config
1 parent c36ca91 commit f4c8cf3

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

install/installer/pkg/components/proxy/service.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package proxy
66

77
import (
88
"fmt"
9+
"strings"
910

1011
"github.com/gitpod-io/gitpod/installer/pkg/common"
1112
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
@@ -15,6 +16,19 @@ import (
1516
)
1617

1718
func service(ctx *common.RenderContext) ([]runtime.Object, error) {
19+
serviceType := corev1.ServiceTypeLoadBalancer
20+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
21+
if cfg.Common != nil && cfg.Common.ServiceConfig != nil {
22+
st, ok := cfg.Common.ServiceConfig["proxy"]
23+
if ok {
24+
if strings.ToLower(st.ServiceType) == "clusterip" {
25+
serviceType = corev1.ServiceTypeClusterIP
26+
}
27+
}
28+
}
29+
return nil
30+
})
31+
1832
loadBalancerIP := ""
1933
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
2034
if cfg.WebApp != nil && cfg.WebApp.ProxyConfig != nil && cfg.WebApp.ProxyConfig.StaticIP != "" {
@@ -57,8 +71,10 @@ func service(ctx *common.RenderContext) ([]runtime.Object, error) {
5771
}
5872

5973
return common.GenerateService(Component, ports, func(service *corev1.Service) {
60-
service.Spec.Type = corev1.ServiceTypeLoadBalancer
61-
service.Spec.LoadBalancerIP = loadBalancerIP
74+
service.Spec.Type = serviceType
75+
if serviceType == corev1.ServiceTypeLoadBalancer {
76+
service.Spec.LoadBalancerIP = loadBalancerIP
77+
}
6278

6379
service.Annotations["external-dns.alpha.kubernetes.io/hostname"] = fmt.Sprintf("%s,*.%s,*.ws.%s", ctx.Config.Domain, ctx.Config.Domain, ctx.Config.Domain)
6480
service.Annotations["cloud.google.com/neg"] = `{"exposed_ports": {"80":{},"443": {}}}`

install/installer/pkg/config/v1/experimental/experimental.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ type Config struct {
2424
}
2525

2626
type CommonConfig struct {
27-
PodConfig map[string]*PodConfig `json:"podConfig,omitempty"`
28-
StaticMessagebusPassword string `json:"staticMessagebusPassword"`
27+
PodConfig map[string]*PodConfig `json:"podConfig,omitempty"`
28+
ServiceConfig map[string]*ServiceConfig `json:"serviceConfig,omitempty"`
29+
StaticMessagebusPassword string `json:"staticMessagebusPassword"`
30+
}
31+
32+
// ServiceConfig enables modification of type of service to `ClusterIP` if needed,
33+
// currently supported only for `proxy` service
34+
type ServiceConfig struct {
35+
ServiceType string `json:"serviceType,omitempty"`
2936
}
3037

3138
type PodConfig struct {

0 commit comments

Comments
 (0)