Skip to content

Commit

Permalink
fix: add hash_fallback_header, hash_on_cookie, hash_on_cookie_path pr…
Browse files Browse the repository at this point in the history
…operties to Upstream object

These properties were introduced in Kong 0.14 and
were missed when Ingress Controller added support
for it.
This change allows configuring these
properties in Upstream in Kong using
KongIngress Custom Resource.

From #139
  • Loading branch information
jdevalk2 authored and hbagdi committed Sep 27, 2018
1 parent b7bad8b commit ab5b6c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
13 changes: 8 additions & 5 deletions internal/apis/admin/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ type Upstream struct {

Name string `json:"name"`

HashOn string `json:"hash_on,omitempty"`
HashOnHeader string `json:"hash_on_header,omitempty"`
HashFallback string `json:"hash_fallback,omitempty"`
Healthchecks *Healthchecks `json:"healthchecks,omitempty"`
Slots int `json:"slots,omitempty"`
HashOn string `json:"hash_on,omitempty"`
HashFallback string `json:"hash_fallback,omitempty"`
HashFallbackHeader string `json:"hash_fallback_header,omitempty"`
HashOnHeader string `json:"hash_on_header,omitempty"`
HashOnCookie string `json:"hash_on_cookie,omitempty"`
HashOnCookiePath string `json:"hash_on_cookie_path,omitempty"`
Healthchecks *Healthchecks `json:"healthchecks,omitempty"`
Slots int `json:"slots,omitempty"`
}

type Healthchecks struct {
Expand Down
13 changes: 8 additions & 5 deletions internal/apis/configuration/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ type Route struct {
}

type Upstream struct {
HashOn string `json:"hash_on"`
HashOnHeader string `json:"hash_on_header"`
HashFallback string `json:"hash_fallback"`
Healthchecks *Healthchecks `json:"healthchecks,omitempty"`
Slots int `json:"slots"`
HashOn string `json:"hash_on"`
HashOnCookie string `json:"hash_on_cookie"`
HashOnCookiePath string `json:"hash_on_cookie_path"`
HashOnHeader string `json:"hash_on_header"`
HashFallback string `json:"hash_fallback"`
HashFallbackHeader string `json:"hash_fallback_header"`
Healthchecks *Healthchecks `json:"healthchecks,omitempty"`
Slots int `json:"slots"`
}

type Proxy struct {
Expand Down
12 changes: 12 additions & 0 deletions internal/ingress/controller/kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,14 @@ func (n *NGINXController) syncUpstreams(locations []*ingress.Location, backends
upstream.HashOn = kongIngress.Upstream.HashOn
}

if kongIngress.Upstream.HashOnCookie != "" {
upstream.HashOnCookie = kongIngress.Upstream.HashOnCookie
}

if kongIngress.Upstream.HashOnCookiePath != "" {
upstream.HashOnCookiePath = kongIngress.Upstream.HashOnCookiePath
}

if kongIngress.Upstream.HashOnHeader != "" {
upstream.HashOnHeader = kongIngress.Upstream.HashOnHeader
}
Expand All @@ -1009,6 +1017,10 @@ func (n *NGINXController) syncUpstreams(locations []*ingress.Location, backends
upstream.HashFallback = kongIngress.Upstream.HashFallback
}

if kongIngress.Upstream.HashFallbackHeader != "" {
upstream.HashFallbackHeader = kongIngress.Upstream.HashFallbackHeader
}

if kongIngress.Upstream.Slots != 0 {
upstream.Slots = kongIngress.Upstream.Slots
}
Expand Down

0 comments on commit ab5b6c5

Please sign in to comment.