Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy-pass-params annotation and Backend field #1278

Merged
merged 1 commit into from
Sep 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/pkg/ingress/annotations/proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
cookiePath = "ingress.kubernetes.io/proxy-cookie-path"
cookieDomain = "ingress.kubernetes.io/proxy-cookie-domain"
nextUpstream = "ingress.kubernetes.io/proxy-next-upstream"
passParams = "ingress.kubernetes.io/proxy-pass-params"
)

// Configuration returns the proxy timeout to use in the upstream server/s
Expand All @@ -44,6 +45,7 @@ type Configuration struct {
CookieDomain string `json:"cookieDomain"`
CookiePath string `json:"cookiePath"`
NextUpstream string `json:"nextUpstream"`
PassParams string `json:"passParams"`
}

// Equal tests for equality between two Configuration types
Expand Down Expand Up @@ -75,6 +77,12 @@ func (l1 *Configuration) Equal(l2 *Configuration) bool {
if l1.CookiePath != l2.CookiePath {
return false
}
if l1.NextUpstream != l2.NextUpstream {
return false
}
if l1.PassParams != l2.PassParams {
return false
}

return true
}
Expand Down Expand Up @@ -132,5 +140,10 @@ func (a proxy) Parse(ing *extensions.Ingress) (interface{}, error) {
nu = defBackend.ProxyNextUpstream
}

return &Configuration{bs, ct, st, rt, bufs, cd, cp, nu}, nil
pp, err := parser.GetStringAnnotation(passParams, ing)
if err != nil || pp == "" {
pp = defBackend.ProxyPassParams
}

return &Configuration{bs, ct, st, rt, bufs, cd, cp, nu, pp}, nil
}
8 changes: 8 additions & 0 deletions core/pkg/ingress/annotations/proxy/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (m mockBackend) GetDefaultBackend() defaults.Backend {
ProxyBufferSize: "10k",
ProxyBodySize: "3k",
ProxyNextUpstream: "error",
ProxyPassParams: "nocanon keepalive=On",
}
}

Expand All @@ -87,6 +88,7 @@ func TestProxy(t *testing.T) {
data[bufferSize] = "1k"
data[bodySize] = "2k"
data[nextUpstream] = "off"
data[passParams] = "smax=5 max=10"
ing.SetAnnotations(data)

i, err := NewParser(mockBackend{}).Parse(ing)
Expand Down Expand Up @@ -115,6 +117,9 @@ func TestProxy(t *testing.T) {
if p.NextUpstream != "off" {
t.Errorf("expected off as next-upstream but returned %v", p.NextUpstream)
}
if p.PassParams != "smax=5 max=10" {
t.Errorf("expected \"smax=5 max=10\" as pass-params but returned \"%v\"", p.PassParams)
}
}

func TestProxyWithNoAnnotation(t *testing.T) {
Expand Down Expand Up @@ -149,4 +154,7 @@ func TestProxyWithNoAnnotation(t *testing.T) {
if p.NextUpstream != "error" {
t.Errorf("expected error as next-upstream but returned %v", p.NextUpstream)
}
if p.PassParams != "nocanon keepalive=On" {
t.Errorf("expected \"nocanon keepalive=On\" as pass-params but returned \"%v\"", p.PassParams)
}
}
3 changes: 3 additions & 0 deletions core/pkg/ingress/defaults/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type Backend struct {
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
ProxyNextUpstream string `json:"proxy-next-upstream"`

// Parameters for proxy-pass directive (eg. Apache web server).
ProxyPassParams string `json:"proxy-pass-params"`

// 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
Expand Down
1 change: 1 addition & 0 deletions docs/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Key:
| `session-cookie-name` | When `affinity` is set to `cookie`, the name of the cookie to use. | | nginx
| `session-cookie-hash` | When `affinity` is set to `cookie`, the hash algorithm used: `md5`, `sha`, `index`. | | nginx
| `proxy-body-size` | Maximum request body size. | | nginx, haproxy
| `proxy-pass-params` | Parameters for proxy-pass directives. | |
| `follow-redirects` | Follow HTTP redirects in the response and deliver the redirect target to the client. | | trafficserver
| `kubernetes.io/ingress.global-static-ip-name` | Name of the static global IP address in GCP to use when provisioning the HTTPS load balancer. | empty string | gce

Expand Down