nginx/proxy: allow specifying next upstream behaviour
This commit is contained in:
parent
1468fcb1aa
commit
5503e8d0e9
8 changed files with 47 additions and 4 deletions
|
|
@ -31,6 +31,7 @@ const (
|
|||
bufferSize = "ingress.kubernetes.io/proxy-buffer-size"
|
||||
cookiePath = "ingress.kubernetes.io/proxy-cookie-path"
|
||||
cookieDomain = "ingress.kubernetes.io/proxy-cookie-domain"
|
||||
nextUpstream = "ingress.kubernetes.io/proxy-next-upstream"
|
||||
)
|
||||
|
||||
// Configuration returns the proxy timeout to use in the upstream server/s
|
||||
|
|
@ -42,6 +43,7 @@ type Configuration struct {
|
|||
BufferSize string `json:"bufferSize"`
|
||||
CookieDomain string `json:"cookieDomain"`
|
||||
CookiePath string `json:"cookiePath"`
|
||||
NextUpstream string `json:"nextUpstream"`
|
||||
}
|
||||
|
||||
func (l1 *Configuration) Equal(l2 *Configuration) bool {
|
||||
|
|
@ -124,5 +126,10 @@ func (a proxy) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
bs = defBackend.ProxyBodySize
|
||||
}
|
||||
|
||||
return &Configuration{bs, ct, st, rt, bufs, cd, cp}, nil
|
||||
nu, err := parser.GetStringAnnotation(nextUpstream, ing)
|
||||
if err != nil || nu == "" {
|
||||
nu = defBackend.ProxyNextUpstream
|
||||
}
|
||||
|
||||
return &Configuration{bs, ct, st, rt, bufs, cd, cp, nu}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ func (m mockBackend) GetDefaultBackend() defaults.Backend {
|
|||
ProxyReadTimeout: 20,
|
||||
ProxyBufferSize: "10k",
|
||||
ProxyBodySize: "3k",
|
||||
ProxyNextUpstream: "error",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +86,7 @@ func TestProxy(t *testing.T) {
|
|||
data[read] = "3"
|
||||
data[bufferSize] = "1k"
|
||||
data[bodySize] = "2k"
|
||||
data[nextUpstream] = "off"
|
||||
ing.SetAnnotations(data)
|
||||
|
||||
i, err := NewParser(mockBackend{}).Parse(ing)
|
||||
|
|
@ -110,6 +112,9 @@ func TestProxy(t *testing.T) {
|
|||
if p.BodySize != "2k" {
|
||||
t.Errorf("expected 2k as body-size but returned %v", p.BodySize)
|
||||
}
|
||||
if p.NextUpstream != "off" {
|
||||
t.Errorf("expected off as next-upstream but returned %v", p.NextUpstream)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProxyWithNoAnnotation(t *testing.T) {
|
||||
|
|
@ -141,4 +146,7 @@ func TestProxyWithNoAnnotation(t *testing.T) {
|
|||
if p.BodySize != "3k" {
|
||||
t.Errorf("expected 3k as body-size but returned %v", p.BodySize)
|
||||
}
|
||||
if p.NextUpstream != "error" {
|
||||
t.Errorf("expected error as next-upstream but returned %v", p.NextUpstream)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -907,6 +907,7 @@ func (ic *GenericController) createServers(data []interface{},
|
|||
BufferSize: bdef.ProxyBufferSize,
|
||||
CookieDomain: bdef.ProxyCookieDomain,
|
||||
CookiePath: bdef.ProxyCookiePath,
|
||||
NextUpstream: bdef.ProxyNextUpstream,
|
||||
}
|
||||
|
||||
// This adds the Default Certificate to Default Backend (or generates a new self signed one)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ type Backend struct {
|
|||
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cookie_domain
|
||||
ProxyCookieDomain string `json:"proxy-cookie-domain"`
|
||||
|
||||
// Specifies in which cases a request should be passed to the next server.
|
||||
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
|
||||
ProxyNextUpstream string `json:"proxy-next-upstream"`
|
||||
|
||||
// Name server/s used to resolve names of upstream servers into IP addresses.
|
||||
// The file /etc/resolv.conf is used as DNS resolution configuration.
|
||||
Resolver []net.IP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue