Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
k8s-ingress
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-ingress
Commits
50d736ab
Commit
50d736ab
authored
Sep 03, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Controller doesn't watch namespaces when restricted to one namespace.
parent
81a73994
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
13 deletions
+25
-13
main.go
cmd/main.go
+3
-3
controller.go
pkg/controller/controller.go
+22
-10
No files found.
cmd/main.go
View file @
50d736ab
...
...
@@ -238,9 +238,9 @@ func main() {
informers
.
WithTweakListOptions
(
ingressTLSSecrets
))
ingController
,
err
:=
controller
.
NewIngressController
(
log
,
*
ingressClassF
,
kubeClient
,
vController
,
h
Controller
,
informerFactory
,
vcrInformerFactory
,
vse
crInformerFactory
,
tsecrInformerFactory
,
*
incomplRetryDelayF
)
*
ingressClassF
,
*
namespaceF
,
kubeClient
,
v
Controller
,
hController
,
informerFactory
,
v
crInformerFactory
,
vsecrInformerFactory
,
tsecrInformerFactory
,
*
incomplRetryDelayF
)
if
err
!=
nil
{
log
.
Fatalf
(
"Could not initialize controller: %v"
,
err
)
os
.
Exit
(
-
1
)
...
...
pkg/controller/controller.go
View file @
50d736ab
...
...
@@ -129,6 +129,7 @@ type IngressController struct {
ctx
context
.
Context
cancel
context
.
CancelFunc
recorder
record
.
EventRecorder
namespace
string
}
// NewIngressController creates a controller.
...
...
@@ -143,6 +144,7 @@ type IngressController struct {
func
NewIngressController
(
log
*
logrus
.
Logger
,
ingClass
string
,
namespace
string
,
kubeClient
kubernetes
.
Interface
,
vc
*
varnish
.
Controller
,
hc
*
haproxy
.
Controller
,
...
...
@@ -154,8 +156,9 @@ func NewIngressController(
)
(
*
IngressController
,
error
)
{
ingc
:=
IngressController
{
log
:
log
,
client
:
kubeClient
,
log
:
log
,
client
:
kubeClient
,
namespace
:
namespace
,
}
InitMetrics
()
...
...
@@ -182,7 +185,6 @@ func NewIngressController(
ing
:
infFactory
.
Extensions
()
.
V1beta1
()
.
Ingresses
()
.
Informer
(),
svc
:
infFactory
.
Core
()
.
V1
()
.
Services
()
.
Informer
(),
endp
:
infFactory
.
Core
()
.
V1
()
.
Endpoints
()
.
Informer
(),
ns
:
infFactory
.
Core
()
.
V1
()
.
Namespaces
()
.
Informer
(),
vsecr
:
vsecrInfFactory
.
Core
()
.
V1
()
.
Secrets
()
.
Informer
(),
tsecr
:
tsecrInfFactory
.
Core
()
.
V1
()
.
Secrets
()
.
Informer
(),
vcfg
:
vcrInfFactory
.
Ingress
()
.
V1alpha1
()
.
VarnishConfigs
()
.
...
...
@@ -205,10 +207,14 @@ func NewIngressController(
ingc
.
informers
.
vcfg
.
AddEventHandler
(
evtFuncs
)
ingc
.
informers
.
bcfg
.
AddEventHandler
(
evtFuncs
)
nsDeleteFunc
:=
cache
.
ResourceEventHandlerFuncs
{
DeleteFunc
:
ingc
.
deleteNs
,
if
namespace
==
api_v1
.
NamespaceAll
{
ingc
.
informers
.
ns
=
infFactory
.
Core
()
.
V1
()
.
Namespaces
()
.
Informer
()
nsDeleteFunc
:=
cache
.
ResourceEventHandlerFuncs
{
DeleteFunc
:
ingc
.
deleteNs
,
}
ingc
.
informers
.
ns
.
AddEventHandler
(
nsDeleteFunc
)
}
ingc
.
informers
.
ns
.
AddEventHandler
(
nsDeleteFunc
)
ingc
.
listers
=
&
Listers
{
ing
:
infFactory
.
Extensions
()
.
V1beta1
()
.
Ingresses
()
.
Lister
(),
...
...
@@ -393,7 +399,9 @@ func (ingc *IngressController) Run(readyFile string, metricsPort uint16) {
go
ingc
.
informers
.
vsecr
.
Run
(
ingc
.
ctx
.
Done
())
go
ingc
.
informers
.
vcfg
.
Run
(
ingc
.
ctx
.
Done
())
go
ingc
.
informers
.
bcfg
.
Run
(
ingc
.
ctx
.
Done
())
go
ingc
.
informers
.
ns
.
Run
(
ingc
.
ctx
.
Done
())
if
ingc
.
namespace
==
api_v1
.
NamespaceAll
{
go
ingc
.
informers
.
ns
.
Run
(
ingc
.
ctx
.
Done
())
}
ingc
.
log
.
Infof
(
"Starting metrics listener at port %d"
,
metricsPort
)
go
ServeMetrics
(
ingc
.
log
,
metricsPort
)
...
...
@@ -416,8 +424,7 @@ func (ingc *IngressController) Run(readyFile string, metricsPort uint16) {
ingc
.
log
.
Infof
(
"Created ready file %s"
,
readyFile
)
}
ingc
.
log
.
Info
(
"Waiting for caches to sync"
)
if
ok
:=
cache
.
WaitForCacheSync
(
ingc
.
ctx
.
Done
(),
syncs
:=
[]
cache
.
InformerSynced
{
ingc
.
informers
.
ing
.
HasSynced
,
ingc
.
informers
.
svc
.
HasSynced
,
ingc
.
informers
.
endp
.
HasSynced
,
...
...
@@ -425,8 +432,13 @@ func (ingc *IngressController) Run(readyFile string, metricsPort uint16) {
ingc
.
informers
.
vsecr
.
HasSynced
,
ingc
.
informers
.
vcfg
.
HasSynced
,
ingc
.
informers
.
bcfg
.
HasSynced
,
ingc
.
informers
.
ns
.
HasSynced
);
!
ok
{
}
if
ingc
.
namespace
==
api_v1
.
NamespaceAll
{
syncs
=
append
(
syncs
,
ingc
.
informers
.
ns
.
HasSynced
)
}
ingc
.
log
.
Info
(
"Waiting for caches to sync"
)
if
ok
:=
cache
.
WaitForCacheSync
(
ingc
.
ctx
.
Done
(),
syncs
...
);
!
ok
{
err
:=
fmt
.
Errorf
(
"Failed waiting for caches to sync"
)
utilruntime
.
HandleError
(
err
)
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment