diff options
author | 2018-10-09 21:56:09 +0100 | |
---|---|---|
committer | 2018-10-09 21:56:09 +0100 | |
commit | 830e97f8008ed83abb6b293a12a87f3fce34e423 (patch) | |
tree | d1a020aa3e7b232a52018479ab7972d350bd74e7 /plugin/kubernetes/autopath.go | |
parent | 298b860a97481630ec65698ab0465675bf58b43a (diff) | |
download | coredns-830e97f8008ed83abb6b293a12a87f3fce34e423.tar.gz coredns-830e97f8008ed83abb6b293a12a87f3fce34e423.tar.zst coredns-830e97f8008ed83abb6b293a12a87f3fce34e423.zip |
plugin/kubernetes: allow trimming down of cached items. (#2128)
* Convert to runtime.Object to smaller structs
This adds conversion for all the objects we want to keep in the cache.
It keeps the minimum for CoreDNS to function and throws away the rest.
The conversion:
api.Endpoints -> object.Endpoints
api.Pod -> object.Pod
api.Serivce -> object.Service
We needed to copy some client-go stuff to insert a conversion function
into NewIndexInformers.
Some unrelated cleanups in the watch functionality as that needed to be
touched because of the above translation of objects.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Reduce test line-count
Signed-off-by: Miek Gieben <miek@miek.nl>
* ....and fix test
Signed-off-by: Miek Gieben <miek@miek.nl>
* Drop use of append
Signed-off-by: Miek Gieben <miek@miek.nl>
* cosmetic changes
Signed-off-by: Miek Gieben <miek@miek.nl>
* that was a typo
Signed-off-by: Miek Gieben <miek@miek.nl>
* re-introduce append here
We can't really use len() here because we don't know the number before
hand.
Signed-off-by: Miek Gieben <miek@miek.nl>
* comment in better place
Signed-off-by: Miek Gieben <miek@miek.nl>
* Make the timestamp a bool; thats where it is used for
Signed-off-by: Miek Gieben <miek@miek.nl>
* Set incoming object to nil
Explicataliy discard the converted object; we did a deep copy it's
not needed anymore.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Per Chris's comment
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/kubernetes/autopath.go')
-rw-r--r-- | plugin/kubernetes/autopath.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/plugin/kubernetes/autopath.go b/plugin/kubernetes/autopath.go index 4d991a38f..71506ee3d 100644 --- a/plugin/kubernetes/autopath.go +++ b/plugin/kubernetes/autopath.go @@ -2,9 +2,8 @@ package kubernetes import ( "github.com/coredns/coredns/plugin" + "github.com/coredns/coredns/plugin/kubernetes/object" "github.com/coredns/coredns/request" - - api "k8s.io/api/core/v1" ) // AutoPath implements the AutoPathFunc call from the autopath plugin. @@ -40,7 +39,7 @@ func (k *Kubernetes) AutoPath(state request.Request) []string { } // podWithIP return the api.Pod for source IP ip. It returns nil if nothing can be found. -func (k *Kubernetes) podWithIP(ip string) *api.Pod { +func (k *Kubernetes) podWithIP(ip string) *object.Pod { ps := k.APIConn.PodIndex(ip) if len(ps) == 0 { return nil |