diff --git a/installer/README.md b/installer/README.md index 87559aed0e9349..3626c6c406843c 100644 --- a/installer/README.md +++ b/installer/README.md @@ -476,6 +476,21 @@ Kubernetes objects, such as your TLS certificate or connection secrets. kubectl create namespace gitpod ``` +# I need to add additional configuration to my load balancer - what do I do? + +By default, this will create a `proxy` service with `ServiceType: LoadBalancer`. +If you want to specify your own ingress, you can do this easily by changing +your Installer configuration: + +```yaml +components: + proxy: + serviceType: ClusterIP +``` + +This will set the `ServiceType` to `ClusterIP` allowing you to create your own +ingress controller. + # Todo PRs/comments welcome diff --git a/installer/pkg/components/proxy/objects.go b/installer/pkg/components/proxy/objects.go index e1af4422b4ccb9..1dd49da65c90fc 100644 --- a/installer/pkg/components/proxy/objects.go +++ b/installer/pkg/components/proxy/objects.go @@ -32,7 +32,7 @@ var Objects = common.CompositeRenderFunc( ServicePort: PrometheusPort, }, }, func(service *corev1.Service) { - service.Spec.Type = corev1.ServiceTypeLoadBalancer + service.Spec.Type = cfg.Config.Components.Proxy.ServiceType service.Annotations["external-dns.alpha.kubernetes.io/hostname"] = fmt.Sprintf("%s,*.%s,*.ws.%s", cfg.Config.Domain, cfg.Config.Domain, cfg.Config.Domain) service.Annotations["cloud.google.com/neg"] = `{"exposed_ports": {"80":{},"443": {}}}` })(cfg) diff --git a/installer/pkg/config/v1/config.go b/installer/pkg/config/v1/config.go index 575b0696e6dd02..c340e4c5cc9a0c 100644 --- a/installer/pkg/config/v1/config.go +++ b/installer/pkg/config/v1/config.go @@ -26,6 +26,11 @@ func (v version) Factory() interface{} { Enabled: false, Passlist: []string{}, }, + Components: &Components{ + Proxy: &ProxyComponent{ + ServiceType: corev1.ServiceTypeLoadBalancer, + }, + }, } } func (v version) Defaults(in interface{}) error { @@ -79,6 +84,8 @@ type Config struct { ImagePullSecrets []ObjectRef `json:"imagePullSecrets"` + Components *Components `json:"components,omitempty"` + Workspace Workspace `json:"workspace" validate:"required"` AuthProviders []ObjectRef `json:"authProviders" validate:"dive"` @@ -163,7 +170,7 @@ const ( type ContainerRegistry struct { InCluster *bool `json:"inCluster,omitempty" validate:"required"` External *ContainerRegistryExternal `json:"external,omitempty" validate:"required_if=InCluster false"` - S3Storage *S3Storage `json:"s3storage"` + S3Storage *S3Storage `json:"s3storage,omitempty"` } type ContainerRegistryExternal struct { @@ -222,6 +229,14 @@ type Workspace struct { Templates *WorkspaceTemplates `json:"templates,omitempty"` } +type Components struct { + Proxy *ProxyComponent `json:"proxy,omitempty"` +} + +type ProxyComponent struct { + ServiceType corev1.ServiceType `json:"serviceType,omitempty" validate:"k8s_service_type"` +} + type FSShiftMethod string const ( diff --git a/installer/pkg/config/v1/validation.go b/installer/pkg/config/v1/validation.go index 4012f9fea683e6..0629a1ad77bc3b 100644 --- a/installer/pkg/config/v1/validation.go +++ b/installer/pkg/config/v1/validation.go @@ -8,10 +8,9 @@ import ( "fmt" "github.com/gitpod-io/gitpod/installer/pkg/cluster" - "sigs.k8s.io/yaml" - "github.com/go-playground/validator/v10" corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/yaml" ) var InstallationKindList = map[InstallationKind]struct{}{ @@ -39,6 +38,13 @@ var FSShiftMethodList = map[FSShiftMethod]struct{}{ FSShiftShiftFS: {}, } +var KubernetesServiceTypeList = map[corev1.ServiceType]struct{}{ + corev1.ServiceTypeClusterIP: {}, + corev1.ServiceTypeNodePort: {}, + corev1.ServiceTypeLoadBalancer: {}, + corev1.ServiceTypeExternalName: {}, +} + // LoadValidationFuncs load custom validation functions for this version of the config API func (v version) LoadValidationFuncs(validate *validator.Validate) error { funcs := map[string]validator.Func{ @@ -54,6 +60,10 @@ func (v version) LoadValidationFuncs(validate *validator.Validate) error { _, ok := InstallationKindList[InstallationKind(fl.Field().String())] return ok }, + "k8s_service_type": func(fl validator.FieldLevel) bool { + _, ok := KubernetesServiceTypeList[corev1.ServiceType(fl.Field().String())] + return ok + }, "log_level": func(fl validator.FieldLevel) bool { _, ok := LogLevelList[LogLevel(fl.Field().String())] return ok