Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
52f3203
Added support for Zevenet loadbalancer
fkollmann Feb 15, 2018
f3f024e
Completed support for Zevenet loadbalancer
fkollmann Feb 16, 2018
a8e8f54
Added zevenet-lb-go to vendors packages
fkollmann Feb 16, 2018
78b0bad
Added support for including labels in LB config
fkollmann Feb 22, 2018
63dd853
Added support for redirect urls to zevenet
fkollmann Feb 22, 2018
a8d4a5c
Added temp files to dockerignore
fkollmann Feb 22, 2018
b94e084
Fixed build error in AVI provider
fkollmann Feb 22, 2018
0af4ecf
Added build artifacts to git ignore file
fkollmann Feb 22, 2018
58b813e
Fixed labels were not copied correctly
fkollmann Feb 22, 2018
bff31c0
Fixed trimming of label keys
fkollmann Feb 22, 2018
003d2f7
Improved debug output for Zevenet lb
fkollmann Mar 7, 2018
180d563
Fixed label prefixes
fkollmann Mar 7, 2018
a8b6ae8
Fixed redirect type was missing for Zevenet lb
fkollmann Mar 7, 2018
e1b2204
Fixed redirect type ('append' seems to break farm config)
fkollmann Mar 7, 2018
cc247cb
Added documentation for Zevenet lb provider
fkollmann Mar 7, 2018
824e286
Added multi-farm support to Zevenet lb
fkollmann Mar 7, 2018
40217a2
Added support for Zevenet farm guardian
fkollmann Mar 9, 2018
1ff0014
Added support for URL patterns
fkollmann Mar 20, 2018
722c8ce
Added support for uppercase farm names
fkollmann Mar 20, 2018
a1b5ed3
Added support for backend encryption
fkollmann Mar 21, 2018
89a8660
Fixed non-ssl http_check was used for encrypted backends
fkollmann Mar 21, 2018
09067c8
Fixed http_check syntax for SSL
fkollmann Mar 21, 2018
31bd2e4
Added support for deleting all services independent from env UUID
fkollmann Apr 10, 2018
0e55706
Fixed service name matching
fkollmann Apr 10, 2018
35b8562
Fixed service name splitting
fkollmann Apr 10, 2018
380e32b
Excluded unit test from dapper/docker build
fkollmann Apr 10, 2018
8071b1d
Added config cache to reduce Zevenet LB farm restarts
fkollmann Apr 18, 2018
446c2ac
Fixed config cache was not initialized
fkollmann Apr 18, 2018
1538532
Fixed config hash was unstable
fkollmann Apr 18, 2018
4d554db
Ensure config hash labels is always initialized
fkollmann Apr 18, 2018
6c4cd14
Added support for specifying LB provider on service
fkollmann Apr 18, 2018
fc1156b
Updated docs
fkollmann Apr 18, 2018
00c3425
Added Gravitee Management API library to vendors
fkollmann Apr 18, 2018
c591f2f
Added support for Gravitee Management API
fkollmann Apr 18, 2018
67c07ff
Added gabs JSON parsing library to vendors
fkollmann Apr 18, 2018
fc4f1f1
Added missing Gravitee metadata handling
fkollmann Apr 18, 2018
3773c5b
Fixed discovery of Gravitee APIs
fkollmann Apr 18, 2018
90b3005
Improved removing of configuration from Gravitee LB
fkollmann Apr 19, 2018
631a48f
Fixed typo
fkollmann Apr 19, 2018
162761a
Added support for more endpoint options
fkollmann Apr 19, 2018
fbab692
Fixed hostname was not matching full string
fkollmann Apr 19, 2018
f58231f
Fixed hostname was not matching full string
fkollmann Apr 19, 2018
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
./.dapper
./dist
./.trash-cache
./Dockerfile.dapper*
./external-lb.exe
./providers/zevenet/zevenet_test.go
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ external-lb
/dist
*.swp
/.trash-cache
/Dockerfile.dapper*
/external-lb.exe
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
_ "github.com/rancher/external-lb/providers/avi"
_ "github.com/rancher/external-lb/providers/elbv1"
_ "github.com/rancher/external-lb/providers/f5"
_ "github.com/rancher/external-lb/providers/gravitee"
_ "github.com/rancher/external-lb/providers/zevenet"
)

const (
Expand Down Expand Up @@ -119,6 +121,19 @@ func main() {
continue
}

// filter regarding provider
if true {
metadataLBConfigsFiltered := make(map[string]model.LBConfig)

for k, v := range metadataLBConfigs {
if pn, ok := v.LBLabels["provider"]; !ok || strings.EqualFold(pn, *providerName) {
metadataLBConfigsFiltered[k] = v
}
}

metadataLBConfigs = metadataLBConfigsFiltered
}

logrus.Debugf("LB configs from metadata: %v", metadataLBConfigs)

// A flapping service might cause the metadata version to change
Expand Down
18 changes: 16 additions & 2 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package metadata

import (
"fmt"
"strings"
"time"

"github.com/Sirupsen/logrus"
"github.com/rancher/external-lb/model"
"github.com/rancher/go-rancher-metadata/metadata"
"strings"
"time"
)

const (
metadataURLTemplate = "http://%v/2015-12-19"
serviceLabelsPrefix = "io.rancher.service.external_lb."
serviceLabelEndpoint = "io.rancher.service.external_lb.endpoint"
serviceLabelEndpointLegacy = "io.rancher.service.external_lb_endpoint"

Expand Down Expand Up @@ -109,7 +111,19 @@ func (m *MetadataClient) GetMetadataLBConfigs(targetPoolSuffix string) (map[stri
continue
}

// copy labels
labels := make(map[string]string)

for key, value := range service.Labels {
if strings.HasPrefix(key, serviceLabelsPrefix) {
newKey := key[len(serviceLabelsPrefix):]

labels[newKey] = value
}
}

lbConfig := model.LBConfig{}
lbConfig.LBLabels = labels
lbConfig.LBEndpoint = endpoint
lbConfig.LBTargetPort = portspec[0]
lbConfig.LBTargetPoolName = fmt.Sprintf("%s_%s_%s_%s", service.Name, service.StackName,
Expand Down
3 changes: 3 additions & 0 deletions model/lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ type LBConfig struct {
LBTargetPoolName string
LBTargetPort string
LBTargets []LBTarget

// LBLabels contains all Rancher labels starting with "io.rancher.service.external_lb"
LBLabels map[string]string
}

type LBTarget struct {
Expand Down
7 changes: 6 additions & 1 deletion providers/avi/aviutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ func formLBConfig(vs map[string]interface{},

vsName := vs["name"].(string)
poolName := pool["name"].(string)
return model.LBConfig{vsName, poolName, defaultPort, lbTargets}
return model.LBConfig{
LBEndpoint: vsName,
LBTargetPoolName: poolName,
LBTargetPort: defaultPort,
LBTargets: lbTargets,
}
}

func GetVsFqdn(vs map[string]interface{}) (string, error) {
Expand Down
30 changes: 30 additions & 0 deletions providers/gravitee/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Gravitee Management API Provider

## Labels (on Rancher services)

The following labels are supported on backend container, which host the services to be added to the Gravitee API.

| Label Name | Description | Example | Optional |
|-----------|------|-------|-------|
| io.rancher.service.external_lb.endpoint | Gravitee API label to look for. | my-fancy-api | No
| io.rancher.service.external_lb.provider | Has to be set to 'gravitee' to be handled by LB provider. Ignored if not set. | gravitee | Yes
| io.rancher.service.external_lb.encrypt | The backend service port is an HTTPS endpoint and re-encryption is required. Default is false. | true | Yes
| io.rancher.service.external_lb.keep_alive | Requests to the backend service will use HTTP keep alive. Default is true. | false | Yes
| io.rancher.service.external_lb.pipelining | Requests to the backend service will be written to connections without waiting for previous responses to return. Default is false. | true | Yes
| io.rancher.service.external_lb.compress | Enables gzip compression support, and will be able to handle compressed response bodies. Default is true. | false | Yes
| io.rancher.service.external_lb.follow_redirects | Follows redirects returned by the backend service. Default is false. | true | Yes
| io.rancher.service.external_lb.conn_timeout | Time in milliseconds to wait for the backend service to accept the connection. Default is 5000. | 10000 | Yes
| io.rancher.service.external_lb.read_timeout | Time in milliseconds to wait for the backend service to start sending the response. Default is 10000. | 60000 | Yes
| io.rancher.service.external_lb.idle_timeout | Time in milliseconds to wait for an idle connection to be closed. Default is 60000. | 60000 | Yes
| io.rancher.service.external_lb.max_conn | Maximum amount of concurrent connections to a single backend service. Default is 100. | 5000 | Yes

Important: The `io.rancher.service.external_lb.endpoint` has to exist to trigger the load-balancer integration.

## Environment Variables

| Variable Name | Description | Default Value | Optional |
|-----------|------|-------|------|
| GRAVITEE_HOST | The hostname of the Gravitee Management API, like *api.mygravitee.net* or *http://my-gravitee:8080* | | No |
| GRAVITEE_USER | The name of the user to user for Management API access. | | No |
| GRAVITEE_PWD | The password of the user to user for Management API access. | | No |
| LB_TARGET_RANCHER_SUFFIX | Service names in the farm will have this suffix. Choose something simple, like "rancher". | "rancher.internal" | Yes |
Loading