Cleanup
This commit is contained in:
parent
f478084cd8
commit
0661eaa08c
29 changed files with 264 additions and 281 deletions
12
.travis.yml
12
.travis.yml
|
@ -9,19 +9,10 @@ notifications:
|
||||||
email: true
|
email: true
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.8.3
|
- 1.9
|
||||||
|
|
||||||
go_import_path: k8s.io/ingress
|
go_import_path: k8s.io/ingress
|
||||||
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
# to add additional secure variables:
|
|
||||||
# docker run --rm caktux/travis-cli encrypt key=value -r kubernetes/ingress
|
|
||||||
- RELEASE="ci-${TRAVIS_BUILD_ID}"
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- export PATH=$PATH:$PWD/hack/e2e-internal/
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- stage: Static Check
|
- stage: Static Check
|
||||||
|
@ -34,4 +25,3 @@ jobs:
|
||||||
- go get github.com/modocache/gover
|
- go get github.com/modocache/gover
|
||||||
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
|
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
|
||||||
- make cover
|
- make cover
|
||||||
#- make test-e2e
|
|
||||||
|
|
18
Makefile
18
Makefile
|
@ -2,24 +2,6 @@ all: fmt lint vet
|
||||||
|
|
||||||
BUILDTAGS=
|
BUILDTAGS=
|
||||||
|
|
||||||
# building inside travis generates a custom version of the
|
|
||||||
# backends in order to run e2e tests agains the build.
|
|
||||||
ifdef TRAVIS_BUILD_ID
|
|
||||||
RELEASE := ci-build-${TRAVIS_BUILD_ID}
|
|
||||||
endif
|
|
||||||
|
|
||||||
# 0.0 shouldn't clobber any release builds
|
|
||||||
RELEASE?=0.0
|
|
||||||
|
|
||||||
# by default build a linux version
|
|
||||||
GOOS?=linux
|
|
||||||
|
|
||||||
REPO_INFO=$(shell git config --get remote.origin.url)
|
|
||||||
|
|
||||||
ifndef COMMIT
|
|
||||||
COMMIT := git-$(shell git rev-parse --short HEAD)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# base package. It contains the common and backends code
|
# base package. It contains the common and backends code
|
||||||
PKG := "k8s.io/ingress"
|
PKG := "k8s.io/ingress"
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
proxyproto "github.com/armon/go-proxyproto"
|
proxyproto "github.com/armon/go-proxyproto"
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
api_v1 "k8s.io/api/core/v1"
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
|
@ -83,7 +82,7 @@ func newNGINXController() *NGINXController {
|
||||||
|
|
||||||
n := &NGINXController{
|
n := &NGINXController{
|
||||||
binary: ngx,
|
binary: ngx,
|
||||||
configmap: &api_v1.ConfigMap{},
|
configmap: &apiv1.ConfigMap{},
|
||||||
isIPV6Enabled: isIPv6Enabled(),
|
isIPV6Enabled: isIPv6Enabled(),
|
||||||
resolver: h,
|
resolver: h,
|
||||||
ports: &config.ListenPorts{},
|
ports: &config.ListenPorts{},
|
||||||
|
@ -123,7 +122,7 @@ type NGINXController struct {
|
||||||
controller *controller.GenericController
|
controller *controller.GenericController
|
||||||
t *ngx_template.Template
|
t *ngx_template.Template
|
||||||
|
|
||||||
configmap *api_v1.ConfigMap
|
configmap *apiv1.ConfigMap
|
||||||
|
|
||||||
storeLister ingress.StoreLister
|
storeLister ingress.StoreLister
|
||||||
|
|
||||||
|
@ -309,7 +308,7 @@ func (n NGINXController) DefaultEndpoint() ingress.Endpoint {
|
||||||
return ingress.Endpoint{
|
return ingress.Endpoint{
|
||||||
Address: "127.0.0.1",
|
Address: "127.0.0.1",
|
||||||
Port: fmt.Sprintf("%v", n.ports.Default),
|
Port: fmt.Sprintf("%v", n.ports.Default),
|
||||||
Target: &api.ObjectReference{},
|
Target: &apiv1.ObjectReference{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +442,7 @@ Error: %v
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetConfig sets the configured configmap
|
// SetConfig sets the configured configmap
|
||||||
func (n *NGINXController) SetConfig(cmap *api_v1.ConfigMap) {
|
func (n *NGINXController) SetConfig(cmap *apiv1.ConfigMap) {
|
||||||
n.configmap = cmap
|
n.configmap = cmap
|
||||||
n.isProxyProtocolEnabled = false
|
n.isProxyProtocolEnabled = false
|
||||||
|
|
||||||
|
@ -469,7 +468,7 @@ func (n *NGINXController) SetListers(lister ingress.StoreLister) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateIngressStatus custom Ingress status update
|
// UpdateIngressStatus custom Ingress status update
|
||||||
func (n *NGINXController) UpdateIngressStatus(*extensions.Ingress) []api_v1.LoadBalancerIngress {
|
func (n *NGINXController) UpdateIngressStatus(*extensions.Ingress) []apiv1.LoadBalancerIngress {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +597,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
setHeaders = cmap.(*api_v1.ConfigMap).Data
|
setHeaders = cmap.(*apiv1.ConfigMap).Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +609,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
addHeaders = cmap.(*api_v1.ConfigMap).Data
|
addHeaders = cmap.(*apiv1.ConfigMap).Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +622,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
secret := s.(*api_v1.Secret)
|
secret := s.(*apiv1.Secret)
|
||||||
nsSecName := strings.Replace(secretName, "/", "-", -1)
|
nsSecName := strings.Replace(secretName, "/", "-", -1)
|
||||||
|
|
||||||
dh, ok := secret.Data["dhparam.pem"]
|
dh, ok := secret.Data["dhparam.pem"]
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/paultag/sniff/parser"
|
"github.com/paultag/sniff/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/util/sysctl"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
"k8s.io/kubernetes/pkg/util/sysctl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// sysctlSomaxconn returns the value of net.core.somaxconn, i.e.
|
// sysctlSomaxconn returns the value of net.core.somaxconn, i.e.
|
||||||
|
|
|
@ -18,6 +18,7 @@ package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
common "github.com/ncabatoff/process-exporter"
|
common "github.com/ncabatoff/process-exporter"
|
||||||
"github.com/ncabatoff/process-exporter/proc"
|
"github.com/ncabatoff/process-exporter/proc"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
|
|
|
@ -30,6 +30,7 @@ import (
|
||||||
text_template "text/template"
|
text_template "text/template"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/pborman/uuid"
|
"github.com/pborman/uuid"
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
|
|
|
@ -19,6 +19,7 @@ package template
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -29,7 +30,6 @@ import (
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/rewrite"
|
"k8s.io/ingress/core/pkg/ingress/annotations/rewrite"
|
||||||
"net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -18,6 +18,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/alias"
|
"k8s.io/ingress/core/pkg/ingress/annotations/alias"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
||||||
|
|
|
@ -19,9 +19,9 @@ package controller
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
|
@ -40,19 +40,19 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockCfg struct {
|
type mockCfg struct {
|
||||||
MockSecrets map[string]*api.Secret
|
MockSecrets map[string]*apiv1.Secret
|
||||||
MockServices map[string]*api.Service
|
MockServices map[string]*apiv1.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockCfg) GetDefaultBackend() defaults.Backend {
|
func (m mockCfg) GetDefaultBackend() defaults.Backend {
|
||||||
return defaults.Backend{}
|
return defaults.Backend{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockCfg) GetSecret(name string) (*api.Secret, error) {
|
func (m mockCfg) GetSecret(name string) (*apiv1.Secret, error) {
|
||||||
return m.MockSecrets[name], nil
|
return m.MockSecrets[name], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockCfg) GetService(name string) (*api.Service, error) {
|
func (m mockCfg) GetService(name string) (*apiv1.Service, error) {
|
||||||
return m.MockServices[name], nil
|
return m.MockServices[name], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ func buildIngress() *extensions.Ingress {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &extensions.Ingress{
|
return &extensions.Ingress{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: extensions.IngressSpec{
|
Spec: extensions.IngressSpec{
|
||||||
Backend: &extensions.IngressBackend{
|
Backend: &extensions.IngressBackend{
|
||||||
|
@ -142,9 +142,9 @@ func TestSecureUpstream(t *testing.T) {
|
||||||
|
|
||||||
func TestSecureVerifyCACert(t *testing.T) {
|
func TestSecureVerifyCACert(t *testing.T) {
|
||||||
ec := newAnnotationExtractor(mockCfg{
|
ec := newAnnotationExtractor(mockCfg{
|
||||||
MockSecrets: map[string]*api.Secret{
|
MockSecrets: map[string]*apiv1.Secret{
|
||||||
"default/secure-verify-ca": {
|
"default/secure-verify-ca": {
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "secure-verify-ca",
|
Name: "secure-verify-ca",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
|
@ -75,9 +75,9 @@ func (ic *GenericController) getPemCertificate(secretName string) (*ingress.SSLC
|
||||||
return nil, fmt.Errorf("secret named %v does not exist", secretName)
|
return nil, fmt.Errorf("secret named %v does not exist", secretName)
|
||||||
}
|
}
|
||||||
|
|
||||||
secret := secretInterface.(*api.Secret)
|
secret := secretInterface.(*apiv1.Secret)
|
||||||
cert, okcert := secret.Data[api.TLSCertKey]
|
cert, okcert := secret.Data[apiv1.TLSCertKey]
|
||||||
key, okkey := secret.Data[api.TLSPrivateKeyKey]
|
key, okkey := secret.Data[apiv1.TLSPrivateKeyKey]
|
||||||
|
|
||||||
ca := secret.Data["ca.crt"]
|
ca := secret.Data["ca.crt"]
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,15 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"fmt"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
api_v1 "k8s.io/api/core/v1"
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
cache_client "k8s.io/client-go/tools/cache"
|
cache_client "k8s.io/client-go/tools/cache"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/ingress/store"
|
"k8s.io/ingress/core/pkg/ingress/store"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
@ -70,9 +70,9 @@ func buildIngListenerForBackendSSL() store.IngressLister {
|
||||||
return ingLister
|
return ingLister
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSecretForBackendSSL() *api_v1.Secret {
|
func buildSecretForBackendSSL() *apiv1.Secret {
|
||||||
return &api_v1.Secret{
|
return &apiv1.Secret{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_secret",
|
Name: "foo_secret",
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/conversion"
|
"k8s.io/apimachinery/pkg/conversion"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
|
@ -37,11 +37,12 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
unversionedcore "k8s.io/client-go/kubernetes/typed/core/v1"
|
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
fcache "k8s.io/client-go/tools/cache/testing"
|
fcache "k8s.io/client-go/tools/cache/testing"
|
||||||
"k8s.io/client-go/tools/record"
|
"k8s.io/client-go/tools/record"
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/healthcheck"
|
"k8s.io/ingress/core/pkg/ingress/annotations/healthcheck"
|
||||||
|
@ -157,7 +158,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
|
|
||||||
eventBroadcaster := record.NewBroadcaster()
|
eventBroadcaster := record.NewBroadcaster()
|
||||||
eventBroadcaster.StartLogging(glog.Infof)
|
eventBroadcaster.StartLogging(glog.Infof)
|
||||||
eventBroadcaster.StartRecordingToSink(&unversionedcore.EventSinkImpl{
|
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{
|
||||||
Interface: config.Client.CoreV1().Events(config.Namespace),
|
Interface: config.Client.CoreV1().Events(config.Namespace),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -166,7 +167,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
stopLock: &sync.Mutex{},
|
stopLock: &sync.Mutex{},
|
||||||
stopCh: make(chan struct{}),
|
stopCh: make(chan struct{}),
|
||||||
syncRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.3, 1),
|
syncRateLimiter: flowcontrol.NewTokenBucketRateLimiter(0.3, 1),
|
||||||
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, api.EventSource{
|
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, apiv1.EventSource{
|
||||||
Component: "ingress-controller",
|
Component: "ingress-controller",
|
||||||
}),
|
}),
|
||||||
sslCertTracker: newSSLCertTracker(),
|
sslCertTracker: newSSLCertTracker(),
|
||||||
|
@ -185,7 +186,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", addIng.Name, class.IngressKey, a)
|
glog.Infof("ignoring add for ingress %v based on annotation %v with value %v", addIng.Name, class.IngressKey, a)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ic.recorder.Eventf(addIng, api.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", addIng.Namespace, addIng.Name))
|
ic.recorder.Eventf(addIng, apiv1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", addIng.Namespace, addIng.Name))
|
||||||
ic.syncQueue.Enqueue(obj)
|
ic.syncQueue.Enqueue(obj)
|
||||||
},
|
},
|
||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
|
@ -207,7 +208,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
glog.Infof("ignoring delete for ingress %v based on annotation %v", delIng.Name, class.IngressKey)
|
glog.Infof("ignoring delete for ingress %v based on annotation %v", delIng.Name, class.IngressKey)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ic.recorder.Eventf(delIng, api.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", delIng.Namespace, delIng.Name))
|
ic.recorder.Eventf(delIng, apiv1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", delIng.Namespace, delIng.Name))
|
||||||
ic.syncQueue.Enqueue(obj)
|
ic.syncQueue.Enqueue(obj)
|
||||||
},
|
},
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
|
@ -217,12 +218,12 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
validCur := class.IsValid(curIng, ic.cfg.IngressClass, ic.cfg.DefaultIngressClass)
|
validCur := class.IsValid(curIng, ic.cfg.IngressClass, ic.cfg.DefaultIngressClass)
|
||||||
if !validOld && validCur {
|
if !validOld && validCur {
|
||||||
glog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
glog.Infof("creating ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||||
ic.recorder.Eventf(curIng, api.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
ic.recorder.Eventf(curIng, apiv1.EventTypeNormal, "CREATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
} else if validOld && !validCur {
|
} else if validOld && !validCur {
|
||||||
glog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
glog.Infof("removing ingress %v based on annotation %v", curIng.Name, class.IngressKey)
|
||||||
ic.recorder.Eventf(curIng, api.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
ic.recorder.Eventf(curIng, apiv1.EventTypeNormal, "DELETE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
} else if validCur && !reflect.DeepEqual(old, cur) {
|
} else if validCur && !reflect.DeepEqual(old, cur) {
|
||||||
ic.recorder.Eventf(curIng, api.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
ic.recorder.Eventf(curIng, apiv1.EventTypeNormal, "UPDATE", fmt.Sprintf("Ingress %s/%s", curIng.Namespace, curIng.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
ic.syncQueue.Enqueue(cur)
|
ic.syncQueue.Enqueue(cur)
|
||||||
|
@ -232,13 +233,13 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
secrEventHandler := cache.ResourceEventHandlerFuncs{
|
secrEventHandler := cache.ResourceEventHandlerFuncs{
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
if !reflect.DeepEqual(old, cur) {
|
if !reflect.DeepEqual(old, cur) {
|
||||||
sec := cur.(*api.Secret)
|
sec := cur.(*apiv1.Secret)
|
||||||
key := fmt.Sprintf("%v/%v", sec.Namespace, sec.Name)
|
key := fmt.Sprintf("%v/%v", sec.Namespace, sec.Name)
|
||||||
ic.syncSecret(key)
|
ic.syncSecret(key)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
sec, ok := obj.(*api.Secret)
|
sec, ok := obj.(*apiv1.Secret)
|
||||||
if !ok {
|
if !ok {
|
||||||
// If we reached here it means the secret was deleted but its final state is unrecorded.
|
// If we reached here it means the secret was deleted but its final state is unrecorded.
|
||||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||||
|
@ -246,7 +247,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
glog.Errorf("couldn't get object from tombstone %#v", obj)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sec, ok = tombstone.Obj.(*api.Secret)
|
sec, ok = tombstone.Obj.(*apiv1.Secret)
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
glog.Errorf("Tombstone contained object that is not a Secret: %#v", obj)
|
||||||
return
|
return
|
||||||
|
@ -265,8 +266,8 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
ic.syncQueue.Enqueue(obj)
|
ic.syncQueue.Enqueue(obj)
|
||||||
},
|
},
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
oep := old.(*api.Endpoints)
|
oep := old.(*apiv1.Endpoints)
|
||||||
ocur := cur.(*api.Endpoints)
|
ocur := cur.(*apiv1.Endpoints)
|
||||||
if !reflect.DeepEqual(ocur.Subsets, oep.Subsets) {
|
if !reflect.DeepEqual(ocur.Subsets, oep.Subsets) {
|
||||||
ic.syncQueue.Enqueue(cur)
|
ic.syncQueue.Enqueue(cur)
|
||||||
}
|
}
|
||||||
|
@ -275,7 +276,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
|
|
||||||
mapEventHandler := cache.ResourceEventHandlerFuncs{
|
mapEventHandler := cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: func(obj interface{}) {
|
AddFunc: func(obj interface{}) {
|
||||||
upCmap := obj.(*api.ConfigMap)
|
upCmap := obj.(*apiv1.ConfigMap)
|
||||||
mapKey := fmt.Sprintf("%s/%s", upCmap.Namespace, upCmap.Name)
|
mapKey := fmt.Sprintf("%s/%s", upCmap.Namespace, upCmap.Name)
|
||||||
if mapKey == ic.cfg.ConfigMapName {
|
if mapKey == ic.cfg.ConfigMapName {
|
||||||
glog.V(2).Infof("adding configmap %v to backend", mapKey)
|
glog.V(2).Infof("adding configmap %v to backend", mapKey)
|
||||||
|
@ -285,7 +286,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
},
|
},
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
if !reflect.DeepEqual(old, cur) {
|
if !reflect.DeepEqual(old, cur) {
|
||||||
upCmap := cur.(*api.ConfigMap)
|
upCmap := cur.(*apiv1.ConfigMap)
|
||||||
mapKey := fmt.Sprintf("%s/%s", upCmap.Namespace, upCmap.Name)
|
mapKey := fmt.Sprintf("%s/%s", upCmap.Namespace, upCmap.Name)
|
||||||
if mapKey == ic.cfg.ConfigMapName {
|
if mapKey == ic.cfg.ConfigMapName {
|
||||||
glog.V(2).Infof("updating configmap backend (%v)", mapKey)
|
glog.V(2).Infof("updating configmap backend (%v)", mapKey)
|
||||||
|
@ -294,15 +295,15 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
}
|
}
|
||||||
// updates to configuration configmaps can trigger an update
|
// updates to configuration configmaps can trigger an update
|
||||||
if mapKey == ic.cfg.ConfigMapName || mapKey == ic.cfg.TCPConfigMapName || mapKey == ic.cfg.UDPConfigMapName {
|
if mapKey == ic.cfg.ConfigMapName || mapKey == ic.cfg.TCPConfigMapName || mapKey == ic.cfg.UDPConfigMapName {
|
||||||
ic.recorder.Eventf(upCmap, api.EventTypeNormal, "UPDATE", fmt.Sprintf("ConfigMap %v", mapKey))
|
ic.recorder.Eventf(upCmap, apiv1.EventTypeNormal, "UPDATE", fmt.Sprintf("ConfigMap %v", mapKey))
|
||||||
ic.syncQueue.Enqueue(cur)
|
ic.syncQueue.Enqueue(cur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
watchNs := api.NamespaceAll
|
watchNs := apiv1.NamespaceAll
|
||||||
if ic.cfg.ForceNamespaceIsolation && ic.cfg.Namespace != api.NamespaceAll {
|
if ic.cfg.ForceNamespaceIsolation && ic.cfg.Namespace != apiv1.NamespaceAll {
|
||||||
watchNs = ic.cfg.Namespace
|
watchNs = ic.cfg.Namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,29 +313,29 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
|
|
||||||
ic.endpLister.Store, ic.endpController = cache.NewInformer(
|
ic.endpLister.Store, ic.endpController = cache.NewInformer(
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "endpoints", ic.cfg.Namespace, fields.Everything()),
|
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "endpoints", ic.cfg.Namespace, fields.Everything()),
|
||||||
&api.Endpoints{}, ic.cfg.ResyncPeriod, eventHandler)
|
&apiv1.Endpoints{}, ic.cfg.ResyncPeriod, eventHandler)
|
||||||
|
|
||||||
ic.secrLister.Store, ic.secrController = cache.NewInformer(
|
ic.secrLister.Store, ic.secrController = cache.NewInformer(
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "secrets", watchNs, fields.Everything()),
|
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "secrets", watchNs, fields.Everything()),
|
||||||
&api.Secret{}, ic.cfg.ResyncPeriod, secrEventHandler)
|
&apiv1.Secret{}, ic.cfg.ResyncPeriod, secrEventHandler)
|
||||||
|
|
||||||
ic.mapLister.Store, ic.mapController = cache.NewInformer(
|
ic.mapLister.Store, ic.mapController = cache.NewInformer(
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "configmaps", watchNs, fields.Everything()),
|
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "configmaps", watchNs, fields.Everything()),
|
||||||
&api.ConfigMap{}, ic.cfg.ResyncPeriod, mapEventHandler)
|
&apiv1.ConfigMap{}, ic.cfg.ResyncPeriod, mapEventHandler)
|
||||||
|
|
||||||
ic.svcLister.Store, ic.svcController = cache.NewInformer(
|
ic.svcLister.Store, ic.svcController = cache.NewInformer(
|
||||||
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "services", ic.cfg.Namespace, fields.Everything()),
|
cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "services", ic.cfg.Namespace, fields.Everything()),
|
||||||
&api.Service{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
&apiv1.Service{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
||||||
|
|
||||||
var nodeListerWatcher cache.ListerWatcher
|
var nodeListerWatcher cache.ListerWatcher
|
||||||
if config.DisableNodeList {
|
if config.DisableNodeList {
|
||||||
nodeListerWatcher = fcache.NewFakeControllerSource()
|
nodeListerWatcher = fcache.NewFakeControllerSource()
|
||||||
} else {
|
} else {
|
||||||
nodeListerWatcher = cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "nodes", api.NamespaceAll, fields.Everything())
|
nodeListerWatcher = cache.NewListWatchFromClient(ic.cfg.Client.CoreV1().RESTClient(), "nodes", apiv1.NamespaceAll, fields.Everything())
|
||||||
}
|
}
|
||||||
ic.nodeLister.Store, ic.nodeController = cache.NewInformer(
|
ic.nodeLister.Store, ic.nodeController = cache.NewInformer(
|
||||||
nodeListerWatcher,
|
nodeListerWatcher,
|
||||||
&api.Node{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
&apiv1.Node{}, ic.cfg.ResyncPeriod, cache.ResourceEventHandlerFuncs{})
|
||||||
|
|
||||||
if config.UpdateStatus {
|
if config.UpdateStatus {
|
||||||
ic.syncStatus = status.NewStatusSyncer(status.Config{
|
ic.syncStatus = status.NewStatusSyncer(status.Config{
|
||||||
|
@ -382,7 +383,7 @@ func (ic GenericController) GetDefaultBackend() defaults.Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPublishService returns the configured service used to set ingress status
|
// GetPublishService returns the configured service used to set ingress status
|
||||||
func (ic GenericController) GetPublishService() *api.Service {
|
func (ic GenericController) GetPublishService() *apiv1.Service {
|
||||||
s, err := ic.GetService(ic.cfg.PublishService)
|
s, err := ic.GetService(ic.cfg.PublishService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -397,7 +398,7 @@ func (ic GenericController) GetRecorder() record.EventRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSecret searches for a secret in the local secrets Store
|
// GetSecret searches for a secret in the local secrets Store
|
||||||
func (ic GenericController) GetSecret(name string) (*api.Secret, error) {
|
func (ic GenericController) GetSecret(name string) (*apiv1.Secret, error) {
|
||||||
s, exists, err := ic.secrLister.Store.GetByKey(name)
|
s, exists, err := ic.secrLister.Store.GetByKey(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -405,11 +406,11 @@ func (ic GenericController) GetSecret(name string) (*api.Secret, error) {
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, fmt.Errorf("secret %v was not found", name)
|
return nil, fmt.Errorf("secret %v was not found", name)
|
||||||
}
|
}
|
||||||
return s.(*api.Secret), nil
|
return s.(*apiv1.Secret), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetService searches for a service in the local secrets Store
|
// GetService searches for a service in the local secrets Store
|
||||||
func (ic GenericController) GetService(name string) (*api.Service, error) {
|
func (ic GenericController) GetService(name string) (*apiv1.Service, error) {
|
||||||
s, exists, err := ic.svcLister.Store.GetByKey(name)
|
s, exists, err := ic.svcLister.Store.GetByKey(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -417,10 +418,10 @@ func (ic GenericController) GetService(name string) (*api.Service, error) {
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, fmt.Errorf("service %v was not found", name)
|
return nil, fmt.Errorf("service %v was not found", name)
|
||||||
}
|
}
|
||||||
return s.(*api.Service), nil
|
return s.(*apiv1.Service), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *GenericController) getConfigMap(ns, name string) (*api.ConfigMap, error) {
|
func (ic *GenericController) getConfigMap(ns, name string) (*apiv1.ConfigMap, error) {
|
||||||
s, exists, err := ic.mapLister.Store.GetByKey(fmt.Sprintf("%v/%v", ns, name))
|
s, exists, err := ic.mapLister.Store.GetByKey(fmt.Sprintf("%v/%v", ns, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -428,7 +429,7 @@ func (ic *GenericController) getConfigMap(ns, name string) (*api.ConfigMap, erro
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, fmt.Errorf("configmap %v was not found", name)
|
return nil, fmt.Errorf("configmap %v was not found", name)
|
||||||
}
|
}
|
||||||
return s.(*api.ConfigMap), nil
|
return s.(*apiv1.ConfigMap), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync collects all the pieces required to assemble the configuration file and
|
// sync collects all the pieces required to assemble the configuration file and
|
||||||
|
@ -474,8 +475,8 @@ func (ic *GenericController) syncIngress(key interface{}) error {
|
||||||
pcfg := ingress.Configuration{
|
pcfg := ingress.Configuration{
|
||||||
Backends: upstreams,
|
Backends: upstreams,
|
||||||
Servers: servers,
|
Servers: servers,
|
||||||
TCPEndpoints: ic.getStreamServices(ic.cfg.TCPConfigMapName, api.ProtocolTCP),
|
TCPEndpoints: ic.getStreamServices(ic.cfg.TCPConfigMapName, apiv1.ProtocolTCP),
|
||||||
UDPEndpoints: ic.getStreamServices(ic.cfg.UDPConfigMapName, api.ProtocolUDP),
|
UDPEndpoints: ic.getStreamServices(ic.cfg.UDPConfigMapName, apiv1.ProtocolUDP),
|
||||||
PassthroughBackends: passUpstreams,
|
PassthroughBackends: passUpstreams,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +504,7 @@ func (ic *GenericController) syncIngress(key interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ic *GenericController) getStreamServices(configmapName string, proto api.Protocol) []ingress.L4Service {
|
func (ic *GenericController) getStreamServices(configmapName string, proto apiv1.Protocol) []ingress.L4Service {
|
||||||
glog.V(3).Infof("obtaining information about stream services of type %v located in configmap %v", proto, configmapName)
|
glog.V(3).Infof("obtaining information about stream services of type %v located in configmap %v", proto, configmapName)
|
||||||
if configmapName == "" {
|
if configmapName == "" {
|
||||||
// no configmap configured
|
// no configmap configured
|
||||||
|
@ -549,7 +550,7 @@ func (ic *GenericController) getStreamServices(configmapName string, proto api.P
|
||||||
useProxyProtocol := false
|
useProxyProtocol := false
|
||||||
|
|
||||||
// Proxy protocol is possible if the service is TCP
|
// Proxy protocol is possible if the service is TCP
|
||||||
if len(nsSvcPort) == 3 && proto == api.ProtocolTCP {
|
if len(nsSvcPort) == 3 && proto == apiv1.ProtocolTCP {
|
||||||
if strings.ToUpper(nsSvcPort[2]) == "PROXY" {
|
if strings.ToUpper(nsSvcPort[2]) == "PROXY" {
|
||||||
useProxyProtocol = true
|
useProxyProtocol = true
|
||||||
}
|
}
|
||||||
|
@ -572,7 +573,7 @@ func (ic *GenericController) getStreamServices(configmapName string, proto api.P
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := svcObj.(*api.Service)
|
svc := svcObj.(*apiv1.Service)
|
||||||
|
|
||||||
var endps []ingress.Endpoint
|
var endps []ingress.Endpoint
|
||||||
targetPort, err := strconv.Atoi(svcPort)
|
targetPort, err := strconv.Atoi(svcPort)
|
||||||
|
@ -643,8 +644,8 @@ func (ic *GenericController) getDefaultUpstream() *ingress.Backend {
|
||||||
return upstream
|
return upstream
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := svcObj.(*api.Service)
|
svc := svcObj.(*apiv1.Service)
|
||||||
endps := ic.getEndpoints(svc, &svc.Spec.Ports[0], api.ProtocolTCP, &healthcheck.Upstream{})
|
endps := ic.getEndpoints(svc, &svc.Spec.Ports[0], apiv1.ProtocolTCP, &healthcheck.Upstream{})
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
||||||
endps = []ingress.Endpoint{ic.cfg.Backend.DefaultEndpoint()}
|
endps = []ingress.Endpoint{ic.cfg.Backend.DefaultEndpoint()}
|
||||||
|
@ -811,7 +812,7 @@ func (ic *GenericController) getBackendServers() ([]*ingress.Backend, []*ingress
|
||||||
// check if the location contains endpoints and a custom default backend
|
// check if the location contains endpoints and a custom default backend
|
||||||
if location.DefaultBackend != nil {
|
if location.DefaultBackend != nil {
|
||||||
sp := location.DefaultBackend.Spec.Ports[0]
|
sp := location.DefaultBackend.Spec.Ports[0]
|
||||||
endps := ic.getEndpoints(location.DefaultBackend, &sp, api.ProtocolTCP, &healthcheck.Upstream{})
|
endps := ic.getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, &healthcheck.Upstream{})
|
||||||
if len(endps) > 0 {
|
if len(endps) > 0 {
|
||||||
glog.V(3).Infof("using custom default backend in server %v location %v (service %v/%v)",
|
glog.V(3).Infof("using custom default backend in server %v location %v (service %v/%v)",
|
||||||
server.Hostname, location.Path, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
|
server.Hostname, location.Path, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
|
||||||
|
@ -1004,7 +1005,7 @@ func (ic *GenericController) createUpstreams(data []interface{}) map[string]*ing
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
upstreams[name].Service = s.(*api.Service)
|
upstreams[name].Service = s.(*apiv1.Service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1019,7 +1020,7 @@ func (ic *GenericController) getServiceClusterEndpoint(svcKey string, backend *e
|
||||||
return endpoint, fmt.Errorf("service %v does not exist", svcKey)
|
return endpoint, fmt.Errorf("service %v does not exist", svcKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := svcObj.(*api.Service)
|
svc := svcObj.(*apiv1.Service)
|
||||||
if svc.Spec.ClusterIP == "" {
|
if svc.Spec.ClusterIP == "" {
|
||||||
return endpoint, fmt.Errorf("No ClusterIP found for service %s", svcKey)
|
return endpoint, fmt.Errorf("No ClusterIP found for service %s", svcKey)
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1047,7 @@ func (ic *GenericController) serviceEndpoints(svcKey, backendPort string,
|
||||||
return upstreams, err
|
return upstreams, err
|
||||||
}
|
}
|
||||||
|
|
||||||
svc := svcObj.(*api.Service)
|
svc := svcObj.(*apiv1.Service)
|
||||||
glog.V(3).Infof("obtaining port information for service %v", svcKey)
|
glog.V(3).Infof("obtaining port information for service %v", svcKey)
|
||||||
for _, servicePort := range svc.Spec.Ports {
|
for _, servicePort := range svc.Spec.Ports {
|
||||||
// targetPort could be a string, use the name or the port (int)
|
// targetPort could be a string, use the name or the port (int)
|
||||||
|
@ -1054,7 +1055,7 @@ func (ic *GenericController) serviceEndpoints(svcKey, backendPort string,
|
||||||
servicePort.TargetPort.String() == backendPort ||
|
servicePort.TargetPort.String() == backendPort ||
|
||||||
servicePort.Name == backendPort {
|
servicePort.Name == backendPort {
|
||||||
|
|
||||||
endps := ic.getEndpoints(svc, &servicePort, api.ProtocolTCP, hz)
|
endps := ic.getEndpoints(svc, &servicePort, apiv1.ProtocolTCP, hz)
|
||||||
if len(endps) == 0 {
|
if len(endps) == 0 {
|
||||||
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
glog.Warningf("service %v does not have any active endpoints", svcKey)
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1176,7 @@ func (ic *GenericController) createServers(data []interface{},
|
||||||
IsDefBackend: true,
|
IsDefBackend: true,
|
||||||
Backend: un,
|
Backend: un,
|
||||||
Proxy: ngxProxy,
|
Proxy: ngxProxy,
|
||||||
Service: &api.Service{},
|
Service: &apiv1.Service{},
|
||||||
},
|
},
|
||||||
}, SSLPassthrough: sslpt}
|
}, SSLPassthrough: sslpt}
|
||||||
}
|
}
|
||||||
|
@ -1262,9 +1263,9 @@ func (ic *GenericController) createServers(data []interface{},
|
||||||
|
|
||||||
// getEndpoints returns a list of <endpoint ip>:<port> for a given service/target port combination.
|
// getEndpoints returns a list of <endpoint ip>:<port> for a given service/target port combination.
|
||||||
func (ic *GenericController) getEndpoints(
|
func (ic *GenericController) getEndpoints(
|
||||||
s *api.Service,
|
s *apiv1.Service,
|
||||||
servicePort *api.ServicePort,
|
servicePort *apiv1.ServicePort,
|
||||||
proto api.Protocol,
|
proto apiv1.Protocol,
|
||||||
hz *healthcheck.Upstream) []ingress.Endpoint {
|
hz *healthcheck.Upstream) []ingress.Endpoint {
|
||||||
|
|
||||||
upsServers := []ingress.Endpoint{}
|
upsServers := []ingress.Endpoint{}
|
||||||
|
@ -1275,7 +1276,7 @@ func (ic *GenericController) getEndpoints(
|
||||||
adus := make(map[string]bool)
|
adus := make(map[string]bool)
|
||||||
|
|
||||||
// ExternalName services
|
// ExternalName services
|
||||||
if s.Spec.Type == api.ServiceTypeExternalName {
|
if s.Spec.Type == apiv1.ServiceTypeExternalName {
|
||||||
targetPort := servicePort.TargetPort.IntValue()
|
targetPort := servicePort.TargetPort.IntValue()
|
||||||
// check for invalid port value
|
// check for invalid port value
|
||||||
if targetPort <= 0 {
|
if targetPort <= 0 {
|
||||||
|
|
|
@ -15,13 +15,13 @@ import (
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
clientcmd_api "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/k8s"
|
"k8s.io/ingress/core/pkg/k8s"
|
||||||
|
@ -70,7 +70,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
resyncPeriod = flags.Duration("sync-period", 600*time.Second,
|
resyncPeriod = flags.Duration("sync-period", 600*time.Second,
|
||||||
`Relist and confirm cloud resources this often. Default is 10 minutes`)
|
`Relist and confirm cloud resources this often. Default is 10 minutes`)
|
||||||
|
|
||||||
watchNamespace = flags.String("watch-namespace", api.NamespaceAll,
|
watchNamespace = flags.String("watch-namespace", apiv1.NamespaceAll,
|
||||||
`Namespace to watch for Ingress. Default is to watch all namespaces`)
|
`Namespace to watch for Ingress. Default is to watch all namespaces`)
|
||||||
|
|
||||||
healthzPort = flags.Int("healthz-port", 10254, "port for healthz endpoint.")
|
healthzPort = flags.Int("healthz-port", 10254, "port for healthz endpoint.")
|
||||||
|
@ -130,7 +130,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
glog.Fatalf("invalid format for service %v: %v", *defaultSvc, err)
|
glog.Fatalf("invalid format for service %v: %v", *defaultSvc, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = kubeClient.Core().Services(ns).Get(name, meta_v1.GetOptions{})
|
_, err = kubeClient.Core().Services(ns).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
if strings.Contains(err.Error(), "cannot get services in the namespace") {
|
||||||
glog.Fatalf("✖ It seems the cluster it is running with Authorization enabled (like RBAC) and there is no permissions for the ingress controller. Please check the configuration")
|
glog.Fatalf("✖ It seems the cluster it is running with Authorization enabled (like RBAC) and there is no permissions for the ingress controller. Please check the configuration")
|
||||||
|
@ -145,7 +145,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
glog.Fatalf("invalid service format: %v", err)
|
glog.Fatalf("invalid service format: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
svc, err := kubeClient.CoreV1().Services(ns).Get(name, meta_v1.GetOptions{})
|
svc, err := kubeClient.CoreV1().Services(ns).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("unexpected error getting information about service %v: %v", *publishSvc, err)
|
glog.Fatalf("unexpected error getting information about service %v: %v", *publishSvc, err)
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *watchNamespace != "" {
|
if *watchNamespace != "" {
|
||||||
_, err = kubeClient.CoreV1().Namespaces().Get(*watchNamespace, meta_v1.GetOptions{})
|
_, err = kubeClient.CoreV1().Namespaces().Get(*watchNamespace, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("no watchNamespace with name %v found: %v", *watchNamespace, err)
|
glog.Fatalf("no watchNamespace with name %v found: %v", *watchNamespace, err)
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ func buildConfigFromFlags(masterURL, kubeconfigPath string) (*rest.Config, error
|
||||||
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfigPath},
|
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfigPath},
|
||||||
&clientcmd.ConfigOverrides{
|
&clientcmd.ConfigOverrides{
|
||||||
ClusterInfo: clientcmd_api.Cluster{
|
ClusterInfo: clientcmdapi.Cluster{
|
||||||
Server: masterURL,
|
Server: masterURL,
|
||||||
},
|
},
|
||||||
}).ClientConfig()
|
}).ClientConfig()
|
||||||
|
|
|
@ -18,6 +18,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
package resolver
|
package resolver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/defaults"
|
"k8s.io/ingress/core/pkg/ingress/defaults"
|
||||||
)
|
)
|
||||||
|
@ -31,7 +31,7 @@ type DefaultBackend interface {
|
||||||
// Secret has a method that searches for secrets contenating
|
// Secret has a method that searches for secrets contenating
|
||||||
// the namespace and name using a the character /
|
// the namespace and name using a the character /
|
||||||
type Secret interface {
|
type Secret interface {
|
||||||
GetSecret(string) (*api.Secret, error)
|
GetSecret(string) (*apiv1.Secret, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthCertificate resolves a given secret name into an SSL certificate.
|
// AuthCertificate resolves a given secret name into an SSL certificate.
|
||||||
|
@ -44,7 +44,7 @@ type AuthCertificate interface {
|
||||||
// Service has a method that searches for services contenating
|
// Service has a method that searches for services contenating
|
||||||
// the namespace and name using a the character /
|
// the namespace and name using a the character /
|
||||||
type Service interface {
|
type Service interface {
|
||||||
GetService(string) (*api.Service, error)
|
GetService(string) (*apiv1.Service, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthSSLCert contains the necessary information to do certificate based
|
// AuthSSLCert contains the necessary information to do certificate based
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func (c LocationByPath) Less(i, j int) bool {
|
||||||
|
|
||||||
// SSLCert describes a SSL certificate to be used in a server
|
// SSLCert describes a SSL certificate to be used in a server
|
||||||
type SSLCert struct {
|
type SSLCert struct {
|
||||||
meta_v1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
Certificate *x509.Certificate `json:"certificate,omitempty"`
|
Certificate *x509.Certificate `json:"certificate,omitempty"`
|
||||||
// CAFileName contains the path to the file with the root certificate
|
// CAFileName contains the path to the file with the root certificate
|
||||||
CAFileName string `json:"caFileName"`
|
CAFileName string `json:"caFileName"`
|
||||||
|
|
|
@ -19,7 +19,7 @@ package ingress
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildBackendByNameServers() BackendByNameServers {
|
func buildBackendByNameServers() BackendByNameServers {
|
||||||
|
@ -365,7 +365,7 @@ func TestLocationByPathLess(t *testing.T) {
|
||||||
|
|
||||||
func TestGetObjectKindForSSLCert(t *testing.T) {
|
func TestGetObjectKindForSSLCert(t *testing.T) {
|
||||||
fk := &SSLCert{
|
fk := &SSLCert{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{},
|
ObjectMeta: metav1.ObjectMeta{},
|
||||||
CAFileName: "ca_file",
|
CAFileName: "ca_file",
|
||||||
PemFileName: "pemfile",
|
PemFileName: "pemfile",
|
||||||
PemSHA: "pem_sha",
|
PemSHA: "pem_sha",
|
||||||
|
|
|
@ -26,9 +26,9 @@ import (
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
@ -68,7 +68,7 @@ type Config struct {
|
||||||
IngressClass string
|
IngressClass string
|
||||||
|
|
||||||
// CustomIngressStatus allows to set custom values in Ingress status
|
// CustomIngressStatus allows to set custom values in Ingress status
|
||||||
CustomIngressStatus func(*extensions.Ingress) []v1.LoadBalancerIngress
|
CustomIngressStatus func(*extensions.Ingress) []apiv1.LoadBalancerIngress
|
||||||
}
|
}
|
||||||
|
|
||||||
// statusSync keeps the status IP in each Ingress rule updated executing a periodic check
|
// statusSync keeps the status IP in each Ingress rule updated executing a periodic check
|
||||||
|
@ -134,7 +134,7 @@ func (s statusSync) Shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.Infof("removing address from ingress status (%v)", addrs)
|
glog.Infof("removing address from ingress status (%v)", addrs)
|
||||||
s.updateStatus([]v1.LoadBalancerIngress{})
|
s.updateStatus([]apiv1.LoadBalancerIngress{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) sync(key interface{}) error {
|
func (s *statusSync) sync(key interface{}) error {
|
||||||
|
@ -197,13 +197,13 @@ func NewStatusSyncer(config Config) Sync {
|
||||||
broadcaster := record.NewBroadcaster()
|
broadcaster := record.NewBroadcaster()
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
|
|
||||||
recorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{
|
recorder := broadcaster.NewRecorder(scheme.Scheme, apiv1.EventSource{
|
||||||
Component: "ingress-leader-elector",
|
Component: "ingress-leader-elector",
|
||||||
Host: hostname,
|
Host: hostname,
|
||||||
})
|
})
|
||||||
|
|
||||||
lock := resourcelock.ConfigMapLock{
|
lock := resourcelock.ConfigMapLock{
|
||||||
ConfigMapMeta: meta_v1.ObjectMeta{Namespace: pod.Namespace, Name: electionID},
|
ConfigMapMeta: metav1.ObjectMeta{Namespace: pod.Namespace, Name: electionID},
|
||||||
Client: config.Client.CoreV1(),
|
Client: config.Client.CoreV1(),
|
||||||
LockConfig: resourcelock.ResourceLockConfig{
|
LockConfig: resourcelock.ResourceLockConfig{
|
||||||
Identity: pod.Name,
|
Identity: pod.Name,
|
||||||
|
@ -233,7 +233,7 @@ func NewStatusSyncer(config Config) Sync {
|
||||||
func (s *statusSync) runningAddresses() ([]string, error) {
|
func (s *statusSync) runningAddresses() ([]string, error) {
|
||||||
if s.PublishService != "" {
|
if s.PublishService != "" {
|
||||||
ns, name, _ := k8s.ParseNameNS(s.PublishService)
|
ns, name, _ := k8s.ParseNameNS(s.PublishService)
|
||||||
svc, err := s.Client.CoreV1().Services(ns).Get(name, meta_v1.GetOptions{})
|
svc, err := s.Client.CoreV1().Services(ns).Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ func (s *statusSync) runningAddresses() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get information about all the pods running the ingress controller
|
// get information about all the pods running the ingress controller
|
||||||
pods, err := s.Client.CoreV1().Pods(s.pod.Namespace).List(meta_v1.ListOptions{
|
pods, err := s.Client.CoreV1().Pods(s.pod.Namespace).List(metav1.ListOptions{
|
||||||
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
|
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -272,7 +272,7 @@ func (s *statusSync) runningAddresses() ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusSync) isRunningMultiplePods() bool {
|
func (s *statusSync) isRunningMultiplePods() bool {
|
||||||
pods, err := s.Client.CoreV1().Pods(s.pod.Namespace).List(meta_v1.ListOptions{
|
pods, err := s.Client.CoreV1().Pods(s.pod.Namespace).List(metav1.ListOptions{
|
||||||
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
|
LabelSelector: labels.SelectorFromSet(s.pod.Labels).String(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -283,13 +283,13 @@ func (s *statusSync) isRunningMultiplePods() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
|
// sliceToStatus converts a slice of IP and/or hostnames to LoadBalancerIngress
|
||||||
func sliceToStatus(endpoints []string) []v1.LoadBalancerIngress {
|
func sliceToStatus(endpoints []string) []apiv1.LoadBalancerIngress {
|
||||||
lbi := []v1.LoadBalancerIngress{}
|
lbi := []apiv1.LoadBalancerIngress{}
|
||||||
for _, ep := range endpoints {
|
for _, ep := range endpoints {
|
||||||
if net.ParseIP(ep) == nil {
|
if net.ParseIP(ep) == nil {
|
||||||
lbi = append(lbi, v1.LoadBalancerIngress{Hostname: ep})
|
lbi = append(lbi, apiv1.LoadBalancerIngress{Hostname: ep})
|
||||||
} else {
|
} else {
|
||||||
lbi = append(lbi, v1.LoadBalancerIngress{IP: ep})
|
lbi = append(lbi, apiv1.LoadBalancerIngress{IP: ep})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ func sliceToStatus(endpoints []string) []v1.LoadBalancerIngress {
|
||||||
// updateStatus changes the status information of Ingress rules
|
// updateStatus changes the status information of Ingress rules
|
||||||
// If the backend function CustomIngressStatus returns a value different
|
// If the backend function CustomIngressStatus returns a value different
|
||||||
// of nil then it uses the returned value or the newIngressPoint values
|
// of nil then it uses the returned value or the newIngressPoint values
|
||||||
func (s *statusSync) updateStatus(newIngressPoint []v1.LoadBalancerIngress) {
|
func (s *statusSync) updateStatus(newIngressPoint []apiv1.LoadBalancerIngress) {
|
||||||
ings := s.IngressLister.List()
|
ings := s.IngressLister.List()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(len(ings))
|
wg.Add(len(ings))
|
||||||
|
@ -315,7 +315,7 @@ func (s *statusSync) updateStatus(newIngressPoint []v1.LoadBalancerIngress) {
|
||||||
go func(wg *sync.WaitGroup, ing *extensions.Ingress) {
|
go func(wg *sync.WaitGroup, ing *extensions.Ingress) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
ingClient := s.Client.Extensions().Ingresses(ing.Namespace)
|
ingClient := s.Client.Extensions().Ingresses(ing.Namespace)
|
||||||
currIng, err := ingClient.Get(ing.Name, meta_v1.GetOptions{})
|
currIng, err := ingClient.Get(ing.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error searching Ingress %v/%v: %v", ing.Namespace, ing.Name, err)
|
glog.Errorf("unexpected error searching Ingress %v/%v: %v", ing.Namespace, ing.Name, err)
|
||||||
return
|
return
|
||||||
|
@ -346,7 +346,7 @@ func (s *statusSync) updateStatus(newIngressPoint []v1.LoadBalancerIngress) {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ingressSliceEqual(lhs, rhs []v1.LoadBalancerIngress) bool {
|
func ingressSliceEqual(lhs, rhs []apiv1.LoadBalancerIngress) bool {
|
||||||
if len(lhs) != len(rhs) {
|
if len(lhs) != len(rhs) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ func ingressSliceEqual(lhs, rhs []v1.LoadBalancerIngress) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadBalancerIngressByIP sorts LoadBalancerIngress using the field IP
|
// loadBalancerIngressByIP sorts LoadBalancerIngress using the field IP
|
||||||
type loadBalancerIngressByIP []v1.LoadBalancerIngress
|
type loadBalancerIngressByIP []apiv1.LoadBalancerIngress
|
||||||
|
|
||||||
func (c loadBalancerIngressByIP) Len() int { return len(c) }
|
func (c loadBalancerIngressByIP) Len() int { return len(c) }
|
||||||
func (c loadBalancerIngressByIP) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
func (c loadBalancerIngressByIP) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
||||||
|
|
|
@ -22,21 +22,21 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
api_v1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
"k8s.io/ingress/core/pkg/ingress/annotations/class"
|
||||||
cache_store "k8s.io/ingress/core/pkg/ingress/store"
|
"k8s.io/ingress/core/pkg/ingress/store"
|
||||||
"k8s.io/ingress/core/pkg/k8s"
|
"k8s.io/ingress/core/pkg/k8s"
|
||||||
"k8s.io/ingress/core/pkg/task"
|
"k8s.io/ingress/core/pkg/task"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildLoadBalancerIngressByIP() loadBalancerIngressByIP {
|
func buildLoadBalancerIngressByIP() loadBalancerIngressByIP {
|
||||||
return []api_v1.LoadBalancerIngress{
|
return []apiv1.LoadBalancerIngress{
|
||||||
{
|
{
|
||||||
IP: "10.0.0.1",
|
IP: "10.0.0.1",
|
||||||
Hostname: "foo1",
|
Hostname: "foo1",
|
||||||
|
@ -58,100 +58,100 @@ func buildLoadBalancerIngressByIP() loadBalancerIngressByIP {
|
||||||
|
|
||||||
func buildSimpleClientSet() *testclient.Clientset {
|
func buildSimpleClientSet() *testclient.Clientset {
|
||||||
return testclient.NewSimpleClientset(
|
return testclient.NewSimpleClientset(
|
||||||
&api_v1.PodList{Items: []api_v1.Pod{
|
&apiv1.PodList{Items: []apiv1.Pod{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo1",
|
Name: "foo1",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"lable_sig": "foo_pod",
|
"lable_sig": "foo_pod",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: api_v1.PodSpec{
|
Spec: apiv1.PodSpec{
|
||||||
NodeName: "foo_node_2",
|
NodeName: "foo_node_2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo2",
|
Name: "foo2",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"lable_sig": "foo_no",
|
"lable_sig": "foo_no",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo3",
|
Name: "foo3",
|
||||||
Namespace: api.NamespaceSystem,
|
Namespace: api.NamespaceSystem,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"lable_sig": "foo_pod",
|
"lable_sig": "foo_pod",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: api_v1.PodSpec{
|
Spec: apiv1.PodSpec{
|
||||||
NodeName: "foo_node_2",
|
NodeName: "foo_node_2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
&api_v1.ServiceList{Items: []api_v1.Service{
|
&apiv1.ServiceList{Items: []apiv1.Service{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Status: api_v1.ServiceStatus{
|
Status: apiv1.ServiceStatus{
|
||||||
LoadBalancer: api_v1.LoadBalancerStatus{
|
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||||
Ingress: buildLoadBalancerIngressByIP(),
|
Ingress: buildLoadBalancerIngressByIP(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_non_exist",
|
Name: "foo_non_exist",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
&api_v1.NodeList{Items: []api_v1.Node{
|
&apiv1.NodeList{Items: []apiv1.Node{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_node_1",
|
Name: "foo_node_1",
|
||||||
},
|
},
|
||||||
Status: api_v1.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api_v1.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api_v1.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
}, {
|
}, {
|
||||||
Type: api_v1.NodeExternalIP,
|
Type: apiv1.NodeExternalIP,
|
||||||
Address: "10.0.0.2",
|
Address: "10.0.0.2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_node_2",
|
Name: "foo_node_2",
|
||||||
},
|
},
|
||||||
Status: api_v1.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api_v1.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api_v1.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "11.0.0.1",
|
Address: "11.0.0.1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: api_v1.NodeExternalIP,
|
Type: apiv1.NodeExternalIP,
|
||||||
Address: "11.0.0.2",
|
Address: "11.0.0.2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
&api_v1.EndpointsList{Items: []api_v1.Endpoints{
|
&apiv1.EndpointsList{Items: []apiv1.Endpoints{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "ingress-controller-leader",
|
Name: "ingress-controller-leader",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
SelfLink: "/api/v1/namespaces/default/endpoints/ingress-controller-leader",
|
SelfLink: "/api/v1/namespaces/default/endpoints/ingress-controller-leader",
|
||||||
},
|
},
|
||||||
}}},
|
}}},
|
||||||
|
@ -166,13 +166,13 @@ func fakeSynFn(interface{}) error {
|
||||||
func buildExtensionsIngresses() []extensions.Ingress {
|
func buildExtensionsIngresses() []extensions.Ingress {
|
||||||
return []extensions.Ingress{
|
return []extensions.Ingress{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_ingress_1",
|
Name: "foo_ingress_1",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Status: extensions.IngressStatus{
|
Status: extensions.IngressStatus{
|
||||||
LoadBalancer: api_v1.LoadBalancerStatus{
|
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||||
Ingress: []api_v1.LoadBalancerIngress{
|
Ingress: []apiv1.LoadBalancerIngress{
|
||||||
{
|
{
|
||||||
IP: "10.0.0.1",
|
IP: "10.0.0.1",
|
||||||
Hostname: "foo1",
|
Hostname: "foo1",
|
||||||
|
@ -182,7 +182,7 @@ func buildExtensionsIngresses() []extensions.Ingress {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_ingress_different_class",
|
Name: "foo_ingress_different_class",
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
@ -190,8 +190,8 @@ func buildExtensionsIngresses() []extensions.Ingress {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: extensions.IngressStatus{
|
Status: extensions.IngressStatus{
|
||||||
LoadBalancer: api_v1.LoadBalancerStatus{
|
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||||
Ingress: []api_v1.LoadBalancerIngress{
|
Ingress: []apiv1.LoadBalancerIngress{
|
||||||
{
|
{
|
||||||
IP: "0.0.0.0",
|
IP: "0.0.0.0",
|
||||||
Hostname: "foo.bar.com",
|
Hostname: "foo.bar.com",
|
||||||
|
@ -201,45 +201,45 @@ func buildExtensionsIngresses() []extensions.Ingress {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_ingress_2",
|
Name: "foo_ingress_2",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Status: extensions.IngressStatus{
|
Status: extensions.IngressStatus{
|
||||||
LoadBalancer: api_v1.LoadBalancerStatus{
|
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||||
Ingress: []api_v1.LoadBalancerIngress{},
|
Ingress: []apiv1.LoadBalancerIngress{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildIngressListener() cache_store.IngressLister {
|
func buildIngressListener() store.IngressLister {
|
||||||
store := cache.NewStore(cache.MetaNamespaceKeyFunc)
|
s := cache.NewStore(cache.MetaNamespaceKeyFunc)
|
||||||
store.Add(&extensions.Ingress{
|
s.Add(&extensions.Ingress{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_ingress_non_01",
|
Name: "foo_ingress_non_01",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
}})
|
}})
|
||||||
store.Add(&extensions.Ingress{
|
s.Add(&extensions.Ingress{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo_ingress_1",
|
Name: "foo_ingress_1",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Status: extensions.IngressStatus{
|
Status: extensions.IngressStatus{
|
||||||
LoadBalancer: api_v1.LoadBalancerStatus{
|
LoadBalancer: apiv1.LoadBalancerStatus{
|
||||||
Ingress: buildLoadBalancerIngressByIP(),
|
Ingress: buildLoadBalancerIngressByIP(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return cache_store.IngressLister{Store: store}
|
return store.IngressLister{Store: s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildStatusSync() statusSync {
|
func buildStatusSync() statusSync {
|
||||||
return statusSync{
|
return statusSync{
|
||||||
pod: &k8s.PodInfo{
|
pod: &k8s.PodInfo{
|
||||||
Name: "foo_base_pod",
|
Name: "foo_base_pod",
|
||||||
Namespace: api_v1.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"lable_sig": "foo_pod",
|
"lable_sig": "foo_pod",
|
||||||
},
|
},
|
||||||
|
@ -247,9 +247,9 @@ func buildStatusSync() statusSync {
|
||||||
syncQueue: task.NewTaskQueue(fakeSynFn),
|
syncQueue: task.NewTaskQueue(fakeSynFn),
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Client: buildSimpleClientSet(),
|
Client: buildSimpleClientSet(),
|
||||||
PublishService: api_v1.NamespaceDefault + "/" + "foo",
|
PublishService: apiv1.NamespaceDefault + "/" + "foo",
|
||||||
IngressLister: buildIngressListener(),
|
IngressLister: buildIngressListener(),
|
||||||
CustomIngressStatus: func(*extensions.Ingress) []api_v1.LoadBalancerIngress {
|
CustomIngressStatus: func(*extensions.Ingress) []apiv1.LoadBalancerIngress {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -259,7 +259,7 @@ func buildStatusSync() statusSync {
|
||||||
func TestStatusActions(t *testing.T) {
|
func TestStatusActions(t *testing.T) {
|
||||||
// make sure election can be created
|
// make sure election can be created
|
||||||
os.Setenv("POD_NAME", "foo1")
|
os.Setenv("POD_NAME", "foo1")
|
||||||
os.Setenv("POD_NAMESPACE", api_v1.NamespaceDefault)
|
os.Setenv("POD_NAMESPACE", apiv1.NamespaceDefault)
|
||||||
c := Config{
|
c := Config{
|
||||||
Client: buildSimpleClientSet(),
|
Client: buildSimpleClientSet(),
|
||||||
PublishService: "",
|
PublishService: "",
|
||||||
|
@ -267,7 +267,7 @@ func TestStatusActions(t *testing.T) {
|
||||||
DefaultIngressClass: "nginx",
|
DefaultIngressClass: "nginx",
|
||||||
IngressClass: "",
|
IngressClass: "",
|
||||||
UpdateStatusOnShutdown: true,
|
UpdateStatusOnShutdown: true,
|
||||||
CustomIngressStatus: func(*extensions.Ingress) []api_v1.LoadBalancerIngress {
|
CustomIngressStatus: func(*extensions.Ingress) []apiv1.LoadBalancerIngress {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -288,10 +288,10 @@ func TestStatusActions(t *testing.T) {
|
||||||
fk.sync("just-test")
|
fk.sync("just-test")
|
||||||
// PublishService is empty, so the running address is: ["11.0.0.2"]
|
// PublishService is empty, so the running address is: ["11.0.0.2"]
|
||||||
// after updated, the ingress's ip should only be "11.0.0.2"
|
// after updated, the ingress's ip should only be "11.0.0.2"
|
||||||
newIPs := []api_v1.LoadBalancerIngress{{
|
newIPs := []apiv1.LoadBalancerIngress{{
|
||||||
IP: "11.0.0.2",
|
IP: "11.0.0.2",
|
||||||
}}
|
}}
|
||||||
fooIngress1, err1 := fk.Client.Extensions().Ingresses(api_v1.NamespaceDefault).Get("foo_ingress_1", meta_v1.GetOptions{})
|
fooIngress1, err1 := fk.Client.Extensions().Ingresses(apiv1.NamespaceDefault).Get("foo_ingress_1", metav1.GetOptions{})
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
t.Fatalf("unexpected error")
|
t.Fatalf("unexpected error")
|
||||||
}
|
}
|
||||||
|
@ -303,8 +303,8 @@ func TestStatusActions(t *testing.T) {
|
||||||
// execute shutdown
|
// execute shutdown
|
||||||
fk.Shutdown()
|
fk.Shutdown()
|
||||||
// ingress should be empty
|
// ingress should be empty
|
||||||
newIPs2 := []api_v1.LoadBalancerIngress{}
|
newIPs2 := []apiv1.LoadBalancerIngress{}
|
||||||
fooIngress2, err2 := fk.Client.Extensions().Ingresses(api_v1.NamespaceDefault).Get("foo_ingress_1", meta_v1.GetOptions{})
|
fooIngress2, err2 := fk.Client.Extensions().Ingresses(apiv1.NamespaceDefault).Get("foo_ingress_1", metav1.GetOptions{})
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
t.Fatalf("unexpected error")
|
t.Fatalf("unexpected error")
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ func TestStatusActions(t *testing.T) {
|
||||||
t.Fatalf("returned %v but expected %v", fooIngress2CurIPs, newIPs2)
|
t.Fatalf("returned %v but expected %v", fooIngress2CurIPs, newIPs2)
|
||||||
}
|
}
|
||||||
|
|
||||||
oic, err := fk.Client.Extensions().Ingresses(api.NamespaceDefault).Get("foo_ingress_different_class", meta_v1.GetOptions{})
|
oic, err := fk.Client.Extensions().Ingresses(api.NamespaceDefault).Get("foo_ingress_different_class", metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error")
|
t.Fatalf("unexpected error")
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ func TestUpdateStatus(t *testing.T) {
|
||||||
sort.Sort(loadBalancerIngressByIP(newIPs))
|
sort.Sort(loadBalancerIngressByIP(newIPs))
|
||||||
fk.updateStatus(newIPs)
|
fk.updateStatus(newIPs)
|
||||||
|
|
||||||
fooIngress1, err1 := fk.Client.Extensions().Ingresses(api_v1.NamespaceDefault).Get("foo_ingress_1", meta_v1.GetOptions{})
|
fooIngress1, err1 := fk.Client.Extensions().Ingresses(apiv1.NamespaceDefault).Get("foo_ingress_1", metav1.GetOptions{})
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
t.Fatalf("unexpected error")
|
t.Fatalf("unexpected error")
|
||||||
}
|
}
|
||||||
|
@ -388,13 +388,13 @@ func TestUpdateStatus(t *testing.T) {
|
||||||
t.Fatalf("returned %v but expected %v", fooIngress1CurIPs, newIPs)
|
t.Fatalf("returned %v but expected %v", fooIngress1CurIPs, newIPs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fooIngress2, err2 := fk.Client.Extensions().Ingresses(api_v1.NamespaceDefault).Get("foo_ingress_2", meta_v1.GetOptions{})
|
fooIngress2, err2 := fk.Client.Extensions().Ingresses(apiv1.NamespaceDefault).Get("foo_ingress_2", metav1.GetOptions{})
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
t.Fatalf("unexpected error")
|
t.Fatalf("unexpected error")
|
||||||
}
|
}
|
||||||
fooIngress2CurIPs := fooIngress2.Status.LoadBalancer.Ingress
|
fooIngress2CurIPs := fooIngress2.Status.LoadBalancer.Ingress
|
||||||
if !ingressSliceEqual(fooIngress2CurIPs, []api_v1.LoadBalancerIngress{}) {
|
if !ingressSliceEqual(fooIngress2CurIPs, []apiv1.LoadBalancerIngress{}) {
|
||||||
t.Fatalf("returned %v but expected %v", fooIngress2CurIPs, []api_v1.LoadBalancerIngress{})
|
t.Fatalf("returned %v but expected %v", fooIngress2CurIPs, []apiv1.LoadBalancerIngress{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ func TestSliceToStatus(t *testing.T) {
|
||||||
r := sliceToStatus(fkEndpoints)
|
r := sliceToStatus(fkEndpoints)
|
||||||
|
|
||||||
if r == nil {
|
if r == nil {
|
||||||
t.Fatalf("returned nil but expected a valid []api_v1.LoadBalancerIngress")
|
t.Fatalf("returned nil but expected a valid []apiv1.LoadBalancerIngress")
|
||||||
}
|
}
|
||||||
rl := len(r)
|
rl := len(r)
|
||||||
if rl != 3 {
|
if rl != 3 {
|
||||||
|
@ -416,21 +416,21 @@ func TestSliceToStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
re1 := r[0]
|
re1 := r[0]
|
||||||
if re1.Hostname != "opensource-k8s-ingress" {
|
if re1.Hostname != "opensource-k8s-ingress" {
|
||||||
t.Fatalf("returned %v but expected %v", re1, api_v1.LoadBalancerIngress{Hostname: "opensource-k8s-ingress"})
|
t.Fatalf("returned %v but expected %v", re1, apiv1.LoadBalancerIngress{Hostname: "opensource-k8s-ingress"})
|
||||||
}
|
}
|
||||||
re2 := r[1]
|
re2 := r[1]
|
||||||
if re2.IP != "10.0.0.1" {
|
if re2.IP != "10.0.0.1" {
|
||||||
t.Fatalf("returned %v but expected %v", re2, api_v1.LoadBalancerIngress{IP: "10.0.0.1"})
|
t.Fatalf("returned %v but expected %v", re2, apiv1.LoadBalancerIngress{IP: "10.0.0.1"})
|
||||||
}
|
}
|
||||||
re3 := r[2]
|
re3 := r[2]
|
||||||
if re3.IP != "2001:db8::68" {
|
if re3.IP != "2001:db8::68" {
|
||||||
t.Fatalf("returned %v but expected %v", re3, api_v1.LoadBalancerIngress{IP: "2001:db8::68"})
|
t.Fatalf("returned %v but expected %v", re3, apiv1.LoadBalancerIngress{IP: "2001:db8::68"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIngressSliceEqual(t *testing.T) {
|
func TestIngressSliceEqual(t *testing.T) {
|
||||||
fk1 := buildLoadBalancerIngressByIP()
|
fk1 := buildLoadBalancerIngressByIP()
|
||||||
fk2 := append(buildLoadBalancerIngressByIP(), api_v1.LoadBalancerIngress{
|
fk2 := append(buildLoadBalancerIngressByIP(), apiv1.LoadBalancerIngress{
|
||||||
IP: "10.0.0.5",
|
IP: "10.0.0.5",
|
||||||
Hostname: "foo5",
|
Hostname: "foo5",
|
||||||
})
|
})
|
||||||
|
@ -440,8 +440,8 @@ func TestIngressSliceEqual(t *testing.T) {
|
||||||
fk4[2].IP = "11.0.0.3"
|
fk4[2].IP = "11.0.0.3"
|
||||||
|
|
||||||
fooTests := []struct {
|
fooTests := []struct {
|
||||||
lhs []api_v1.LoadBalancerIngress
|
lhs []apiv1.LoadBalancerIngress
|
||||||
rhs []api_v1.LoadBalancerIngress
|
rhs []apiv1.LoadBalancerIngress
|
||||||
er bool
|
er bool
|
||||||
}{
|
}{
|
||||||
{fk1, fk1, true},
|
{fk1, fk1, true},
|
||||||
|
@ -450,7 +450,7 @@ func TestIngressSliceEqual(t *testing.T) {
|
||||||
{fk4, fk1, false},
|
{fk4, fk1, false},
|
||||||
{fk1, nil, false},
|
{fk1, nil, false},
|
||||||
{nil, nil, true},
|
{nil, nil, true},
|
||||||
{[]api_v1.LoadBalancerIngress{}, []api_v1.LoadBalancerIngress{}, true},
|
{[]apiv1.LoadBalancerIngress{}, []apiv1.LoadBalancerIngress{}, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, fooTest := range fooTests {
|
for _, fooTest := range fooTests {
|
||||||
|
@ -466,7 +466,7 @@ func TestLoadBalancerIngressByIPLen(t *testing.T) {
|
||||||
ips loadBalancerIngressByIP
|
ips loadBalancerIngressByIP
|
||||||
el int
|
el int
|
||||||
}{
|
}{
|
||||||
{[]api_v1.LoadBalancerIngress{}, 0},
|
{[]apiv1.LoadBalancerIngress{}, 0},
|
||||||
{buildLoadBalancerIngressByIP(), 4},
|
{buildLoadBalancerIngressByIP(), 4},
|
||||||
{nil, 0},
|
{nil, 0},
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
|
@ -78,7 +78,7 @@ type Controller interface {
|
||||||
//
|
//
|
||||||
OnUpdate(Configuration) error
|
OnUpdate(Configuration) error
|
||||||
// ConfigMap content of --configmap
|
// ConfigMap content of --configmap
|
||||||
SetConfig(*api.ConfigMap)
|
SetConfig(*apiv1.ConfigMap)
|
||||||
// SetListers allows the access of store listers present in the generic controller
|
// SetListers allows the access of store listers present in the generic controller
|
||||||
// This avoid the use of the kubernetes client.
|
// This avoid the use of the kubernetes client.
|
||||||
SetListers(StoreLister)
|
SetListers(StoreLister)
|
||||||
|
@ -97,7 +97,7 @@ type Controller interface {
|
||||||
// UpdateIngressStatus custom callback used to update the status in an Ingress rule
|
// UpdateIngressStatus custom callback used to update the status in an Ingress rule
|
||||||
// This allows custom implementations
|
// This allows custom implementations
|
||||||
// If the function returns nil the standard functions will be executed.
|
// If the function returns nil the standard functions will be executed.
|
||||||
UpdateIngressStatus(*extensions.Ingress) []api.LoadBalancerIngress
|
UpdateIngressStatus(*extensions.Ingress) []apiv1.LoadBalancerIngress
|
||||||
// DefaultEndpoint returns the Endpoint to use as default when the
|
// DefaultEndpoint returns the Endpoint to use as default when the
|
||||||
// referenced service does not exists. This should return the content
|
// referenced service does not exists. This should return the content
|
||||||
// of to the default backend
|
// of to the default backend
|
||||||
|
@ -152,9 +152,9 @@ type Configuration struct {
|
||||||
// Backend describes one or more remote server/s (endpoints) associated with a service
|
// Backend describes one or more remote server/s (endpoints) associated with a service
|
||||||
// +k8s:deepcopy-gen=true
|
// +k8s:deepcopy-gen=true
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
// Name represents an unique api.Service name formatted as <namespace>-<name>-<port>
|
// Name represents an unique apiv1.Service name formatted as <namespace>-<name>-<port>
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Service *api.Service `json:"service,omitempty"`
|
Service *apiv1.Service `json:"service,omitempty"`
|
||||||
Port intstr.IntOrString `json:"port"`
|
Port intstr.IntOrString `json:"port"`
|
||||||
// This indicates if the communication protocol between the backend and the endpoint is HTTP or HTTPS
|
// This indicates if the communication protocol between the backend and the endpoint is HTTP or HTTPS
|
||||||
// Allowing the use of HTTPS
|
// Allowing the use of HTTPS
|
||||||
|
@ -208,7 +208,7 @@ type Endpoint struct {
|
||||||
// to consider the endpoint unavailable
|
// to consider the endpoint unavailable
|
||||||
FailTimeout int `json:"failTimeout"`
|
FailTimeout int `json:"failTimeout"`
|
||||||
// Target returns a reference to the object providing the endpoint
|
// Target returns a reference to the object providing the endpoint
|
||||||
Target *api.ObjectReference `json:"target,omipempty"`
|
Target *apiv1.ObjectReference `json:"target,omipempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server describes a website
|
// Server describes a website
|
||||||
|
@ -270,7 +270,7 @@ type Location struct {
|
||||||
// Backend describes the name of the backend to use.
|
// Backend describes the name of the backend to use.
|
||||||
Backend string `json:"backend"`
|
Backend string `json:"backend"`
|
||||||
// Service describes the referenced services from the ingress
|
// Service describes the referenced services from the ingress
|
||||||
Service *api.Service `json:"service,omitempty"`
|
Service *apiv1.Service `json:"service,omitempty"`
|
||||||
// Port describes to which port from the service
|
// Port describes to which port from the service
|
||||||
Port intstr.IntOrString `json:"port"`
|
Port intstr.IntOrString `json:"port"`
|
||||||
// Overwrite the Host header passed into the backend. Defaults to
|
// Overwrite the Host header passed into the backend. Defaults to
|
||||||
|
@ -326,7 +326,7 @@ type Location struct {
|
||||||
ClientBodyBufferSize string `json:"clientBodyBufferSize,omitempty"`
|
ClientBodyBufferSize string `json:"clientBodyBufferSize,omitempty"`
|
||||||
// DefaultBackend allows the use of a custom default backend for this location.
|
// DefaultBackend allows the use of a custom default backend for this location.
|
||||||
// +optional
|
// +optional
|
||||||
DefaultBackend *api.Service `json:"defaultBackend,omitempty"`
|
DefaultBackend *apiv1.Service `json:"defaultBackend,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSLPassthroughBackend describes a SSL upstream server configured
|
// SSLPassthroughBackend describes a SSL upstream server configured
|
||||||
|
@ -334,7 +334,7 @@ type Location struct {
|
||||||
// The endpoints must provide the TLS termination exposing the required SSL certificate.
|
// The endpoints must provide the TLS termination exposing the required SSL certificate.
|
||||||
// The ingress controller only pipes the underlying TCP connection
|
// The ingress controller only pipes the underlying TCP connection
|
||||||
type SSLPassthroughBackend struct {
|
type SSLPassthroughBackend struct {
|
||||||
Service *api.Service `json:"service,omitEmpty"`
|
Service *apiv1.Service `json:"service,omitEmpty"`
|
||||||
Port intstr.IntOrString `json:"port"`
|
Port intstr.IntOrString `json:"port"`
|
||||||
// Backend describes the endpoints to use.
|
// Backend describes the endpoints to use.
|
||||||
Backend string `json:"namespace,omitempty"`
|
Backend string `json:"namespace,omitempty"`
|
||||||
|
@ -357,7 +357,7 @@ type L4Backend struct {
|
||||||
Port intstr.IntOrString `json:"port"`
|
Port intstr.IntOrString `json:"port"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Namespace string `json:"namespace"`
|
Namespace string `json:"namespace"`
|
||||||
Protocol api.Protocol `json:"protocol"`
|
Protocol apiv1.Protocol `json:"protocol"`
|
||||||
// +optional
|
// +optional
|
||||||
UseProxyProtocol bool `json:"useProxyProtocol"`
|
UseProxyProtocol bool `json:"useProxyProtocol"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,20 +39,20 @@ func ParseNameNS(input string) (string, string, error) {
|
||||||
// GetNodeIP returns the IP address of a node in the cluster
|
// GetNodeIP returns the IP address of a node in the cluster
|
||||||
func GetNodeIP(kubeClient clientset.Interface, name string) string {
|
func GetNodeIP(kubeClient clientset.Interface, name string) string {
|
||||||
var externalIP string
|
var externalIP string
|
||||||
node, err := kubeClient.Core().Nodes().Get(name, meta_v1.GetOptions{})
|
node, err := kubeClient.Core().Nodes().Get(name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return externalIP
|
return externalIP
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, address := range node.Status.Addresses {
|
for _, address := range node.Status.Addresses {
|
||||||
if address.Type == api.NodeExternalIP {
|
if address.Type == apiv1.NodeExternalIP {
|
||||||
if address.Address != "" {
|
if address.Address != "" {
|
||||||
externalIP = address.Address
|
externalIP = address.Address
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if externalIP == "" && address.Type == api.NodeInternalIP {
|
if externalIP == "" && address.Type == apiv1.NodeInternalIP {
|
||||||
externalIP = address.Address
|
externalIP = address.Address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func GetPodDetails(kubeClient clientset.Interface) (*PodInfo, error) {
|
||||||
return nil, fmt.Errorf("unable to get POD information (missing POD_NAME or POD_NAMESPACE environment variable")
|
return nil, fmt.Errorf("unable to get POD information (missing POD_NAME or POD_NAMESPACE environment variable")
|
||||||
}
|
}
|
||||||
|
|
||||||
pod, _ := kubeClient.Core().Pods(podNs).Get(podName, meta_v1.GetOptions{})
|
pod, _ := kubeClient.Core().Pods(podNs).Get(podName, metav1.GetOptions{})
|
||||||
if pod == nil {
|
if pod == nil {
|
||||||
return nil, fmt.Errorf("unable to get POD information")
|
return nil, fmt.Errorf("unable to get POD information")
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
api "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
testclient "k8s.io/client-go/kubernetes/fake"
|
testclient "k8s.io/client-go/kubernetes/fake"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,14 +66,14 @@ func TestGetNodeIP(t *testing.T) {
|
||||||
{testclient.NewSimpleClientset(), "demo", ""},
|
{testclient.NewSimpleClientset(), "demo", ""},
|
||||||
|
|
||||||
// node not exist
|
// node not exist
|
||||||
{testclient.NewSimpleClientset(&api.NodeList{Items: []api.Node{{
|
{testclient.NewSimpleClientset(&apiv1.NodeList{Items: []apiv1.Node{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -81,14 +81,14 @@ func TestGetNodeIP(t *testing.T) {
|
||||||
}}}), "notexistnode", ""},
|
}}}), "notexistnode", ""},
|
||||||
|
|
||||||
// node exist
|
// node exist
|
||||||
{testclient.NewSimpleClientset(&api.NodeList{Items: []api.Node{{
|
{testclient.NewSimpleClientset(&apiv1.NodeList{Items: []apiv1.Node{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -96,28 +96,28 @@ func TestGetNodeIP(t *testing.T) {
|
||||||
}}}), "demo", "10.0.0.1"},
|
}}}), "demo", "10.0.0.1"},
|
||||||
|
|
||||||
// search the correct node
|
// search the correct node
|
||||||
{testclient.NewSimpleClientset(&api.NodeList{Items: []api.Node{
|
{testclient.NewSimpleClientset(&apiv1.NodeList{Items: []apiv1.Node{
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo1",
|
Name: "demo1",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo2",
|
Name: "demo2",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.2",
|
Address: "10.0.0.2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -126,17 +126,17 @@ func TestGetNodeIP(t *testing.T) {
|
||||||
}}), "demo2", "10.0.0.2"},
|
}}), "demo2", "10.0.0.2"},
|
||||||
|
|
||||||
// get NodeExternalIP
|
// get NodeExternalIP
|
||||||
{testclient.NewSimpleClientset(&api.NodeList{Items: []api.Node{{
|
{testclient.NewSimpleClientset(&apiv1.NodeList{Items: []apiv1.Node{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
}, {
|
}, {
|
||||||
Type: api.NodeExternalIP,
|
Type: apiv1.NodeExternalIP,
|
||||||
Address: "10.0.0.2",
|
Address: "10.0.0.2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -144,17 +144,17 @@ func TestGetNodeIP(t *testing.T) {
|
||||||
}}}), "demo", "10.0.0.2"},
|
}}}), "demo", "10.0.0.2"},
|
||||||
|
|
||||||
// get NodeInternalIP
|
// get NodeInternalIP
|
||||||
{testclient.NewSimpleClientset(&api.NodeList{Items: []api.Node{{
|
{testclient.NewSimpleClientset(&apiv1.NodeList{Items: []apiv1.Node{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeExternalIP,
|
Type: apiv1.NodeExternalIP,
|
||||||
Address: "",
|
Address: "",
|
||||||
}, {
|
}, {
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.2",
|
Address: "10.0.0.2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -181,7 +181,7 @@ func TestGetPodDetails(t *testing.T) {
|
||||||
|
|
||||||
// POD_NAME not exist
|
// POD_NAME not exist
|
||||||
os.Setenv("POD_NAME", "")
|
os.Setenv("POD_NAME", "")
|
||||||
os.Setenv("POD_NAMESPACE", api.NamespaceDefault)
|
os.Setenv("POD_NAMESPACE", apiv1.NamespaceDefault)
|
||||||
_, err2 := GetPodDetails(testclient.NewSimpleClientset())
|
_, err2 := GetPodDetails(testclient.NewSimpleClientset())
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
t.Errorf("expected an error but returned nil")
|
t.Errorf("expected an error but returned nil")
|
||||||
|
@ -197,7 +197,7 @@ func TestGetPodDetails(t *testing.T) {
|
||||||
|
|
||||||
// POD not exist
|
// POD not exist
|
||||||
os.Setenv("POD_NAME", "testpod")
|
os.Setenv("POD_NAME", "testpod")
|
||||||
os.Setenv("POD_NAMESPACE", api.NamespaceDefault)
|
os.Setenv("POD_NAMESPACE", apiv1.NamespaceDefault)
|
||||||
_, err4 := GetPodDetails(testclient.NewSimpleClientset())
|
_, err4 := GetPodDetails(testclient.NewSimpleClientset())
|
||||||
if err4 == nil {
|
if err4 == nil {
|
||||||
t.Errorf("expected an error but returned nil")
|
t.Errorf("expected an error but returned nil")
|
||||||
|
@ -205,24 +205,24 @@ func TestGetPodDetails(t *testing.T) {
|
||||||
|
|
||||||
// success to get PodInfo
|
// success to get PodInfo
|
||||||
fkClient := testclient.NewSimpleClientset(
|
fkClient := testclient.NewSimpleClientset(
|
||||||
&api.PodList{Items: []api.Pod{{
|
&apiv1.PodList{Items: []apiv1.Pod{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "testpod",
|
Name: "testpod",
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: apiv1.NamespaceDefault,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"first": "first_label",
|
"first": "first_label",
|
||||||
"second": "second_label",
|
"second": "second_label",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}},
|
}}},
|
||||||
&api.NodeList{Items: []api.Node{{
|
&apiv1.NodeList{Items: []apiv1.Node{{
|
||||||
ObjectMeta: meta_v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "demo",
|
Name: "demo",
|
||||||
},
|
},
|
||||||
Status: api.NodeStatus{
|
Status: apiv1.NodeStatus{
|
||||||
Addresses: []api.NodeAddress{
|
Addresses: []apiv1.NodeAddress{
|
||||||
{
|
{
|
||||||
Type: api.NodeInternalIP,
|
Type: apiv1.NodeInternalIP,
|
||||||
Address: "10.0.0.1",
|
Address: "10.0.0.1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,6 +36,7 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/file"
|
"k8s.io/ingress/core/pkg/file"
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
|
|
||||||
certutil "k8s.io/client-go/util/cert"
|
certutil "k8s.io/client-go/util/cert"
|
||||||
"k8s.io/client-go/util/cert/triple"
|
"k8s.io/client-go/util/cert/triple"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue