Skip to content

Support private load balancers on GCP #1786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/clusters/gcp/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ max_instances: 5

# the name of the subnetwork in which to create your cluster
# subnet: default

# API load balancer scheme [internet-facing | internal]
api_load_balancer_scheme: internet-facing

# operator load balancer scheme [internet-facing | internal]
# note: if using "internal", you must be within the cluster's VPC or configure VPC Peering to connect your CLI to your cluster operator
operator_load_balancer_scheme: internet-facing
```

The docker images used by the Cortex cluster can also be overridden, although this is not common. They can be configured by adding any of these keys to your cluster configuration file (default values are shown):
Expand Down
12 changes: 7 additions & 5 deletions manager/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,14 @@ function validate_cortex_gcp() {
api_load_balancer_endpoint=$(kubectl -n=istio-system get service ingressgateway-apis -o json | tr -d '[:space:]' | sed 's/.*{\"ip\":\"\(.*\)\".*/\1/')
fi

operator_endpoint_reachable="false" # don't cache this result
if ! curl --max-time 3 "${operator_endpoint}/verifycortex" >/dev/null 2>&1; then
success_cycles=0
continue
if [ "$CORTEX_OPERATOR_LOAD_BALANCER_SCHEME" == "internet-facing" ]; then
operator_endpoint_reachable="false" # don't cache this result
if ! curl --max-time 3 "${operator_endpoint}/verifycortex" >/dev/null 2>&1; then
success_cycles=0
continue
fi
operator_endpoint_reachable="true"
fi
operator_endpoint_reachable="true"

if [[ $success_cycles -lt 1 ]]; then
((success_cycles++))
Expand Down
6 changes: 6 additions & 0 deletions manager/manifests/istio.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ spec:
{% if config.get('operator_load_balancer_scheme') == 'internal' %}
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
{% endif %}
{% elif env['CORTEX_PROVIDER'] == "gcp" and config.get('operator_load_balancer_scheme') == 'internal' %}
serviceAnnotations:
cloud.google.com/load-balancer-type: "Internal"
{% endif %}
service:
type: LoadBalancer
Expand Down Expand Up @@ -106,6 +109,9 @@ spec:
{% if config.get('ssl_certificate_arn', '') != '' %}
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "{{ config['ssl_certificate_arn'] }}"
{% endif %}
{% elif env['CORTEX_PROVIDER'] == "gcp" and config.get('api_load_balancer_scheme') == 'internal' %}
serviceAnnotations:
cloud.google.com/load-balancer-type: "Internal"
{% endif %}
service:
type: LoadBalancer
Expand Down
62 changes: 44 additions & 18 deletions pkg/types/clusterconfig/cluster_config_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,26 @@ import (
)

type GCPConfig struct {
Provider types.ProviderType `json:"provider" yaml:"provider"`
Project *string `json:"project" yaml:"project"`
Zone *string `json:"zone" yaml:"zone"`
InstanceType *string `json:"instance_type" yaml:"instance_type"`
AcceleratorType *string `json:"accelerator_type" yaml:"accelerator_type"`
Network *string `json:"network" yaml:"network"`
Subnet *string `json:"subnet" yaml:"subnet"`
MinInstances *int64 `json:"min_instances" yaml:"min_instances"`
MaxInstances *int64 `json:"max_instances" yaml:"max_instances"`
ClusterName string `json:"cluster_name" yaml:"cluster_name"`
Telemetry bool `json:"telemetry" yaml:"telemetry"`
ImageOperator string `json:"image_operator" yaml:"image_operator"`
ImageManager string `json:"image_manager" yaml:"image_manager"`
ImageDownloader string `json:"image_downloader" yaml:"image_downloader"`
ImageFluentBit string `json:"image_fluent_bit" yaml:"image_fluent_bit"`
ImageIstioProxy string `json:"image_istio_proxy" yaml:"image_istio_proxy"`
ImageIstioPilot string `json:"image_istio_pilot" yaml:"image_istio_pilot"`
ImageGooglePause string `json:"image_google_pause" yaml:"image_google_pause"`
Provider types.ProviderType `json:"provider" yaml:"provider"`
Project *string `json:"project" yaml:"project"`
Zone *string `json:"zone" yaml:"zone"`
InstanceType *string `json:"instance_type" yaml:"instance_type"`
AcceleratorType *string `json:"accelerator_type" yaml:"accelerator_type"`
Network *string `json:"network" yaml:"network"`
Subnet *string `json:"subnet" yaml:"subnet"`
APILoadBalancerScheme LoadBalancerScheme `json:"api_load_balancer_scheme" yaml:"api_load_balancer_scheme"`
OperatorLoadBalancerScheme LoadBalancerScheme `json:"operator_load_balancer_scheme" yaml:"operator_load_balancer_scheme"`
MinInstances *int64 `json:"min_instances" yaml:"min_instances"`
MaxInstances *int64 `json:"max_instances" yaml:"max_instances"`
ClusterName string `json:"cluster_name" yaml:"cluster_name"`
Telemetry bool `json:"telemetry" yaml:"telemetry"`
ImageOperator string `json:"image_operator" yaml:"image_operator"`
ImageManager string `json:"image_manager" yaml:"image_manager"`
ImageDownloader string `json:"image_downloader" yaml:"image_downloader"`
ImageFluentBit string `json:"image_fluent_bit" yaml:"image_fluent_bit"`
ImageIstioProxy string `json:"image_istio_proxy" yaml:"image_istio_proxy"`
ImageIstioPilot string `json:"image_istio_pilot" yaml:"image_istio_pilot"`
ImageGooglePause string `json:"image_google_pause" yaml:"image_google_pause"`
}

type InternalGCPConfig struct {
Expand Down Expand Up @@ -148,6 +150,26 @@ var UserGCPValidation = &cr.StructValidation{
AllowExplicitNull: true,
},
},
{
StructField: "APILoadBalancerScheme",
StringValidation: &cr.StringValidation{
AllowedValues: LoadBalancerSchemeStrings(),
Default: InternetFacingLoadBalancerScheme.String(),
},
Parser: func(str string) (interface{}, error) {
return LoadBalancerSchemeFromString(str), nil
},
},
{
StructField: "OperatorLoadBalancerScheme",
StringValidation: &cr.StringValidation{
AllowedValues: LoadBalancerSchemeStrings(),
Default: InternetFacingLoadBalancerScheme.String(),
},
Parser: func(str string) (interface{}, error) {
return LoadBalancerSchemeFromString(str), nil
},
},
{
StructField: "MinInstances",
Int64PtrValidation: &cr.Int64PtrValidation{
Expand Down Expand Up @@ -501,6 +523,8 @@ func (cc *GCPConfig) UserTable() table.KeyValuePairs {
if cc.Subnet != nil {
items.Add(SubnetUserKey, *cc.Subnet)
}
items.Add(APILoadBalancerSchemeUserKey, cc.APILoadBalancerScheme)
items.Add(OperatorLoadBalancerSchemeUserKey, cc.OperatorLoadBalancerScheme)
items.Add(TelemetryUserKey, cc.Telemetry)
items.Add(ImageOperatorUserKey, cc.ImageOperator)
items.Add(ImageManagerUserKey, cc.ImageManager)
Expand Down Expand Up @@ -536,6 +560,8 @@ func (cc *GCPConfig) TelemetryEvent() map[string]interface{} {
if cc.Subnet != nil {
event["subnet._is_defined"] = true
}
event["api_load_balancer_scheme"] = cc.APILoadBalancerScheme
event["operator_load_balancer_scheme"] = cc.OperatorLoadBalancerScheme
if cc.MinInstances != nil {
event["min_instances._is_defined"] = true
event["min_instances"] = *cc.MinInstances
Expand Down