Skip to content

Commit

Permalink
👋 Route53!
Browse files Browse the repository at this point in the history
  • Loading branch information
bigkraig committed Aug 15, 2017
1 parent 5cb5491 commit 4d9c01c
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 826 deletions.
7 changes: 2 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ func main() {

awsDebug, _ := strconv.ParseBool(os.Getenv("AWS_DEBUG"))

disableRoute53, _ := strconv.ParseBool(os.Getenv("DISABLE_ROUTE53"))

conf := &config.Config{
ClusterName: clusterName,
AWSDebug: awsDebug,
DisableRoute53: disableRoute53,
ClusterName: clusterName,
AWSDebug: awsDebug,
}

if len(clusterName) > 11 {
Expand Down
1 change: 0 additions & 1 deletion pkg/alb/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type LoadBalancer struct {
Hostname *string
CurrentLoadBalancer *elbv2.LoadBalancer // current version of load balancer in AWS
DesiredLoadBalancer *elbv2.LoadBalancer // desired version of load balancer in AWS
ResourceRecordSet *ResourceRecordSet
TargetGroups TargetGroups
Listeners Listeners
CurrentTags util.Tags
Expand Down
10 changes: 0 additions & 10 deletions pkg/alb/loadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ func (l LoadBalancers) Reconcile(rOpts *ReconcileOptions) (LoadBalancers, LoadBa
errLBs = append(errLBs, loadbalancer)
continue
}
if !rOpts.disableRoute53 {
if err := loadbalancer.ResourceRecordSet.Reconcile(rOpts); err != nil {
loadbalancer.LastError = err
errLBs = append(errLBs, loadbalancer)
continue
}
}
if err := loadbalancer.TargetGroups.Reconcile(rOpts); err != nil {
loadbalancer.LastError = err
errLBs = append(errLBs, loadbalancer)
Expand All @@ -60,8 +53,5 @@ func (l LoadBalancers) Reconcile(rOpts *ReconcileOptions) (LoadBalancers, LoadBa
func (l LoadBalancers) StripDesiredState() {
for _, lb := range l {
lb.DesiredLoadBalancer = nil
if lb.ResourceRecordSet != nil {
lb.ResourceRecordSet.DesiredResourceRecordSet = nil
}
}
}
10 changes: 2 additions & 8 deletions pkg/alb/reconcile.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
package alb

type ReconcileOptions struct {
disableRoute53 bool
Eventf func(string, string, string, ...interface{})
loadbalancer *LoadBalancer
Eventf func(string, string, string, ...interface{})
loadbalancer *LoadBalancer
}

func NewReconcileOptions() *ReconcileOptions {
return &ReconcileOptions{}
}

func (r *ReconcileOptions) SetDisableRoute53(b bool) *ReconcileOptions {
r.disableRoute53 = b
return r
}

func (r *ReconcileOptions) SetEventf(f func(string, string, string, ...interface{})) *ReconcileOptions {
r.Eventf = f
return r
Expand Down
239 changes: 0 additions & 239 deletions pkg/alb/resourcerecordset.go

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/alb/resourcerecordsets.go

This file was deleted.

5 changes: 2 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

// Config contains the ALB Ingress Controller configuration
type Config struct {
ClusterName string
AWSDebug bool
DisableRoute53 bool
ClusterName string
AWSDebug bool
}
23 changes: 8 additions & 15 deletions pkg/controller/alb-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import (

// ALBController is our main controller
type ALBController struct {
storeLister ingress.StoreLister
recorder record.EventRecorder
ALBIngresses ALBIngressesT
clusterName *string
IngressClass string
disableRoute53 bool
storeLister ingress.StoreLister
recorder record.EventRecorder
ALBIngresses ALBIngressesT
clusterName *string
IngressClass string
}

var logger *log.Logger
Expand All @@ -42,8 +41,7 @@ func init() {
// NewALBController returns an ALBController
func NewALBController(awsconfig *aws.Config, conf *config.Config) *ALBController {
ac := &ALBController{
clusterName: aws.String(conf.ClusterName),
disableRoute53: conf.DisableRoute53,
clusterName: aws.String(conf.ClusterName),
}

awsutil.AWSDebug = conf.AWSDebug
Expand All @@ -53,10 +51,6 @@ func NewALBController(awsconfig *aws.Config, conf *config.Config) *ALBController
awsutil.ACMsvc = awsutil.NewACM(awsutil.Session)
awsutil.IAMsvc = awsutil.NewIAM(awsutil.Session)

if !conf.DisableRoute53 {
awsutil.Route53svc = awsutil.NewRoute53(awsutil.Session)
}

return ingress.Controller(ac).(*ALBController)
}

Expand Down Expand Up @@ -120,7 +114,7 @@ func (ac *ALBController) OnUpdate(_ ingress.Configuration) error {
for _, ingress := range ac.ALBIngresses {
go func(wg *sync.WaitGroup, ingress *ALBIngress) {
defer wg.Done()
rOpts := alb.NewReconcileOptions().SetDisableRoute53(ac.disableRoute53).SetEventf(ingress.Eventf)
rOpts := alb.NewReconcileOptions().SetEventf(ingress.Eventf)
ingress.Reconcile(rOpts)
}(&wg, ingress)
}
Expand Down Expand Up @@ -176,7 +170,6 @@ func (ac *ALBController) Info() *ingress.BackendInfo {

// ConfigureFlags
func (ac *ALBController) ConfigureFlags(pf *pflag.FlagSet) {
pf.BoolVar(&ac.disableRoute53, "disable-route53", ac.disableRoute53, "Disable Route 53 management")
}

func (ac *ALBController) UpdateIngressStatus(ing *extensions.Ingress) []api.LoadBalancerIngress {
Expand Down Expand Up @@ -277,7 +270,7 @@ func (ac *ALBController) AssembleIngresses() {
go func(wg *sync.WaitGroup, loadBalancer *elbv2.LoadBalancer) {
defer wg.Done()

albIngress, ok := NewALBIngressFromLoadBalancer(loadBalancer, *ac.clusterName, ac.disableRoute53)
albIngress, ok := NewALBIngressFromLoadBalancer(loadBalancer, *ac.clusterName)
if !ok {
return
}
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/alb-controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var a *ALBIngress
func setup() {
//setupEC2()
//setupELBV2()
//setupRoute53()

a = &ALBIngress{
id: aws.String("clustername-ingressname"),
Expand Down
Loading

0 comments on commit 4d9c01c

Please sign in to comment.