-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix: Add only healthy containers to the target pool * Fix: Only attempt to update provider configs if the LB config from metadata has changed. This prevents flooding of the provider API when there is a flapping service in the environment that causes the metadata version to change rapidly. * Enhancement: Set Cattle service FQDN to the FQDN of the load balancer (if supported by the provider) * Refactored code
- Loading branch information
janeczku
committed
Sep 23, 2016
1 parent
d7f6048
commit 6fb5064
Showing
10 changed files
with
406 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
external-lb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/rancher/go-rancher/client" | ||
) | ||
|
||
type CattleClient struct { | ||
rancherClient *client.RancherClient | ||
} | ||
|
||
func NewCattleClientFromEnvironment() (*CattleClient, error) { | ||
var cattleURL string | ||
var cattleAccessKey string | ||
var cattleSecretKey string | ||
|
||
if env := os.Getenv("CATTLE_URL"); len(env) > 0 { | ||
cattleURL = env | ||
} else { | ||
return nil, fmt.Errorf("Environment variable 'CATTLE_URL' is not set") | ||
} | ||
|
||
if env := os.Getenv("CATTLE_ACCESS_KEY"); len(env) > 0 { | ||
cattleAccessKey = env | ||
} else { | ||
return nil, fmt.Errorf("Environment variable 'CATTLE_ACCESS_KEY' is not set") | ||
} | ||
|
||
if env := os.Getenv("CATTLE_SECRET_KEY"); len(env) > 0 { | ||
cattleSecretKey = env | ||
} else { | ||
return nil, fmt.Errorf("Environment variable 'CATTLE_SECRET_KEY' is not set") | ||
} | ||
|
||
apiClient, err := client.NewRancherClient(&client.ClientOpts{ | ||
Url: cattleURL, | ||
AccessKey: cattleAccessKey, | ||
SecretKey: cattleSecretKey, | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &CattleClient{ | ||
rancherClient: apiClient, | ||
}, nil | ||
} | ||
|
||
func (c *CattleClient) UpdateServiceFqdn(serviceName, stackName, fqdn string) error { | ||
event := &client.ExternalDnsEvent{ | ||
EventType: "dns.update", | ||
ExternalId: fqdn, | ||
ServiceName: serviceName, | ||
StackName: stackName, | ||
Fqdn: fqdn, | ||
} | ||
_, err := c.rancherClient.ExternalDnsEvent.Create(event) | ||
return err | ||
} | ||
|
||
func (c *CattleClient) TestConnect() error { | ||
opts := &client.ListOpts{} | ||
_, err := c.rancherClient.ExternalDnsEvent.List(opts) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.