1
This commit is contained in:
parent
d3ddd4afbc
commit
5b7b3b56d4
2 changed files with 26 additions and 25 deletions
|
@ -31,7 +31,6 @@ import (
|
||||||
|
|
||||||
apiv1 "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/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
@ -54,15 +53,6 @@ const (
|
||||||
rootLocation = "/"
|
rootLocation = "/"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
cloner *conversion.Cloner
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
cloner := conversion.NewCloner()
|
|
||||||
cloner.RegisterDeepCopyFunc(ingress.GetGeneratedDeepCopyFuncs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configuration contains all the settings required by an Ingress controller
|
// Configuration contains all the settings required by an Ingress controller
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
APIServerHost string
|
APIServerHost string
|
||||||
|
@ -446,6 +436,8 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([]
|
||||||
loc.VtsFilterKey = anns.VtsFilterKey
|
loc.VtsFilterKey = anns.VtsFilterKey
|
||||||
loc.Whitelist = anns.Whitelist
|
loc.Whitelist = anns.Whitelist
|
||||||
loc.Denied = anns.Denied
|
loc.Denied = anns.Denied
|
||||||
|
loc.XForwardedPrefix = anns.XForwardedPrefix
|
||||||
|
loc.UsePortInRedirects = anns.UsePortInRedirects
|
||||||
|
|
||||||
if loc.Redirect.FromToWWW {
|
if loc.Redirect.FromToWWW {
|
||||||
server.RedirectFromToWWW = true
|
server.RedirectFromToWWW = true
|
||||||
|
@ -476,6 +468,8 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([]
|
||||||
VtsFilterKey: anns.VtsFilterKey,
|
VtsFilterKey: anns.VtsFilterKey,
|
||||||
Whitelist: anns.Whitelist,
|
Whitelist: anns.Whitelist,
|
||||||
Denied: anns.Denied,
|
Denied: anns.Denied,
|
||||||
|
XForwardedPrefix: anns.XForwardedPrefix,
|
||||||
|
UsePortInRedirects: anns.UsePortInRedirects,
|
||||||
}
|
}
|
||||||
|
|
||||||
if loc.Redirect.FromToWWW {
|
if loc.Redirect.FromToWWW {
|
||||||
|
@ -521,12 +515,8 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([]
|
||||||
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)
|
||||||
b, err := cloner.DeepCopy(upstream)
|
nb := upstream.DeepCopy()
|
||||||
if err != nil {
|
|
||||||
glog.Errorf("unexpected error copying Upstream: %v", err)
|
|
||||||
} else {
|
|
||||||
name := fmt.Sprintf("custom-default-backend-%v", upstream.Name)
|
name := fmt.Sprintf("custom-default-backend-%v", upstream.Name)
|
||||||
nb := b.(*ingress.Backend)
|
|
||||||
nb.Name = name
|
nb.Name = name
|
||||||
nb.Endpoints = endps
|
nb.Endpoints = endps
|
||||||
aUpstreams = append(aUpstreams, nb)
|
aUpstreams = append(aUpstreams, nb)
|
||||||
|
@ -534,7 +524,6 @@ func (n *NGINXController) getBackendServers(ingresses []*extensions.Ingress) ([]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Configure Backends[].SSLPassthrough
|
// Configure Backends[].SSLPassthrough
|
||||||
if server.SSLPassthrough {
|
if server.SSLPassthrough {
|
||||||
|
@ -1186,19 +1175,22 @@ func (n *NGINXController) SetForceReload(shouldReload bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NGINXController) extractAnnotations(ing *extensions.Ingress) {
|
func (n *NGINXController) extractAnnotations(ing *extensions.Ingress) {
|
||||||
|
glog.V(3).Infof("updating annotations information for ingress %v/%v", ing.Namespace, ing.Name)
|
||||||
anns := n.annotations.Extract(ing)
|
anns := n.annotations.Extract(ing)
|
||||||
glog.V(3).Infof("updating annotations information for ingress %v/%v", anns.Namespace, anns.Name)
|
err := n.store.UpdateIngressAnnotation(anns)
|
||||||
n.store.UpdateIngressAnnotation(anns)
|
if err != nil {
|
||||||
|
glog.Errorf("unexpected error updating annotations information for ingress %v/%v: %v", anns.Namespace, anns.Name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getByIngress returns the parsed annotations from an Ingress
|
// getByIngress returns the parsed annotations from an Ingress
|
||||||
func (n *NGINXController) getIngressAnnotations(ing *extensions.Ingress) *annotations.Ingress {
|
func (n *NGINXController) getIngressAnnotations(ing *extensions.Ingress) *annotations.Ingress {
|
||||||
key := fmt.Sprintf("%v/%v", ing.Namespace, ing.Name)
|
key := fmt.Sprintf("%v/%v", ing.Namespace, ing.Name)
|
||||||
item, err := n.listers.IngressAnnotation.GetByKey(key)
|
item, err := n.store.GetIngressAnnotations(ing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("unexpected error getting ingress annotation %v: %v", key, err)
|
glog.Errorf("unexpected error getting ingress annotation %v: %v", key, err)
|
||||||
return &annotations.Ingress{}
|
return &annotations.Ingress{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.(*annotations.Ingress)
|
return item
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,9 @@ type Storer interface {
|
||||||
// GetIngressAnnotations returns the annotations associated to an Ingress
|
// GetIngressAnnotations returns the annotations associated to an Ingress
|
||||||
GetIngressAnnotations(ing *extensions.Ingress) (*annotations.Ingress, error)
|
GetIngressAnnotations(ing *extensions.Ingress) (*annotations.Ingress, error)
|
||||||
|
|
||||||
|
// UpdateIngressAnnotations updates the annotations associated to an Ingress
|
||||||
|
UpdateIngressAnnotations(ing *annotations.Ingress) error
|
||||||
|
|
||||||
// GetLocalSecret returns the local copy of a Secret
|
// GetLocalSecret returns the local copy of a Secret
|
||||||
GetLocalSecret(name string) (*ingress.SSLCert, error)
|
GetLocalSecret(name string) (*ingress.SSLCert, error)
|
||||||
|
|
||||||
|
@ -450,6 +453,12 @@ func (s k8sStore) GetIngressAnnotations(ing *extensions.Ingress) (*annotations.I
|
||||||
return item.(*annotations.Ingress), nil
|
return item.(*annotations.Ingress), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateIngressAnnotations updates the annotations associated to an Ingress
|
||||||
|
func (s k8sStore) UpdateIngressAnnotations(ing *annotations.Ingress) error {
|
||||||
|
key := fmt.Sprintf("%v/%v", ing.Namespace, ing.Name)
|
||||||
|
return s.listers.IngressAnnotation.Update(key)
|
||||||
|
}
|
||||||
|
|
||||||
// GetLocalSecret returns the local copy of a Secret
|
// GetLocalSecret returns the local copy of a Secret
|
||||||
func (s k8sStore) GetLocalSecret(key string) (*ingress.SSLCert, error) {
|
func (s k8sStore) GetLocalSecret(key string) (*ingress.SSLCert, error) {
|
||||||
return s.sslStore.ByKey(key)
|
return s.sslStore.ByKey(key)
|
||||||
|
|
Loading…
Reference in a new issue