Skip to content

Commit

Permalink
feat(gce): Add GCP internal http(s) load balancer. (#8397)
Browse files Browse the repository at this point in the history
* fix(provider/google): add internal http(s) load balancer. (#5042)

* fix(provider/gce): Fix Internal HTTP LB implementations.

* fix(provider/gce): convert Internal HTTP LB impl to ts

* chore(gce): refactor internal http lb

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
takaaki7 and mergify[bot] committed Aug 7, 2020
1 parent 972e85d commit 3f279bc
Show file tree
Hide file tree
Showing 23 changed files with 404 additions and 63 deletions.
2 changes: 2 additions & 0 deletions app/scripts/modules/google/src/domain/loadBalancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ILoadBalancer } from '@spinnaker/core';
import { IGceBackendService } from './backendService';

export interface IGceLoadBalancer extends ILoadBalancer {
name: string;
account: string;
credentials: string;
detail: string;
Expand All @@ -24,6 +25,7 @@ export interface IGceHttpLoadBalancer extends IGceLoadBalancer {
region: 'global';
stack: string;
urlMapName: string;
subnet?: string;
}

export interface IGceHostRule {
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/google/src/gce.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { GOOGLE_LOADBALANCER_LOADBALANCER_TRANSFORMER } from './loadBalancer/loa
import { GOOGLE_LOADBALANCER_DETAILS_LOADBALANCERDETAIL_CONTROLLER } from './loadBalancer/details/loadBalancerDetail.controller';
import { GOOGLE_LOADBALANCER_CONFIGURE_NETWORK_CREATELOADBALANCER_CONTROLLER } from './loadBalancer/configure/network/createLoadBalancer.controller';
import { GOOGLE_LOADBALANCER_CONFIGURE_HTTP_CREATEHTTPLOADBALANCER_CONTROLLER } from './loadBalancer/configure/http/createHttpLoadBalancer.controller';
import { GOOGLE_LOADBALANCER_CONFIGURE_INTERNAL_HTTP_CREATEHTTPLOADBALANCER_CONTROLLER } from './loadBalancer/configure/internalhttp/createInternalHttpLoadBalancer.controller';
import { GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER } from './instance/details/instance.details.controller';
import { GOOGLE_SECURITYGROUP_DETAILS_SECURITYGROUPDETAIL_CONTROLLER } from './securityGroup/details/securityGroupDetail.controller';
import { GOOGLE_SECURITYGROUP_CONFIGURE_CREATESECURITYGROUP_CONTROLLER } from './securityGroup/configure/createSecurityGroup.controller';
Expand Down Expand Up @@ -89,6 +90,7 @@ module(GOOGLE_MODULE, [
GOOGLE_LOADBALANCER_DETAILS_LOADBALANCERDETAIL_CONTROLLER,
GOOGLE_LOADBALANCER_CONFIGURE_NETWORK_CREATELOADBALANCER_CONTROLLER,
GOOGLE_LOADBALANCER_CONFIGURE_HTTP_CREATEHTTPLOADBALANCER_CONTROLLER,
GOOGLE_LOADBALANCER_CONFIGURE_INTERNAL_HTTP_CREATEHTTPLOADBALANCER_CONTROLLER,
GOOGLE_INSTANCE_DETAILS_INSTANCE_DETAILS_CONTROLLER,
GOOGLE_SECURITYGROUP_DETAILS_SECURITYGROUPDETAIL_CONTROLLER,
GOOGLE_SECURITYGROUP_CONFIGURE_CREATESECURITYGROUP_CONTROLLER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module(GOOGLE_GCENETWORKSELECTFIELD_DIRECTIVE, []).directive('gceNetworkSelectFi
component: '=',
field: '@',
account: '=',
helpKey: '@',
onChange: '&',
labelColumns: '@',
fieldColumns: '@',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface IHealthCheckSearchResults {
name: string;
account: string;
healthCheck: string; // JSON encoded string containing the real health check (it is missing the account).
region?: string;
kind: string;
provider: string;
type: string;
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/google/src/help/gce.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const helpContents: { [key: string]: string } = {
'gce.instanceType.32core':
'<p>32-core machine types are in Beta and are available only in Ivy Bridge and Haswell zones.</p>',
'gce.internalLoadBalancer.ports': 'Use a comma to separate up to five TCP ports.',
'gce.internalHttpLoadBalancer.network':
"Network must have a subnet whose 'purpose' is 'INTERNAL_HTTPS_LOAD_BALANCER'",
'gce.loadBalancer.connectionDraining':
'(Optional) If set, enables connection draining for this backend service. This field defines the number of seconds to wait before instances that belong to this backend service are terminated in order to drain in-flight connections.',
'gce.loadBalancer.detail':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const loadBalancerTypeToWizardMap: IGceLoadBalancerToWizardMap = {
editTemplateUrl: require('../http/editHttpLoadBalancer.html'),
controller: 'gceCreateHttpLoadBalancerCtrl',
},
INTERNAL_MANAGED: {
label: 'Internal HTTP(S)',
createTemplateUrl: require('../http/createHttpLoadBalancer.html'),
editTemplateUrl: require('../http/editHttpLoadBalancer.html'),
controller: 'gceCreateInternalHttpLoadBalancerCtrl',
},
INTERNAL: {
label: 'Internal',
createTemplateUrl: require('../common/commonCreateLoadBalancer.html'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const sessionAffinityViewToModelMap: IStringMap = {
'Generated Cookie': 'GENERATED_COOKIE',
'Client IP and protocol': 'CLIENT_IP_PROTO',
'Client IP, port and protocol': 'CLIENT_IP_PORT_PROTO',
'Header Field': 'HEADER_FIELD',
'HTTP Cookie': 'HTTP_COOKIE',
};

export const sessionAffinityModelToViewMap = _.invert<IStringMap, IStringMap>(sessionAffinityViewToModelMap);
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@
<ui-select-match placeholder="Select...">
{{ $select.selected }}
</ui-select-match>
<ui-select-choices
repeat="sessionAffinity in ['None', 'Client IP', 'Generated Cookie'] | filter: $select.search"
>
<ui-select-choices repeat="sessionAffinity in $ctrl.getSessionAffinitySuggestions() | filter: $select.search">
<div ng-bind-html="sessionAffinity | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
Expand Down Expand Up @@ -130,7 +128,7 @@
</div>
</div>

<div class="form-group">
<div ng-if="$ctrl.loadBalancer.loadBalancerType === 'HTTP'" class="form-group">
<div class="col-md-4 sm-label-right">
<b>Enable CDN</b>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ module(GOOGLE_LOADBALANCER_CONFIGURE_HTTP_BACKENDSERVICE_BACKENDSERVICE_COMPONEN
.value();
};

this.getSessionAffinitySuggestions = () => {
if (this.loadBalancer.loadBalancerType === 'HTTP') {
return ['None', 'Client IP', 'Generated Cookie'];
} else {
return ['None', 'Client IP', 'Generated Cookie', 'Header Field', 'HTTP Cookie'];
}
};

this.getAllServiceNames = () => {
return this.command.backingData.backendServices
.filter(service => service.account === this.loadBalancer.credentials)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,27 @@
</account-select-field>
</div>
</div>
<div class="form-group">
<div class="col-md-2 sm-label-right">Region</div>
<div class="col-md-3">
<input readonly class="form-control input-sm" ng-model="$ctrl.loadBalancer.region" />
</div>
</div>
<gce-region-select-field
ng-if="$ctrl.loadBalancer.loadBalancerType === 'INTERNAL_MANAGED'"
label-columns="2"
field-columns="8"
component="$ctrl.loadBalancer"
field="region"
account="$ctrl.loadBalancer.credentials"
on-change="$ctrl.command.onRegionSelected($ctrl.command)"
regions="$ctrl.command.backingData.regions"
></gce-region-select-field>
<gce-network-select-field
ng-if="$ctrl.loadBalancer.loadBalancerType === 'INTERNAL_MANAGED'"
label-columns="2"
field-columns="8"
component="$ctrl.loadBalancer"
field="network"
helpKey="gce.internalHttpLoadBalancer.network"
account="$ctrl.loadBalancer.credentials"
networks="$ctrl.command.backingData.internalHttpLbNetworks"
></gce-network-select-field>

<div class="form-group">
<div class="col-md-2 sm-label-right">Stack <help-field key="aws.loadBalancer.stack"></help-field></div>
<div class="col-md-3">
Expand Down
Loading

0 comments on commit 3f279bc

Please sign in to comment.