Skip to content
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

Add CSM NEG support. #827

Merged
merged 4 commits into from
Aug 29, 2019
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
16 changes: 12 additions & 4 deletions cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ package main
import (
"context"
"fmt"
"k8s.io/ingress-gce/pkg/frontendconfig"
"math/rand"
"os"
"time"

flag "github.com/spf13/pflag"
"k8s.io/ingress-gce/pkg/frontendconfig"
"k8s.io/klog"

crdclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
Expand Down Expand Up @@ -78,7 +79,13 @@ func main() {
if err != nil {
klog.Fatalf("Failed to create kubernetes client: %v", err)
}

var dynamicClient dynamic.Interface
if flags.F.EnableCSM {
dynamicClient, err = dynamic.NewForConfig(kubeConfig)
if err != nil {
klog.Fatalf("Failed to create kubernetes dynamic client: %v", err)
}
}
// Due to scaling issues, leader election must be configured with a separate k8s client.
leaderElectKubeClient, err := kubernetes.NewForConfig(restclient.AddUserAgent(kubeConfig, "leader-election"))
if err != nil {
Expand Down Expand Up @@ -132,8 +139,9 @@ func main() {
HealthCheckPath: flags.F.HealthCheckPath,
DefaultBackendHealthCheckPath: flags.F.DefaultSvcHealthCheckPath,
FrontendConfigEnabled: flags.F.EnableFrontendConfig,
EnableCSM: flags.F.EnableCSM,
}
ctx := ingctx.NewControllerContext(kubeClient, backendConfigClient, frontendConfigClient, cloud, namer, ctxConfig)
ctx := ingctx.NewControllerContext(kubeClient, dynamicClient, backendConfigClient, frontendConfigClient, cloud, namer, ctxConfig)
go app.RunHTTPServer(ctx.HealthCheck)

if !flags.F.LeaderElection.LeaderElect {
Expand Down Expand Up @@ -197,7 +205,7 @@ func runControllers(ctx *ingctx.ControllerContext) {
fwc := firewalls.NewFirewallController(ctx, flags.F.NodePortRanges.Values())

// TODO: Refactor NEG to use cloud mocks so ctx.Cloud can be referenced within NewController.
negController := neg.NewController(negtypes.NewAdapter(ctx.Cloud), ctx, lbc.Translator, ctx.ClusterNamer, flags.F.ResyncPeriod, flags.F.NegGCPeriod, neg.NegSyncerType(flags.F.NegSyncerType), flags.F.EnableReadinessReflector)
negController := neg.NewController(negtypes.NewAdapter(ctx.Cloud), ctx, lbc.Translator, ctx.ClusterNamer, flags.F.ResyncPeriod, flags.F.NegGCPeriod, neg.NegSyncerType(flags.F.NegSyncerType), flags.F.EnableReadinessReflector, flags.F.EnableCSM, flags.F.CSMServiceNEGSkipNamespaces)

go negController.Run(stopCh)
klog.V(0).Infof("negController started")
Expand Down
13 changes: 10 additions & 3 deletions docs/deploy/gke/gke-self-managed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function usage() {
echo " the Makefile for defaults and other configuration)"
echo " --help Display this help and exit"
echo " --network-name Override for the network-name gce.conf value"
echo " --enable-csm If set, enable CSM mode which will create NEGs for Istio objects."
echo " --subnetwork-name Override for the subnetwork-name gce.conf value"
echo " --network-tags Override for the node-tags gce.conf value"
echo " --no-confirm Don't ask confirmation to reenable GLBC on cleanup"
Expand Down Expand Up @@ -142,7 +143,7 @@ function cleanup() {
}

# Loops until calls to the API server are succeeding.
function wait-for-api-server() {
function wait_for_api_server() {
echo "Waiting for API server to become ready..."
until run_maybe_dry kubectl api-resources > /dev/null 2>&1; do
sleep 0.1
Expand All @@ -156,6 +157,7 @@ CLEANUP_HELP="Invoking me with the -c option will get you back to a clean slate.
NO_CLEANUP="Nothing has to be cleaned up :)"
PERMISSION_ISSUE="If this looks like a permissions problem, see the README."
CONFIRM=1
ENABLE_CSM=false

# Parsing command line arguments
while [[ $# -gt 0 ]]
Expand Down Expand Up @@ -201,6 +203,10 @@ case $key in
BUILD_AND_PUSH=1
shift
;;
--enable-csm)
ENABLE_CSM=true
shift
;;
--no-confirm)
CONFIRM=0

Expand Down Expand Up @@ -303,7 +309,8 @@ fi

# And format the GLBC YAML with the image URL (either from --image-url or parsed from)
# our Makefile output.
sed "s|\[IMAGE_URL\]|$IMAGE_URL|" ../resources/glbc.yaml > ../resources/glbc.yaml.gen
sed "s|\[IMAGE_URL\]|$IMAGE_URL|" ../resources/glbc.yaml | \
sed -e "s|\[ENABLE_CSM\]|$ENABLE_CSM|" > ../resources/glbc.yaml.gen

# Grant permission to current GCP user to create new k8s ClusterRole's.
run_maybe_dry_kubectl kubectl create clusterrolebinding one-binding-to-rule-them-all --clusterrole=cluster-admin --user=${GCP_USER}
Expand Down Expand Up @@ -352,7 +359,7 @@ run_maybe_dry gcloud container clusters update ${CLUSTER_NAME} ${GCLOUD_EXTRA_FL
[[ $? -eq 0 ]] || error_exit "Error-bot: Issue turning off GLBC. ${PERMISSION_ISSUE} ${CLEANUP_HELP}"

# Critical to wait for the API server to be handling responses before continuing.
wait-for-api-server
wait_for_api_server

# In case the API server isn't actually ready (there's been mention of it succeeding on
# a request only to fail on the next), prompt user so that they can choose when to proceed.
Expand Down
2 changes: 2 additions & 0 deletions docs/deploy/resources/glbc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ spec:
- --gce-ratelimit=ga.BackendServices.Get,qps,1.8,1
- --gce-ratelimit=ga.HealthChecks.Get,qps,1.8,1
- --gce-ratelimit=alpha.HealthChecks.Get,qps,1.8,1
- --enable-csm=[ENABLE_CSM]
- --csm-service-skip-namespaces=kube-system,istio-system
volumes:
- name: google-cloud-key
secret:
Expand Down
3 changes: 3 additions & 0 deletions docs/deploy/resources/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ rules:
- apiGroups: [""]
resources: ["services"]
verbs: ["update", "patch"]
- apiGroups: ["networking.istio.io"]
resources: ["destinationrules"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["extensions", "networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "list", "watch"]
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/evanphx/json-patch v4.1.0+incompatible // indirect
github.com/go-openapi/spec v0.19.0
github.com/go-openapi/swag v0.19.0 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/google/gofuzz v1.0.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
Expand All @@ -31,6 +30,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
istio.io/api v0.0.0-20190809125725-591cf32c1d0e
k8s.io/api v0.0.0
k8s.io/apiextensions-apiserver v0.0.0
k8s.io/apimachinery v0.0.0
Expand All @@ -53,7 +53,7 @@ replace (
github.com/evanphx/json-patch => github.com/evanphx/json-patch v4.1.0+incompatible
github.com/go-openapi/spec => github.com/go-openapi/spec v0.19.0
github.com/go-openapi/swag => github.com/go-openapi/swag v0.19.0
github.com/gogo/protobuf => github.com/gogo/protobuf v1.2.1
github.com/gogo/protobuf => github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48
github.com/golang/groupcache => github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef
github.com/golang/protobuf => github.com/golang/protobuf v1.3.1
github.com/google/gofuzz => github.com/google/gofuzz v1.0.0
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+
github.com/go-ozzo/ozzo-validation v3.5.0+incompatible/go.mod h1:gsEKFIVnabGBt6mXmxK0MoFy+cZoTJY6mu5Ll3LVLBU=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 h1:X+zN6RZXsvnrSJaAIQhZezPfAfvsqihKKR8oiLHid34=
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk=
Expand Down Expand Up @@ -195,6 +199,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/kardianos/osext v0.0.0-20150410034420-8fef92e41e22/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
github.com/karrick/godirwalk v1.7.5/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46shStcFDJ34=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.0.0-20131111012553-2788f0dbd169/go.mod h1:glhvuHOU9Hy7/8PwwdtnarXqLagOX0b/TbZx2zLMqEg=
Expand Down Expand Up @@ -355,6 +360,7 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down Expand Up @@ -390,6 +396,8 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand All @@ -413,6 +421,9 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
istio.io/api v0.0.0-20190809125725-591cf32c1d0e h1:96ps7g+JjoJ0Wh/VzIdfds+ZDt8pFYhX7gHyKX5Tswk=
istio.io/api v0.0.0-20190809125725-591cf32c1d0e/go.mod h1:42cBjnu/rTJcCaKi8nLdIvq0n71RcLrkgZ9IQSvDdSQ=
istio.io/gogo-genproto v0.0.0-20190731221249-06e20ada0df2/go.mod h1:IjvrbUlRbbw4JCpsgvgihcz9USUwEoNTL/uwMtyV5yk=
k8s.io/api v0.0.0-20190418212532-b8e4ab4b136a h1:dQUlNDGA5R4bkG882FlNHw+zSvc8VSgGvHv57DOVyHA=
k8s.io/api v0.0.0-20190418212532-b8e4ab4b136a/go.mod h1:B0cvvXrD9UkqARVdlFhdZB9SNL0TzJ13UB/p410skE4=
k8s.io/api v0.0.0-20190620085002-8f739060a0b3 h1:Cgi5AmittRgKVpjIoEKQf6S4bvQjcDxdfDg16TdrUoY=
Expand Down
42 changes: 42 additions & 0 deletions pkg/annotations/destination_rule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package annotations

import "encoding/json"

//PortSubsetNegMap is the mapping between subset to NEG name.
type PortSubsetNegMap map[string]map[string]string

// DestinationRuleNEGStatus holds the NEGs Zones info.
// NetworkEndpointGroups(PortSubsetNegMap) is the mapping between subset to NEG name.
// Structure:
// {
// "subsetv1": {
// "9080": "somehash-default-reviews-v1-9080",
// }
// "v2": {
// "9080": "somehash-default-reviews-v2-9080",
// }
// }
type DestinationRuleNEGStatus struct {
NetworkEndpointGroups PortSubsetNegMap `json:"network_endpoint_groups,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean move the comment from above to here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Zones is a list of zones where the NEGs exist.
Zones []string `json:"zones,omitempty"`
}

// NewDestinationRuleNegStatus generates a NegStatus denoting the current NEGs
// associated with the given PortSubsetNegMap.
func NewDestinationRuleNegStatus(zones []string, portSubsetToNegs PortSubsetNegMap) DestinationRuleNEGStatus {
res := DestinationRuleNEGStatus{}
res.Zones = zones
res.NetworkEndpointGroups = portSubsetToNegs
return res
}

// Marshal returns the DestinationRuleNEGStatus in json string.
func (ns DestinationRuleNEGStatus) Marshal() (string, error) {
ret := ""
bytes, err := json.Marshal(ns)
if err != nil {
return ret, err
}
return string(bytes), err
}
40 changes: 32 additions & 8 deletions pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"time"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
informerv1 "k8s.io/client-go/informers/core/v1"
informerv1beta1 "k8s.io/client-go/informers/networking/v1beta1"
"k8s.io/client-go/kubernetes"
Expand All @@ -42,21 +45,23 @@ const (

// ControllerContext holds the state needed for the execution of the controller.
type ControllerContext struct {
KubeClient kubernetes.Interface
KubeClient kubernetes.Interface
DestinationRuleClient dynamic.NamespaceableResourceInterface

Cloud *gce.Cloud

ClusterNamer *utils.Namer

ControllerContextConfig

IngressInformer cache.SharedIndexInformer
ServiceInformer cache.SharedIndexInformer
BackendConfigInformer cache.SharedIndexInformer
FrontendConfigInformer cache.SharedIndexInformer
PodInformer cache.SharedIndexInformer
NodeInformer cache.SharedIndexInformer
EndpointInformer cache.SharedIndexInformer
IngressInformer cache.SharedIndexInformer
ServiceInformer cache.SharedIndexInformer
BackendConfigInformer cache.SharedIndexInformer
FrontendConfigInformer cache.SharedIndexInformer
PodInformer cache.SharedIndexInformer
NodeInformer cache.SharedIndexInformer
EndpointInformer cache.SharedIndexInformer
DestinationRuleInformer cache.SharedIndexInformer

healthChecks map[string]func() error

Expand All @@ -75,11 +80,13 @@ type ControllerContextConfig struct {
HealthCheckPath string
DefaultBackendHealthCheckPath string
FrontendConfigEnabled bool
EnableCSM bool
}

// NewControllerContext returns a new shared set of informers.
func NewControllerContext(
kubeClient kubernetes.Interface,
dynamicClient dynamic.Interface,
backendConfigClient backendconfigclient.Interface,
frontendConfigClient frontendconfigclient.Interface,
cloud *gce.Cloud,
Expand All @@ -101,6 +108,16 @@ func NewControllerContext(
healthChecks: make(map[string]func() error),
}

if config.EnableCSM && dynamicClient != nil {
klog.Warning("The DestinationRule group version is v1alpha3 in group networking.istio.io. Need to update as istio API graduates.")
destrinationGVR := schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1alpha3", Resource: "destinationrules"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add a WARNING here.
The destinationRule group version is v1alpha3 in group networking.istio.io. Need to update as istio API graduates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

drDynamicInformer := dynamicinformer.NewFilteredDynamicInformer(dynamicClient, destrinationGVR, config.Namespace, config.ResyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
nil)
context.DestinationRuleInformer = drDynamicInformer.Informer()
context.DestinationRuleClient = dynamicClient.Resource(destrinationGVR)
}

if config.FrontendConfigEnabled {
context.FrontendConfigInformer = informerfrontendconfig.NewFrontendConfigInformer(frontendConfigClient, config.Namespace, config.ResyncPeriod, utils.NewNamespaceIndexer())
}
Expand All @@ -123,6 +140,10 @@ func (ctx *ControllerContext) HasSynced() bool {
funcs = append(funcs, ctx.FrontendConfigInformer.HasSynced)
}

if ctx.DestinationRuleInformer != nil {
funcs = append(funcs, ctx.DestinationRuleInformer.HasSynced)
}

for _, f := range funcs {
if !f() {
return false
Expand Down Expand Up @@ -187,6 +208,9 @@ func (ctx *ControllerContext) Start(stopCh chan struct{}) {
if ctx.FrontendConfigInformer != nil {
go ctx.FrontendConfigInformer.Run(stopCh)
}
if ctx.DestinationRuleInformer != nil {
go ctx.DestinationRuleInformer.Run(stopCh)
}
}

// Ingresses returns the store of Ingresses.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func newLoadBalancerController() *LoadBalancerController {
HealthCheckPath: "/",
DefaultBackendHealthCheckPath: "/healthz",
}
ctx := context.NewControllerContext(kubeClient, backendConfigClient, nil, fakeGCE, namer, ctxConfig)
ctx := context.NewControllerContext(kubeClient, nil, backendConfigClient, nil, fakeGCE, namer, ctxConfig)
lbc := NewLoadBalancerController(ctx, stopCh)
// TODO(rramkumar): Fix this so we don't have to override with our fake
lbc.instancePool = instances.NewNodePool(instances.NewFakeInstanceGroups(sets.NewString(), namer), namer)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func fakeTranslator() *Translator {
HealthCheckPath: "/",
DefaultBackendHealthCheckPath: "/healthz",
}
ctx := context.NewControllerContext(client, backendConfigClient, nil, nil, namer, ctxConfig)
ctx := context.NewControllerContext(client, nil, backendConfigClient, nil, nil, namer, ctxConfig)
gce := &Translator{
ctx: ctx,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/firewalls/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newFirewallController() *FirewallController {
DefaultBackendSvcPort: test.DefaultBeSvcPort,
}

ctx := context.NewControllerContext(kubeClient, backendConfigClient, nil, fakeGCE, namer, ctxConfig)
ctx := context.NewControllerContext(kubeClient, nil, backendConfigClient, nil, fakeGCE, namer, ctxConfig)
fwc := NewFirewallController(ctx, []string{"30000-32767"})
fwc.hasSynced = func() bool { return true }

Expand Down
Loading