From b3813305828013ec651303391a4803262a62a56b Mon Sep 17 00:00:00 2001 From: wasker Date: Mon, 24 May 2021 08:55:04 -0700 Subject: [PATCH 01/38] More prereqs --- docs/developer-guide/getting-started.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/developer-guide/getting-started.md b/docs/developer-guide/getting-started.md index eb5e7cae5e..a9f233d99d 100644 --- a/docs/developer-guide/getting-started.md +++ b/docs/developer-guide/getting-started.md @@ -4,15 +4,13 @@ This document explains how to get started with developing for NGINX Ingress cont ## Prerequisites -Install [Go 1.14](https://golang.org/dl/) or later. - -!!! note - The project uses [Go Modules](https://github.com/golang/go/wiki/Modules) - -Install [Docker](https://docs.docker.com/engine/install/) (v19.03.0 or later with experimental feature on) - -!!! important - The majority of make tasks run as docker containers +* [Go 1.14](https://golang.org/dl/) or later + * The project uses [Go modules](https://github.com/golang/go/wiki/Modules). +* [Docker](https://docs.docker.com/engine/install/) (v19.03.0 or later with experimental feature on) + * The majority of make tasks run as docker containers. +* [Kind](https://kind.sigs.k8s.io/) +* [Kubectl](https://kubernetes.io/docs/tasks/tools/) +* [Helm](https://helm.sh/docs/intro/install/) ## Quick Start From ab70af234b5745381c926c59248c8b5f01ed594e Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 11:06:52 -0700 Subject: [PATCH 02/38] Clone session affinity settings from pri to alt up --- internal/ingress/controller/controller.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 5d4cff7215..4a945249c4 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -1329,6 +1329,8 @@ func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) b } } + priUps.SessionAffinity.DeepCopyInto(&altUps.SessionAffinity) + priUps.AlternativeBackends = append(priUps.AlternativeBackends, altUps.Name) From 3d1a5ee1a05b3a7e81e006d16191f9242d220867 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 11:32:30 -0700 Subject: [PATCH 03/38] New annotation. --- docs/examples/affinity/cookie/README.md | 1 + .../nginx-configuration/annotations.md | 7 +++++-- .../annotations/sessionaffinity/main.go | 20 ++++++++++++++----- internal/ingress/controller/controller.go | 10 ++++++---- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/examples/affinity/cookie/README.md b/docs/examples/affinity/cookie/README.md index 670d345e3f..4f93fc0f85 100644 --- a/docs/examples/affinity/cookie/README.md +++ b/docs/examples/affinity/cookie/README.md @@ -10,6 +10,7 @@ Session affinity can be configured using the following annotations: | --- | --- | --- | |nginx.ingress.kubernetes.io/affinity|Type of the affinity, set this to `cookie` to enable session affinity|string (NGINX only supports `cookie`)| |nginx.ingress.kubernetes.io/affinity-mode|The affinity mode defines how sticky a session is. Use `balanced` to redistribute some sessions when scaling pods or `persistent` for maximum stickiness.|`balanced` (default) or `persistent`| +|nginx.ingress.kubernetes.io/affinity-canary-behavior|Defines session affinity behavior of canaries. By default the behavior is `sticky`, and canaries respect session affinity configuration. Set this to `legacy` to restore original canary behavior, when session affinity parameters were not respected.|`sticky` (default) or `legacy`| |nginx.ingress.kubernetes.io/session-cookie-name|Name of the cookie that will be created|string (defaults to `INGRESSCOOKIE`)| |nginx.ingress.kubernetes.io/session-cookie-path|Path that will be set on the cookie (required if your [Ingress paths][ingress-paths] use regular expressions)|string (defaults to the currently [matched path][ingress-paths])| |nginx.ingress.kubernetes.io/session-cookie-samesite|SameSite attribute to apply to the cookie|Browser accepted values are `None`, `Lax`, and `Strict`| diff --git a/docs/user-guide/nginx-configuration/annotations.md b/docs/user-guide/nginx-configuration/annotations.md index add5c5595e..ef9a4e5ef5 100755 --- a/docs/user-guide/nginx-configuration/annotations.md +++ b/docs/user-guide/nginx-configuration/annotations.md @@ -18,6 +18,7 @@ You can add these Kubernetes annotations to specific Ingress objects to customiz |[nginx.ingress.kubernetes.io/app-root](#rewrite)|string| |[nginx.ingress.kubernetes.io/affinity](#session-affinity)|cookie| |[nginx.ingress.kubernetes.io/affinity-mode](#session-affinity)|"balanced" or "persistent"| +|[nginx.ingress.kubernetes.io/affinity-canary-behavior](#session-affinity)|"sticky" or "legacy"| |[nginx.ingress.kubernetes.io/auth-realm](#authentication)|string| |[nginx.ingress.kubernetes.io/auth-secret](#authentication)|string| |[nginx.ingress.kubernetes.io/auth-secret-type](#authentication)|string| @@ -140,7 +141,7 @@ In some cases, you may want to "canary" a new set of changes by sending a small Canary rules are evaluated in order of precedence. Precedence is as follows: `canary-by-header -> canary-by-cookie -> canary-weight` -**Note** that when you mark an ingress as canary, then all the other non-canary annotations will be ignored (inherited from the corresponding main ingress) except `nginx.ingress.kubernetes.io/load-balance` and `nginx.ingress.kubernetes.io/upstream-hash-by`. +**Note** that when you mark an ingress as canary, then all the other non-canary annotations will be ignored (inherited from the corresponding main ingress) except `nginx.ingress.kubernetes.io/load-balance`, `nginx.ingress.kubernetes.io/upstream-hash-by`, and [annotations related to session affinity](#session-affinity). If you want to restore the original behavior of canaries when session affinity was ignored, set `nginx.ingress.kubernetes.io/affinity-canary-behavior` annotation with value `legacy` on the non-canary ingress definition. **Known Limitations** @@ -163,6 +164,8 @@ The only affinity type available for NGINX is `cookie`. The annotation `nginx.ingress.kubernetes.io/affinity-mode` defines the stickiness of a session. Setting this to `balanced` (default) will redistribute some sessions if a deployment gets scaled up, therefore rebalancing the load on the servers. Setting this to `persistent` will not rebalance sessions to new servers, therefore providing maximum stickiness. +The annotation `nginx.ingress.kubernetes.io/affinity-canary-behavior` defines the behavior of canaries when session affinity is enabled. Setting this to `sticky` (default) will ensure that users that were served by canaries, will continue to be served by canaries. Setting this to `legacy` will restore original canary behavior, when session affinity was ignored. + !!! attention If more than one Ingress is defined for a host and at least one Ingress uses `nginx.ingress.kubernetes.io/affinity: cookie`, then only paths on the Ingress using `nginx.ingress.kubernetes.io/affinity` will use session cookie affinity. All paths defined on other Ingresses for the host will be load balanced through the random selection of a backend server. @@ -342,7 +345,7 @@ CORS can be controlled with the following annotations: - Example: `nginx.ingress.kubernetes.io/cors-allow-headers: "X-Forwarded-For, X-app123-XPTO"` * `nginx.ingress.kubernetes.io/cors-expose-headers` - controls which headers are exposed to response. This is a multi-valued field, separated by ',' and accepts + controls which headers are exposed to response. This is a multi-valued field, separated by ',' and accepts letters, numbers, _, - and *. - Default: *empty* - Example: `nginx.ingress.kubernetes.io/cors-expose-headers: "*, X-CustomResponseHeader"` diff --git a/internal/ingress/annotations/sessionaffinity/main.go b/internal/ingress/annotations/sessionaffinity/main.go index c5b340ec75..80b24f13bf 100644 --- a/internal/ingress/annotations/sessionaffinity/main.go +++ b/internal/ingress/annotations/sessionaffinity/main.go @@ -27,8 +27,10 @@ import ( ) const ( - annotationAffinityType = "affinity" - annotationAffinityMode = "affinity-mode" + annotationAffinityType = "affinity" + annotationAffinityMode = "affinity-mode" + annotationAffinityCanaryBehavior = "affinity-canary-behavior" + // If a cookie with this name exists, // its value is used as an index into the list of available backends. annotationAffinityCookieName = "session-cookie-name" @@ -66,6 +68,8 @@ type Config struct { Type string `json:"type"` // The affinity mode, i.e. how sticky a session is Mode string `json:"mode"` + // Affinity behavior for canaries (sticky or legacy) + CanaryBehavior string `json:"canaryBehavior"` Cookie } @@ -160,6 +164,11 @@ func (a affinity) Parse(ing *networking.Ingress) (interface{}, error) { am = "" } + cb, err := parser.GetStringAnnotation(annotationAffinityCanaryBehavior, ing) + if err != nil { + cb = "" + } + switch at { case "cookie": cookie = a.cookieAffinityParse(ing) @@ -169,8 +178,9 @@ func (a affinity) Parse(ing *networking.Ingress) (interface{}, error) { } return &Config{ - Type: at, - Mode: am, - Cookie: *cookie, + Type: at, + Mode: am, + CanaryBehavior: cb, + Cookie: *cookie, }, nil } diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 4a945249c4..15cb16fe19 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -1315,7 +1315,7 @@ func canMergeBackend(primary *ingress.Backend, alternative *ingress.Backend) boo } // Performs the merge action and checks to ensure that one two alternative backends do not merge into each other -func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) bool { +func mergeAlternativeBackend(ing *ingress.Ingress, priUps *ingress.Backend, altUps *ingress.Backend) bool { if priUps.NoServer { klog.Warningf("unable to merge alternative backend %v into primary backend %v because %v is a primary backend", altUps.Name, priUps.Name, priUps.Name) @@ -1329,7 +1329,9 @@ func mergeAlternativeBackend(priUps *ingress.Backend, altUps *ingress.Backend) b } } - priUps.SessionAffinity.DeepCopyInto(&altUps.SessionAffinity) + if ing.ParsedAnnotations.SessionAffinity.CanaryBehavior != "legacy" { + priUps.SessionAffinity.DeepCopyInto(&altUps.SessionAffinity) + } priUps.AlternativeBackends = append(priUps.AlternativeBackends, altUps.Name) @@ -1370,7 +1372,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres klog.V(2).Infof("matching backend %v found for alternative backend %v", priUps.Name, altUps.Name) - merged = mergeAlternativeBackend(priUps, altUps) + merged = mergeAlternativeBackend(ing, priUps, altUps) } } @@ -1423,7 +1425,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres klog.V(2).Infof("matching backend %v found for alternative backend %v", priUps.Name, altUps.Name) - merged = mergeAlternativeBackend(priUps, altUps) + merged = mergeAlternativeBackend(ing, priUps, altUps) } } From 8dbd6309ac59b16ea6c6f783417669d0a5aeae91 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 13:57:58 -0700 Subject: [PATCH 04/38] High-level implementation of is_affinitized() --- rootfs/etc/nginx/lua/balancer.lua | 4 ++++ rootfs/etc/nginx/lua/balancer/ewma.lua | 4 ++++ rootfs/etc/nginx/lua/balancer/sticky.lua | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index afcfebb67a..6a6e51351e 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -186,6 +186,10 @@ local function sync_backends() end local function route_to_alternative_balancer(balancer) + if balancer.is_affinitized() then + return false + end + if not balancer.alternative_backends then return false end diff --git a/rootfs/etc/nginx/lua/balancer/ewma.lua b/rootfs/etc/nginx/lua/balancer/ewma.lua index ae65ccc73f..681866dc16 100644 --- a/rootfs/etc/nginx/lua/balancer/ewma.lua +++ b/rootfs/etc/nginx/lua/balancer/ewma.lua @@ -170,6 +170,10 @@ local function calculate_slow_start_ewma(self) return total_ewma / endpoints_count end +function _M.is_affinitized() + return false +end + function _M.balance(self) local peers = self.peers local endpoint, ewma_score = peers[1], -1 diff --git a/rootfs/etc/nginx/lua/balancer/sticky.lua b/rootfs/etc/nginx/lua/balancer/sticky.lua index 45ea9beaf7..4cbcafe885 100644 --- a/rootfs/etc/nginx/lua/balancer/sticky.lua +++ b/rootfs/etc/nginx/lua/balancer/sticky.lua @@ -86,6 +86,14 @@ function _M.set_cookie(self, value) end end +function _M.is_affinitized() + if self:get_cookie() then + return true + end + + return false +end + function _M.get_last_failure() return ngx_balancer.get_last_failure() end From ec36aabc0b8f2a3f647e81c4e0e41db9ef56be9c Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 15:08:34 -0700 Subject: [PATCH 05/38] Affinitization works. --- rootfs/etc/nginx/lua/balancer.lua | 9 +++- rootfs/etc/nginx/lua/balancer/chashsubset.lua | 4 ++ rootfs/etc/nginx/lua/balancer/ewma.lua | 2 +- rootfs/etc/nginx/lua/balancer/resty.lua | 4 ++ rootfs/etc/nginx/lua/balancer/sticky.lua | 43 ++++++++++++++----- rootfs/etc/nginx/lua/util/split.lua | 15 +++++++ 6 files changed, 65 insertions(+), 12 deletions(-) diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index 6a6e51351e..558278a743 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -186,7 +186,8 @@ local function sync_backends() end local function route_to_alternative_balancer(balancer) - if balancer.is_affinitized() then + if balancer.is_affinitized(balancer) then + -- If request is already affinitized to a primary balancer, keep the primary balancer. return false end @@ -208,6 +209,12 @@ local function route_to_alternative_balancer(balancer) return false end + if alternative_balancer.is_affinitized(alternative_balancer) then + -- If request is affinitized to an alternative balancer, instruct caller to switch to alternative. + return true + end + + -- Use traffic shaping policy, if request didn't have affinity set. local traffic_shaping_policy = alternative_balancer.traffic_shaping_policy if not traffic_shaping_policy then ngx.log(ngx.ERR, "traffic shaping policy is not set for balancer ", diff --git a/rootfs/etc/nginx/lua/balancer/chashsubset.lua b/rootfs/etc/nginx/lua/balancer/chashsubset.lua index 28c2354a1b..1bd625d4d5 100644 --- a/rootfs/etc/nginx/lua/balancer/chashsubset.lua +++ b/rootfs/etc/nginx/lua/balancer/chashsubset.lua @@ -68,6 +68,10 @@ function _M.new(self, backend) return o end +function _M.is_affinitized(self) + return false +end + function _M.balance(self) local key = util.generate_var_value(self.hash_by) local subset_id = self.instance:find(key) diff --git a/rootfs/etc/nginx/lua/balancer/ewma.lua b/rootfs/etc/nginx/lua/balancer/ewma.lua index 681866dc16..c28760b96e 100644 --- a/rootfs/etc/nginx/lua/balancer/ewma.lua +++ b/rootfs/etc/nginx/lua/balancer/ewma.lua @@ -170,7 +170,7 @@ local function calculate_slow_start_ewma(self) return total_ewma / endpoints_count end -function _M.is_affinitized() +function _M.is_affinitized(self) return false end diff --git a/rootfs/etc/nginx/lua/balancer/resty.lua b/rootfs/etc/nginx/lua/balancer/resty.lua index c1065ff19d..ee9d698df7 100644 --- a/rootfs/etc/nginx/lua/balancer/resty.lua +++ b/rootfs/etc/nginx/lua/balancer/resty.lua @@ -14,6 +14,10 @@ function _M.new(self, o) return o end +function _M.is_affinitized(self) + return false +end + function _M.sync(self, backend) self.traffic_shaping_policy = backend.trafficShapingPolicy self.alternative_backends = backend.alternativeBackends diff --git a/rootfs/etc/nginx/lua/balancer/sticky.lua b/rootfs/etc/nginx/lua/balancer/sticky.lua index 4cbcafe885..112308c8e3 100644 --- a/rootfs/etc/nginx/lua/balancer/sticky.lua +++ b/rootfs/etc/nginx/lua/balancer/sticky.lua @@ -13,6 +13,7 @@ local setmetatable = setmetatable local _M = balancer_resty:new() local DEFAULT_COOKIE_NAME = "route" +local COOKIE_VALUE_DELIMITER = ":" function _M.cookie_name(self) return self.cookie_session_affinity.name or DEFAULT_COOKIE_NAME @@ -22,7 +23,8 @@ function _M.new(self) local o = { alternative_backends = nil, cookie_session_affinity = nil, - traffic_shaping_policy = nil + traffic_shaping_policy = nil, + backend_key = nil } setmetatable(o, self) @@ -31,13 +33,37 @@ function _M.new(self) return o end -function _M.get_cookie(self) +function _M.get_cookie_parsed(self) local cookie, err = ck:new() if not cookie then ngx.log(ngx.ERR, err) end - return cookie:get(self:cookie_name()) + local result = { + upstream_key = nil, + backend_key = nil + } + + local raw_value = cookie:get(self:cookie_name()) + if not raw_value then + return result + end + + local parsed_value, len = split.split_string(raw_value, COOKIE_VALUE_DELIMITER) + if len == 0 then + return result + end + + result.upstream_key = parsed_value[1] + if len <= 2 then + result.backend_key = parsed_value[2] + end + + return result +end + +function _M.get_cookie(self) + return self:get_cookie_parsed().upstream_key end function _M.set_cookie(self, value) @@ -63,7 +89,7 @@ function _M.set_cookie(self, value) local cookie_data = { key = self:cookie_name(), - value = value, + value = value .. COOKIE_VALUE_DELIMITER .. self.backend_key, path = cookie_path, httponly = true, samesite = cookie_samesite, @@ -86,12 +112,8 @@ function _M.set_cookie(self, value) end end -function _M.is_affinitized() - if self:get_cookie() then - return true - end - - return false +function _M.is_affinitized(self) + return self:get_cookie_parsed().backend_key == self.backend_key end function _M.get_last_failure() @@ -174,6 +196,7 @@ function _M.sync(self, backend) self.traffic_shaping_policy = backend.trafficShapingPolicy self.alternative_backends = backend.alternativeBackends self.cookie_session_affinity = backend.sessionAffinityConfig.cookieSessionAffinity + self.backend_key = ngx.md5(ngx.md5(backend.name) .. backend.name) end return _M diff --git a/rootfs/etc/nginx/lua/util/split.lua b/rootfs/etc/nginx/lua/util/split.lua index d5400ab577..63f6e90099 100644 --- a/rootfs/etc/nginx/lua/util/split.lua +++ b/rootfs/etc/nginx/lua/util/split.lua @@ -65,4 +65,19 @@ function _M.split_upstream_addr(addrs_str) return host_and_ports end +-- Splits string by delimiter. Returns array of parsed values and the length of the array. +function _M.split_string(what, delim) + local result = {} + local idx = 0 + + if what then + for chunk in what:gmatch("([^" .. delim .. "]+)") do + idx = idx + 1 + result[idx] = chunk + end + end + + return result, idx +end + return _M From d13ba21e6cabf32be089607beb3822524b556275 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 15:16:02 -0700 Subject: [PATCH 06/38] Make existing lua tests pass. --- rootfs/etc/nginx/lua/test/balancer_test.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua index 1834b6f60d..98ab6e5282 100644 --- a/rootfs/etc/nginx/lua/test/balancer_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -133,7 +133,10 @@ describe("Balancer", function() _balancer = { alternative_backends = { backend.name, - } + }, + is_affinitized = function (_) + return false + end } mock_ngx({ var = { request_uri = "/" } }) reset_balancer() From 28af8361d60f8a6930af21f9afa2468cf5b3eeb1 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 18:18:57 -0700 Subject: [PATCH 07/38] Tests for split. --- rootfs/etc/nginx/lua/test/util/split.lua | 15 ----- rootfs/etc/nginx/lua/test/util/split_test.lua | 57 +++++++++++++++++++ rootfs/etc/nginx/lua/util/split.lua | 2 +- 3 files changed, 58 insertions(+), 16 deletions(-) delete mode 100644 rootfs/etc/nginx/lua/test/util/split.lua create mode 100644 rootfs/etc/nginx/lua/test/util/split_test.lua diff --git a/rootfs/etc/nginx/lua/test/util/split.lua b/rootfs/etc/nginx/lua/test/util/split.lua deleted file mode 100644 index 3d3a6d7e9a..0000000000 --- a/rootfs/etc/nginx/lua/test/util/split.lua +++ /dev/null @@ -1,15 +0,0 @@ -local split = require("util.split") - - -describe("split", function() - it("get_last_value", function() - for _, case in ipairs({ - {"127.0.0.1:26157 : 127.0.0.1:26158", "127.0.0.1:26158"}, - {"127.0.0.1:26157, 127.0.0.1:26158", "127.0.0.1:26158"}, - {"127.0.0.1:26158", "127.0.0.1:26158"}, - }) do - local last = split.get_last_value(case[1]) - assert.equal(case[2], last) - end - end) -end) diff --git a/rootfs/etc/nginx/lua/test/util/split_test.lua b/rootfs/etc/nginx/lua/test/util/split_test.lua new file mode 100644 index 0000000000..5f0b1a3fb7 --- /dev/null +++ b/rootfs/etc/nginx/lua/test/util/split_test.lua @@ -0,0 +1,57 @@ +local split = require("util.split") + +describe("split", function() + + describe("get_last_value", function() + it("splits value of an upstream variable and returns last value", function() + for _, case in ipairs({{"127.0.0.1:26157 : 127.0.0.1:26158", "127.0.0.1:26158"}, + {"127.0.0.1:26157, 127.0.0.1:26158", "127.0.0.1:26158"}, + {"127.0.0.1:26158", "127.0.0.1:26158"}}) do + local last = split.get_last_value(case[1]) + assert.equal(case[2], last) + end + end) + end) + + describe("split_string", function() + + it("returns empty array if input string is empty", function() + local splits, len = split.split_string("", ",") + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns empty array if input string is nil", function() + local splits, len = split.split_string(nil, ",") + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns empty array if delimiter is empty", function() + local splits, len = split.split_string("1,2", "") + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns empty array delimiter is nil", function() + local splits, len = split.split_string("1,2", nil) + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns array of 1 value if input string is not a list", function() + local splits, len = split.split_string("123", ",") + assert.equal(1, len) + assert.equal("123", splits[1]) + end) + + it("returns array of values extracted from the input string", function() + local splits, len = split.split_string("1,2,3", ",") + assert.equal(3, len) + assert.equal("1", splits[1]) + assert.equal("2", splits[2]) + assert.equal("3", splits[3]) + end) + + end) +end) diff --git a/rootfs/etc/nginx/lua/util/split.lua b/rootfs/etc/nginx/lua/util/split.lua index 63f6e90099..63edf0900b 100644 --- a/rootfs/etc/nginx/lua/util/split.lua +++ b/rootfs/etc/nginx/lua/util/split.lua @@ -70,7 +70,7 @@ function _M.split_string(what, delim) local result = {} local idx = 0 - if what then + if what and delim and delim ~= "" then for chunk in what:gmatch("([^" .. delim .. "]+)") do idx = idx + 1 result[idx] = chunk From ddeeaa44455e7f2def9470190c0a45de9d0ca160 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 18:20:02 -0700 Subject: [PATCH 08/38] Reformat lua code. --- rootfs/etc/nginx/lua/test/util/split_test.lua | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/util/split_test.lua b/rootfs/etc/nginx/lua/test/util/split_test.lua index 5f0b1a3fb7..d81a92c2d4 100644 --- a/rootfs/etc/nginx/lua/test/util/split_test.lua +++ b/rootfs/etc/nginx/lua/test/util/split_test.lua @@ -2,56 +2,56 @@ local split = require("util.split") describe("split", function() - describe("get_last_value", function() - it("splits value of an upstream variable and returns last value", function() - for _, case in ipairs({{"127.0.0.1:26157 : 127.0.0.1:26158", "127.0.0.1:26158"}, - {"127.0.0.1:26157, 127.0.0.1:26158", "127.0.0.1:26158"}, - {"127.0.0.1:26158", "127.0.0.1:26158"}}) do - local last = split.get_last_value(case[1]) - assert.equal(case[2], last) - end - end) + describe("get_last_value", function() + it("splits value of an upstream variable and returns last value", function() + for _, case in ipairs({{"127.0.0.1:26157 : 127.0.0.1:26158", "127.0.0.1:26158"}, + {"127.0.0.1:26157, 127.0.0.1:26158", "127.0.0.1:26158"}, + {"127.0.0.1:26158", "127.0.0.1:26158"}}) do + local last = split.get_last_value(case[1]) + assert.equal(case[2], last) + end end) + end) - describe("split_string", function() - - it("returns empty array if input string is empty", function() - local splits, len = split.split_string("", ",") - assert.equal(0, len) - assert.is.truthy(splits) - end) - - it("returns empty array if input string is nil", function() - local splits, len = split.split_string(nil, ",") - assert.equal(0, len) - assert.is.truthy(splits) - end) - - it("returns empty array if delimiter is empty", function() - local splits, len = split.split_string("1,2", "") - assert.equal(0, len) - assert.is.truthy(splits) - end) - - it("returns empty array delimiter is nil", function() - local splits, len = split.split_string("1,2", nil) - assert.equal(0, len) - assert.is.truthy(splits) - end) - - it("returns array of 1 value if input string is not a list", function() - local splits, len = split.split_string("123", ",") - assert.equal(1, len) - assert.equal("123", splits[1]) - end) - - it("returns array of values extracted from the input string", function() - local splits, len = split.split_string("1,2,3", ",") - assert.equal(3, len) - assert.equal("1", splits[1]) - assert.equal("2", splits[2]) - assert.equal("3", splits[3]) - end) + describe("split_string", function() + it("returns empty array if input string is empty", function() + local splits, len = split.split_string("", ",") + assert.equal(0, len) + assert.is.truthy(splits) end) + + it("returns empty array if input string is nil", function() + local splits, len = split.split_string(nil, ",") + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns empty array if delimiter is empty", function() + local splits, len = split.split_string("1,2", "") + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns empty array delimiter is nil", function() + local splits, len = split.split_string("1,2", nil) + assert.equal(0, len) + assert.is.truthy(splits) + end) + + it("returns array of 1 value if input string is not a list", function() + local splits, len = split.split_string("123", ",") + assert.equal(1, len) + assert.equal("123", splits[1]) + end) + + it("returns array of values extracted from the input string", function() + local splits, len = split.split_string("1,2,3", ",") + assert.equal(3, len) + assert.equal("1", splits[1]) + assert.equal("2", splits[2]) + assert.equal("3", splits[3]) + end) + + end) end) From b21add31b8a270f819b4e5e9bafeb4ff2efb2086 Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 18:30:27 -0700 Subject: [PATCH 09/38] Reshuffle alt balancer tests. --- rootfs/etc/nginx/lua/test/balancer_test.lua | 289 ++++++++++---------- 1 file changed, 148 insertions(+), 141 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua index 98ab6e5282..44678a8fbf 100644 --- a/rootfs/etc/nginx/lua/test/balancer_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -133,168 +133,175 @@ describe("Balancer", function() _balancer = { alternative_backends = { backend.name, - }, - is_affinitized = function (_) - return false - end + } } mock_ngx({ var = { request_uri = "/" } }) reset_balancer() end) - it("returns false when no trafficShapingPolicy is set", function() - balancer.sync_backend(backend) - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) - end) + describe("not affinitized - uses traffic shaping policy", function() - it("returns false when no alternative backends is set", function() - backend.trafficShapingPolicy.weight = 100 - balancer.sync_backend(backend) - _balancer.alternative_backends = nil - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) - end) + before_each(function() + _balancer.is_affinitized = function (_) + return false + end + end) - it("returns false when alternative backends name does not match", function() - backend.trafficShapingPolicy.weight = 100 - balancer.sync_backend(backend) - _balancer.alternative_backends[1] = "nonExistingBackend" - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) - end) + it("returns false when no trafficShapingPolicy is set", function() + balancer.sync_backend(backend) + assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + end) - context("canary by weight", function() - it("returns true when weight is 100", function() + it("returns false when no alternative backends is set", function() backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) - assert.equal(true, balancer.route_to_alternative_balancer(_balancer)) + _balancer.alternative_backends = nil + assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) end) - it("returns false when weight is 0", function() - backend.trafficShapingPolicy.weight = 0 + it("returns false when alternative backends name does not match", function() + backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) + _balancer.alternative_backends[1] = "nonExistingBackend" assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) end) - end) - context("canary by cookie", function() - it("returns correct result for given cookies", function() - local test_patterns = { - { - case_title = "cookie_value is 'always'", - request_cookie_name = "canaryCookie", - request_cookie_value = "always", - expected_result = true, - }, - { - case_title = "cookie_value is 'never'", - request_cookie_name = "canaryCookie", - request_cookie_value = "never", - expected_result = false, - }, - { - case_title = "cookie_value is undefined", - request_cookie_name = "canaryCookie", - request_cookie_value = "foo", - expected_result = false, - }, - { - case_title = "cookie_name is undefined", - request_cookie_name = "foo", - request_cookie_value = "always", - expected_result = false - }, - } - for _, test_pattern in pairs(test_patterns) do - mock_ngx({ var = { - ["cookie_" .. test_pattern.request_cookie_name] = test_pattern.request_cookie_value, - request_uri = "/" - }}) - reset_balancer() - backend.trafficShapingPolicy.cookie = "canaryCookie" + describe("canary by weight", function() + it("returns true when weight is 100", function() + backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) - assert.message("\nTest data pattern: " .. test_pattern.case_title) - .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) - reset_ngx() - end + assert.equal(true, balancer.route_to_alternative_balancer(_balancer)) + end) + + it("returns false when weight is 0", function() + backend.trafficShapingPolicy.weight = 0 + balancer.sync_backend(backend) + assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + end) end) - end) - context("canary by header", function() - it("returns correct result for given headers", function() - local test_patterns = { - -- with no header value setting - { - case_title = "no custom header value and header value is 'always'", - header_name = "canaryHeader", - header_value = "", - request_header_name = "canaryHeader", - request_header_value = "always", - expected_result = true, - }, - { - case_title = "no custom header value and header value is 'never'", - header_name = "canaryHeader", - header_value = "", - request_header_name = "canaryHeader", - request_header_value = "never", - expected_result = false, - }, - { - case_title = "no custom header value and header value is undefined", - header_name = "canaryHeader", - header_value = "", - request_header_name = "canaryHeader", - request_header_value = "foo", - expected_result = false, - }, - { - case_title = "no custom header value and header name is undefined", - header_name = "canaryHeader", - header_value = "", - request_header_name = "foo", - request_header_value = "always", - expected_result = false, - }, - -- with header value setting - { - case_title = "custom header value is set and header value is 'always'", - header_name = "canaryHeader", - header_value = "foo", - request_header_name = "canaryHeader", - request_header_value = "always", - expected_result = false, - }, - { - case_title = "custom header value is set and header value match custom header value", - header_name = "canaryHeader", - header_value = "foo", - request_header_name = "canaryHeader", - request_header_value = "foo", - expected_result = true, - }, - { - case_title = "custom header value is set and header name is undefined", - header_name = "canaryHeader", - header_value = "foo", - request_header_name = "bar", - request_header_value = "foo", - expected_result = false - }, - } + describe("canary by cookie", function() + it("returns correct result for given cookies", function() + local test_patterns = { + { + case_title = "cookie_value is 'always'", + request_cookie_name = "canaryCookie", + request_cookie_value = "always", + expected_result = true, + }, + { + case_title = "cookie_value is 'never'", + request_cookie_name = "canaryCookie", + request_cookie_value = "never", + expected_result = false, + }, + { + case_title = "cookie_value is undefined", + request_cookie_name = "canaryCookie", + request_cookie_value = "foo", + expected_result = false, + }, + { + case_title = "cookie_name is undefined", + request_cookie_name = "foo", + request_cookie_value = "always", + expected_result = false + }, + } + for _, test_pattern in pairs(test_patterns) do + mock_ngx({ var = { + ["cookie_" .. test_pattern.request_cookie_name] = test_pattern.request_cookie_value, + request_uri = "/" + }}) + reset_balancer() + backend.trafficShapingPolicy.cookie = "canaryCookie" + balancer.sync_backend(backend) + assert.message("\nTest data pattern: " .. test_pattern.case_title) + .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) + reset_ngx() + end + end) + end) - for _, test_pattern in pairs(test_patterns) do - mock_ngx({ var = { - ["http_" .. test_pattern.request_header_name] = test_pattern.request_header_value, - request_uri = "/" - }}) - reset_balancer() - backend.trafficShapingPolicy.header = test_pattern.header_name - backend.trafficShapingPolicy.headerValue = test_pattern.header_value - balancer.sync_backend(backend) - assert.message("\nTest data pattern: " .. test_pattern.case_title) - .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) - reset_ngx() - end + describe("canary by header", function() + it("returns correct result for given headers", function() + local test_patterns = { + -- with no header value setting + { + case_title = "no custom header value and header value is 'always'", + header_name = "canaryHeader", + header_value = "", + request_header_name = "canaryHeader", + request_header_value = "always", + expected_result = true, + }, + { + case_title = "no custom header value and header value is 'never'", + header_name = "canaryHeader", + header_value = "", + request_header_name = "canaryHeader", + request_header_value = "never", + expected_result = false, + }, + { + case_title = "no custom header value and header value is undefined", + header_name = "canaryHeader", + header_value = "", + request_header_name = "canaryHeader", + request_header_value = "foo", + expected_result = false, + }, + { + case_title = "no custom header value and header name is undefined", + header_name = "canaryHeader", + header_value = "", + request_header_name = "foo", + request_header_value = "always", + expected_result = false, + }, + -- with header value setting + { + case_title = "custom header value is set and header value is 'always'", + header_name = "canaryHeader", + header_value = "foo", + request_header_name = "canaryHeader", + request_header_value = "always", + expected_result = false, + }, + { + case_title = "custom header value is set and header value match custom header value", + header_name = "canaryHeader", + header_value = "foo", + request_header_name = "canaryHeader", + request_header_value = "foo", + expected_result = true, + }, + { + case_title = "custom header value is set and header name is undefined", + header_name = "canaryHeader", + header_value = "foo", + request_header_name = "bar", + request_header_value = "foo", + expected_result = false + }, + } + + for _, test_pattern in pairs(test_patterns) do + mock_ngx({ var = { + ["http_" .. test_pattern.request_header_name] = test_pattern.request_header_value, + request_uri = "/" + }}) + reset_balancer() + backend.trafficShapingPolicy.header = test_pattern.header_name + backend.trafficShapingPolicy.headerValue = test_pattern.header_value + balancer.sync_backend(backend) + assert.message("\nTest data pattern: " .. test_pattern.case_title) + .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) + reset_ngx() + end + end) end) + end) end) From 52d6ec811fcb62914805916163bf1c012747167b Mon Sep 17 00:00:00 2001 From: wasker Date: Tue, 25 May 2021 18:53:48 -0700 Subject: [PATCH 10/38] Added test for chashsubset impl. --- rootfs/etc/nginx/lua/balancer.lua | 2 +- rootfs/etc/nginx/lua/test/balancer_test.lua | 69 +++++++++++++-------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index 558278a743..62dfb0c8d1 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -48,7 +48,7 @@ local function get_implementation(backend) if backend["sessionAffinityConfig"] and backend["sessionAffinityConfig"]["name"] == "cookie" then - if backend["sessionAffinityConfig"]["mode"] == 'persistent' then + if backend["sessionAffinityConfig"]["mode"] == "persistent" then name = "sticky_persistent" else name = "sticky_balanced" diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua index 44678a8fbf..5663db2bf8 100644 --- a/rootfs/etc/nginx/lua/test/balancer_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -26,7 +26,8 @@ local function reset_expected_implementations() ["my-dummy-app-2"] = package.loaded["balancer.chash"], ["my-dummy-app-3"] = package.loaded["balancer.sticky_persistent"], ["my-dummy-app-4"] = package.loaded["balancer.ewma"], - ["my-dummy-app-5"] = package.loaded["balancer.sticky_balanced"] + ["my-dummy-app-5"] = package.loaded["balancer.sticky_balanced"], + ["my-dummy-app-6"] = package.loaded["balancer.chashsubset"] } end @@ -48,20 +49,35 @@ local function reset_backends() cookie = "" }, }, - { name = "my-dummy-app-1", ["load-balance"] = "round_robin", }, { - name = "my-dummy-app-2", ["load-balance"] = "chash", + name = "my-dummy-app-1", + ["load-balance"] = "round_robin", + }, + { + name = "my-dummy-app-2", + ["load-balance"] = "round_robin", -- upstreamHashByConfig will take priority. upstreamHashByConfig = { ["upstream-hash-by"] = "$request_uri", }, }, { - name = "my-dummy-app-3", ["load-balance"] = "ewma", - sessionAffinityConfig = { name = "cookie", mode = 'persistent', cookieSessionAffinity = { name = "route" } } + name = "my-dummy-app-3", + ["load-balance"] = "ewma", -- sessionAffinityConfig will take priority. + sessionAffinityConfig = { name = "cookie", mode = "persistent", cookieSessionAffinity = { name = "route" } } }, - { name = "my-dummy-app-4", ["load-balance"] = "ewma", }, { - name = "my-dummy-app-5", ["load-balance"] = "ewma", ["upstream-hash-by"] = "$request_uri", + name = "my-dummy-app-4", + ["load-balance"] = "ewma", + }, + { + name = "my-dummy-app-5", + ["load-balance"] = "ewma", -- sessionAffinityConfig will take priority. + upstreamHashByConfig = { ["upstream-hash-by"] = "$request_uri", }, sessionAffinityConfig = { name = "cookie", cookieSessionAffinity = { name = "route" } } }, + { + name = "my-dummy-app-6", + ["load-balance"] = "ewma", -- upstreamHashByConfig will take priority. + upstreamHashByConfig = { ["upstream-hash-by"] = "$request_uri", ["upstream-hash-by-subset"] = "true", } + }, } end @@ -77,7 +93,7 @@ describe("Balancer", function() end) describe("get_implementation()", function() - it("returns correct implementation for given backend", function() + it("uses heuristics to select correct load balancer implementation for a given backend", function() for _, backend in pairs(backends) do local expected_implementation = expected_implementations[backend.name] local implementation = balancer.get_implementation(backend) @@ -89,8 +105,8 @@ describe("Balancer", function() describe("get_balancer()", function() it("always returns the same balancer for given request context", function() local backend = { - name = "my-dummy-app-6", ["load-balance"] = "ewma", - alternativeBackends = { "my-dummy-canary-app-6" }, + name = "my-dummy-app-100", ["load-balance"] = "ewma", + alternativeBackends = { "my-dummy-canary-app-100" }, endpoints = { { address = "10.184.7.40", port = "8080", maxFails = 0, failTimeout = 0 } }, trafficShapingPolicy = { weight = 0, @@ -100,8 +116,8 @@ describe("Balancer", function() }, } local canary_backend = { - name = "my-dummy-canary-app-6", ["load-balance"] = "ewma", - alternativeBackends = { "my-dummy-canary-app-6" }, + name = "my-dummy-canary-app-100", ["load-balance"] = "ewma", + alternativeBackends = { "my-dummy-canary-app-100" }, endpoints = { { address = "11.184.7.40", port = "8080", maxFails = 0, failTimeout = 0 } }, trafficShapingPolicy = { weight = 5, @@ -126,11 +142,11 @@ describe("Balancer", function() end) describe("route_to_alternative_balancer()", function() - local backend, _balancer + local backend, _primaryBalancer before_each(function() backend = backends[1] - _balancer = { + _primaryBalancer = { alternative_backends = { backend.name, } @@ -139,44 +155,44 @@ describe("Balancer", function() reset_balancer() end) - describe("not affinitized - uses traffic shaping policy", function() + describe("not affinitized - uses traffic shaping policy to pick backend", function() before_each(function() - _balancer.is_affinitized = function (_) + _primaryBalancer.is_affinitized = function (_) return false end end) it("returns false when no trafficShapingPolicy is set", function() balancer.sync_backend(backend) - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + assert.equal(false, balancer.route_to_alternative_balancer(_primaryBalancer)) end) it("returns false when no alternative backends is set", function() backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) - _balancer.alternative_backends = nil - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + _primaryBalancer.alternative_backends = nil + assert.equal(false, balancer.route_to_alternative_balancer(_primaryBalancer)) end) it("returns false when alternative backends name does not match", function() backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) - _balancer.alternative_backends[1] = "nonExistingBackend" - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + _primaryBalancer.alternative_backends[1] = "nonExistingBackend" + assert.equal(false, balancer.route_to_alternative_balancer(_primaryBalancer)) end) describe("canary by weight", function() it("returns true when weight is 100", function() backend.trafficShapingPolicy.weight = 100 balancer.sync_backend(backend) - assert.equal(true, balancer.route_to_alternative_balancer(_balancer)) + assert.equal(true, balancer.route_to_alternative_balancer(_primaryBalancer)) end) it("returns false when weight is 0", function() backend.trafficShapingPolicy.weight = 0 balancer.sync_backend(backend) - assert.equal(false, balancer.route_to_alternative_balancer(_balancer)) + assert.equal(false, balancer.route_to_alternative_balancer(_primaryBalancer)) end) end) @@ -217,7 +233,7 @@ describe("Balancer", function() backend.trafficShapingPolicy.cookie = "canaryCookie" balancer.sync_backend(backend) assert.message("\nTest data pattern: " .. test_pattern.case_title) - .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) + .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_primaryBalancer)) reset_ngx() end end) @@ -296,13 +312,16 @@ describe("Balancer", function() backend.trafficShapingPolicy.headerValue = test_pattern.header_value balancer.sync_backend(backend) assert.message("\nTest data pattern: " .. test_pattern.case_title) - .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_balancer)) + .equal(test_pattern.expected_result, balancer.route_to_alternative_balancer(_primaryBalancer)) reset_ngx() end end) end) end) + + describe("affinitized - prefers affinitized backend", function() + end) end) describe("sync_backend()", function() From 4cb1e91a7a8651e13b04f9a055fb0522cae5cbd4 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 08:12:10 -0700 Subject: [PATCH 11/38] Always reset balancer after ngx mocked. --- rootfs/etc/nginx/lua/test/balancer_test.lua | 42 +++++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua index 5663db2bf8..947b5ef910 100644 --- a/rootfs/etc/nginx/lua/test/balancer_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -6,12 +6,9 @@ local original_ngx = ngx local function reset_ngx() _G.ngx = original_ngx -end -local function mock_ngx(mock) - local _ngx = mock - setmetatable(_ngx, { __index = ngx }) - _G.ngx = _ngx + -- Ensure balancer cache is reset. + _G.ngx.ctx.balancer = nil end local function reset_balancer() @@ -19,6 +16,19 @@ local function reset_balancer() balancer = require("balancer") end +local function mock_ngx(mock, after_mock_set) + local _ngx = mock + setmetatable(_ngx, { __index = ngx }) + _G.ngx = _ngx + + if after_mock_set then + after_mock_set() + end + + -- Balancer module caches ngx module, must be reset after mocks were configured. + reset_balancer() +end + local function reset_expected_implementations() expected_implementations = { ["access-router-production-web-80"] = package.loaded["balancer.round_robin"], @@ -128,7 +138,6 @@ describe("Balancer", function() } mock_ngx({ var = { proxy_upstream_name = backend.name } }) - reset_balancer() balancer.sync_backend(backend) balancer.sync_backend(canary_backend) @@ -152,7 +161,6 @@ describe("Balancer", function() } } mock_ngx({ var = { request_uri = "/" } }) - reset_balancer() end) describe("not affinitized - uses traffic shaping policy to pick backend", function() @@ -229,7 +237,6 @@ describe("Balancer", function() ["cookie_" .. test_pattern.request_cookie_name] = test_pattern.request_cookie_value, request_uri = "/" }}) - reset_balancer() backend.trafficShapingPolicy.cookie = "canaryCookie" balancer.sync_backend(backend) assert.message("\nTest data pattern: " .. test_pattern.case_title) @@ -307,7 +314,6 @@ describe("Balancer", function() ["http_" .. test_pattern.request_header_name] = test_pattern.request_header_value, request_uri = "/" }}) - reset_balancer() backend.trafficShapingPolicy.header = test_pattern.header_name backend.trafficShapingPolicy.headerValue = test_pattern.header_value balancer.sync_backend(backend) @@ -321,6 +327,15 @@ describe("Balancer", function() end) describe("affinitized - prefers affinitized backend", function() + + before_each(function() + mock_ngx({ var = { request_uri = "/", proxy_upstream_name = backend.name } }) + end) + + it("test", function() + assert.equal(_primaryBalancer, balancer.get_balancer()) + end) + end) end) @@ -461,10 +476,13 @@ describe("Balancer", function() }, } } - mock_ngx({ var = { proxy_upstream_name = "access-router-production-web-80" }, ctx = { } }) - ngx.shared.configuration_data:set("backends", cjson.encode(backends)) - reset_balancer() + + mock_ngx({ var = { proxy_upstream_name = "access-router-production-web-80" }, ctx = { } }, function() + ngx.shared.configuration_data:set("backends", cjson.encode(backends)) + end) + balancer.init_worker() + assert.not_equal(balancer.get_balancer(), nil) end) From 60e0642c25f472350d5a6d9104e4c8e7a5197dcd Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 08:16:01 -0700 Subject: [PATCH 12/38] Exposed get_balancer_by_upstream_name() --- rootfs/etc/nginx/lua/balancer.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index 62dfb0c8d1..81440a4151 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -265,6 +265,10 @@ local function route_to_alternative_balancer(balancer) return false end +local function get_balancer_by_upstream_name(upstream_name) + return balancers[upstream_name] +end + local function get_balancer() if ngx.ctx.balancer then return ngx.ctx.balancer @@ -274,7 +278,7 @@ local function get_balancer() local balancer = balancers[backend_name] if not balancer then - return + return nil end if route_to_alternative_balancer(balancer) then @@ -363,6 +367,7 @@ setmetatable(_M, {__index = { sync_backend = sync_backend, route_to_alternative_balancer = route_to_alternative_balancer, get_balancer = get_balancer, + get_balancer_by_upstream_name = get_balancer_by_upstream_name, }}) return _M From f6621a6f294b9c7deb5f369e00abdd573c2a79d1 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 08:36:21 -0700 Subject: [PATCH 13/38] UTs for affinitized requests. --- rootfs/etc/nginx/lua/test/balancer_test.lua | 40 ++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer_test.lua b/rootfs/etc/nginx/lua/test/balancer_test.lua index 947b5ef910..4f40bc6ae5 100644 --- a/rootfs/etc/nginx/lua/test/balancer_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer_test.lua @@ -163,7 +163,8 @@ describe("Balancer", function() mock_ngx({ var = { request_uri = "/" } }) end) - describe("not affinitized - uses traffic shaping policy to pick backend", function() + -- Not affinitized request must follow traffic shaping policies. + describe("not affinitized", function() before_each(function() _primaryBalancer.is_affinitized = function (_) @@ -326,14 +327,45 @@ describe("Balancer", function() end) - describe("affinitized - prefers affinitized backend", function() + -- Affinitized request prefers backend it is affinitized to. + describe("affinitized", function() before_each(function() mock_ngx({ var = { request_uri = "/", proxy_upstream_name = backend.name } }) + balancer.sync_backend(backend) + end) + + it("returns false if request is affinitized to primary backend", function() + _primaryBalancer.is_affinitized = function (_) + return true + end + + local alternativeBalancer = balancer.get_balancer_by_upstream_name(backend.name) + + local primarySpy = spy.on(_primaryBalancer, "is_affinitized") + local alternativeSpy = spy.on(alternativeBalancer, "is_affinitized") + + assert.is_false(balancer.route_to_alternative_balancer(_primaryBalancer)) + assert.spy(_primaryBalancer.is_affinitized).was_called() + assert.spy(alternativeBalancer.is_affinitized).was_not_called() end) - it("test", function() - assert.equal(_primaryBalancer, balancer.get_balancer()) + it("returns true if request is affinitized to alternative backend", function() + _primaryBalancer.is_affinitized = function (_) + return false + end + + local alternativeBalancer = balancer.get_balancer_by_upstream_name(backend.name) + alternativeBalancer.is_affinitized = function (_) + return true + end + + local primarySpy = spy.on(_primaryBalancer, "is_affinitized") + local alternativeSpy = spy.on(alternativeBalancer, "is_affinitized") + + assert.is_true(balancer.route_to_alternative_balancer(_primaryBalancer)) + assert.spy(_primaryBalancer.is_affinitized).was_called() + assert.spy(alternativeBalancer.is_affinitized).was_called() end) end) From c1a006e0fc6cdaaf57487350479a9a61b1ca2a4e Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 08:40:44 -0700 Subject: [PATCH 14/38] Follow same patterns as balancer UTs. --- .../nginx/lua/test/balancer/sticky_test.lua | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua index 44e103c1c6..3d6285aa4b 100644 --- a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua @@ -5,22 +5,33 @@ local util = require("util") local original_ngx = ngx -function mock_ngx(mock) +local function reset_sticky_balancer() + package.loaded["balancer.sticky"] = nil + package.loaded["balancer.sticky_balanced"] = nil + package.loaded["balancer.sticky_persistent"] = nil + + sticky_balanced = require("balancer.sticky_balanced") + sticky_persistent = require("balancer.sticky_persistent") +end + +local function mock_ngx(mock, after_mock_set) local _ngx = mock - setmetatable(_ngx, {__index = _G.ngx}) + setmetatable(_ngx, { __index = ngx }) _G.ngx = _ngx + + if after_mock_set then + after_mock_set() + end + + -- Balancer module caches ngx module, must be reset after mocks were configured. + reset_sticky_balancer() end local function reset_ngx() _G.ngx = original_ngx -end -local function reset_sticky_balancer() - package.loaded["balancer.sticky"] = nil - package.loaded["balancer.sticky_balanced"] = nil - package.loaded["balancer.sticky_persistent"] = nil - sticky_balanced = require("balancer.sticky_balanced") - sticky_persistent = require("balancer.sticky_persistent") + -- Ensure balancer cache is reset. + _G.ngx.ctx.balancer = nil end function get_mocked_cookie_new() @@ -55,7 +66,6 @@ end describe("Sticky", function() before_each(function() mock_ngx({ var = { location_path = "/", host = "test.com" } }) - reset_sticky_balancer() end) after_each(function() @@ -66,7 +76,7 @@ describe("Sticky", function() local test_backend_endpoint= test_backend.endpoints[1].address .. ":" .. test_backend.endpoints[1].port describe("new(backend)", function() - context("when backend specifies cookie name", function() + describe("when backend specifies cookie name", function() local function test(sticky) local sticky_balancer_instance = sticky:new(test_backend) local test_backend_cookie_name = test_backend.sessionAffinityConfig.cookieSessionAffinity.name @@ -77,7 +87,7 @@ describe("Sticky", function() it("returns an instance containing the corresponding cookie name", function() test(sticky_persistent) end) end) - context("when backend does not specify cookie name", function() + describe("when backend does not specify cookie name", function() local function test(sticky) local temp_backend = util.deepcopy(test_backend) temp_backend.sessionAffinityConfig.cookieSessionAffinity.name = nil @@ -95,17 +105,14 @@ describe("Sticky", function() local mocked_cookie_new = cookie.new before_each(function() - package.loaded["balancer.sticky_balanced"] = nil - package.loaded["balancer.sticky_persistent"] = nil - sticky_balanced = require("balancer.sticky_balanced") - sticky_persistent = require("balancer.sticky_persistent") + reset_sticky_balancer() end) after_each(function() cookie.new = mocked_cookie_new end) - context("when client doesn't have a cookie set and location is in cookie_locations", function() + describe("when client doesn't have a cookie set and location is in cookie_locations", function() local function test_pick_endpoint(sticky) local sticky_balancer_instance = sticky:new(test_backend) @@ -180,8 +187,8 @@ describe("Sticky", function() end) end) - context("when client doesn't have a cookie set and cookie_locations contains a matching wildcard location", - function() + describe("when client doesn't have a cookie set and cookie_locations contains a matching wildcard location", function() + before_each(function () ngx.var.host = "dev.test.com" end) @@ -220,7 +227,7 @@ describe("Sticky", function() it("sets a cookie on the client", function() test(sticky_persistent) end) end) - context("when client doesn't have a cookie set and location not in cookie_locations", function() + describe("when client doesn't have a cookie set and location not in cookie_locations", function() local function test_pick_endpoint(sticky) local sticky_balancer_instance = sticky:new(test_backend) @@ -257,7 +264,7 @@ describe("Sticky", function() it("does not set a cookie on the client", function() test_no_cookie(sticky_persistent) end) end) - context("when client has a cookie set", function() + describe("when client has a cookie set", function() local function test_no_cookie(sticky) local s = {} @@ -312,14 +319,13 @@ describe("Sticky", function() before_each(function() mock_ngx({ var = { location_path = "/", host = "test.com" } }) - reset_sticky_balancer() end) after_each(function() reset_ngx() end) - context("when request to upstream fails", function() + describe("when request to upstream fails", function() local function test(sticky, change_on_failure) local sticky_balancer_instance = sticky:new(get_several_test_backends(change_on_failure)) @@ -364,8 +370,7 @@ describe("Sticky", function() end) end) - context("when client doesn't have a cookie set and no host header, matching default server '_'", - function() + describe("when client doesn't have a cookie set and no host header, matching default server '_'", function() before_each(function () ngx.var.host = "not-default-server" ngx.var.server_name = "_" @@ -406,10 +411,7 @@ describe("Sticky", function() local mocked_cookie_new = cookie.new before_each(function() - package.loaded["balancer.sticky_balanced"] = nil - package.loaded["balancer.sticky_persistent"] = nil - sticky_balanced = require("balancer.sticky_balanced") - sticky_persistent = require("balancer.sticky_persistent") + reset_sticky_balancer() end) after_each(function() @@ -465,7 +467,6 @@ describe("Sticky", function() end) it("returns a cookie without SameSite=None when user specifies samesite None and conditional samesite none with unsupported user agent", function() mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"} }) - reset_sticky_balancer() test_set_cookie(sticky_balanced, "None", true, "/", nil) end) end) From 1e6bc30792ac0f63bc726c6dd6d2dd906701eab8 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 09:19:34 -0700 Subject: [PATCH 15/38] UTs for cookies --- rootfs/etc/nginx/lua/balancer/sticky.lua | 4 +- .../nginx/lua/test/balancer/sticky_test.lua | 139 +++++++++++++++++- 2 files changed, 140 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/nginx/lua/balancer/sticky.lua b/rootfs/etc/nginx/lua/balancer/sticky.lua index 112308c8e3..63f3c67850 100644 --- a/rootfs/etc/nginx/lua/balancer/sticky.lua +++ b/rootfs/etc/nginx/lua/balancer/sticky.lua @@ -13,7 +13,7 @@ local setmetatable = setmetatable local _M = balancer_resty:new() local DEFAULT_COOKIE_NAME = "route" -local COOKIE_VALUE_DELIMITER = ":" +local COOKIE_VALUE_DELIMITER = "|" function _M.cookie_name(self) return self.cookie_session_affinity.name or DEFAULT_COOKIE_NAME @@ -55,7 +55,7 @@ function _M.get_cookie_parsed(self) end result.upstream_key = parsed_value[1] - if len <= 2 then + if len > 1 then result.backend_key = parsed_value[2] end diff --git a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua index 3d6285aa4b..8308d56c30 100644 --- a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua @@ -75,6 +75,11 @@ describe("Sticky", function() local test_backend = get_test_backend() local test_backend_endpoint= test_backend.endpoints[1].address .. ":" .. test_backend.endpoints[1].port + local legacy_cookie_value = test_backend_endpoint + local function create_current_cookie_value(backend_key) + return test_backend_endpoint .. "|" .. backend_key + end + describe("new(backend)", function() describe("when backend specifies cookie name", function() local function test(sticky) @@ -99,6 +104,16 @@ describe("Sticky", function() it("returns an instance with 'route' as cookie name", function() test(sticky_balanced) end) it("returns an instance with 'route' as cookie name", function() test(sticky_persistent) end) end) + + describe("backend_key", function() + local function test(sticky) + local sticky_balancer_instance = sticky:new(test_backend) + assert.is_truthy(sticky_balancer_instance.backend_key) + end + + it("calculates at construction time", function() test(sticky_balanced) end) + it("calculates at construction time", function() test(sticky_persistent) end) + end) end) describe("balance()", function() @@ -271,7 +286,7 @@ describe("Sticky", function() cookie.new = function(self) local return_obj = { set = function(v) return false, nil end, - get = function(k) return test_backend_endpoint end, + get = function(k) return legacy_cookie_value end, } s = spy.on(return_obj, "set") return return_obj, false @@ -470,4 +485,126 @@ describe("Sticky", function() test_set_cookie(sticky_balanced, "None", true, "/", nil) end) end) + + describe("get_cookie()", function() + + describe("legacy cookie value", function() + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) + + cookie.new = function(self) + local return_obj = { + set = function(v) return false, nil end, + get = function(k) return legacy_cookie_value end, + } + return return_obj, false + end + + assert.equal(test_backend_endpoint, sticky_balancer_instance.get_cookie(sticky_balancer_instance)) + end + + it("retrieves upstream key value", function() test_with(sticky_balanced) end) + it("retrieves upstream key value", function() test_with(sticky_persistent) end) + end) + + describe("current cookie value", function() + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) + + cookie.new = function(self) + local return_obj = { + set = function(v) return false, nil end, + get = function(k) return create_current_cookie_value(sticky_balancer_instance.backend_key) end, + } + return return_obj, false + end + + assert.equal(test_backend_endpoint, sticky_balancer_instance.get_cookie(sticky_balancer_instance)) + end + + it("retrieves upstream key value", function() test_with(sticky_balanced) end) + it("retrieves upstream key value", function() test_with(sticky_persistent) end) + end) + + end) + + describe("get_cookie_parsed()", function() + + describe("legacy cookie value", function() + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) + + cookie.new = function(self) + local return_obj = { + set = function(v) return false, nil end, + get = function(k) return legacy_cookie_value end, + } + return return_obj, false + end + + local parsed_cookie = sticky_balancer_instance.get_cookie_parsed(sticky_balancer_instance) + + assert.is_truthy(parsed_cookie) + assert.equal(test_backend_endpoint, parsed_cookie.upstream_key) + assert.is_falsy(parsed_cookie.backend_key) + end + + it("retrieves upstream key value", function() test_with(sticky_balanced) end) + it("retrieves upstream key value", function() test_with(sticky_persistent) end) + end) + + describe("current cookie value", function() + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) + + cookie.new = function(self) + local return_obj = { + set = function(v) return false, nil end, + get = function(k) return create_current_cookie_value(sticky_balancer_instance.backend_key) end, + } + return return_obj, false + end + + local parsed_cookie = sticky_balancer_instance.get_cookie_parsed(sticky_balancer_instance) + + assert.is_truthy(parsed_cookie) + assert.equal(test_backend_endpoint, parsed_cookie.upstream_key) + assert.equal(sticky_balancer_instance.backend_key, parsed_cookie.backend_key) + end + + it("retrieves all supported values", function() test_with(sticky_balanced) end) + it("retrieves all supported values", function() test_with(sticky_persistent) end) + end) + + end) + + describe("set_cookie()", function() + + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) + + local cookieSetSpy = {} + cookie.new = function(self) + local return_obj = { + set = function(self, payload) + assert.equal(create_current_cookie_value(sticky_balancer_instance.backend_key), payload.value) + + return true, nil + end, + get = function(k) return nil end, + } + cookieSetSpy = spy.on(return_obj, "set") + + return return_obj, false + end + + sticky_balancer_instance.set_cookie(sticky_balancer_instance, test_backend_endpoint) + + assert.spy(cookieSetSpy).was_called() + end + + it("constructs correct cookie value", function() test_with(sticky_balanced) end) + it("constructs correct cookie value", function() test_with(sticky_persistent) end) + + end) end) From e5b9bcd98379cca46e874251117f8267672e56a7 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 09:28:39 -0700 Subject: [PATCH 16/38] Use same style across the board. --- .../nginx/lua/test/balancer/sticky_test.lua | 155 ++++++++++-------- 1 file changed, 84 insertions(+), 71 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua index 8308d56c30..a0c0ae54f0 100644 --- a/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua +++ b/rootfs/etc/nginx/lua/test/balancer/sticky_test.lua @@ -82,37 +82,37 @@ describe("Sticky", function() describe("new(backend)", function() describe("when backend specifies cookie name", function() - local function test(sticky) - local sticky_balancer_instance = sticky:new(test_backend) + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) local test_backend_cookie_name = test_backend.sessionAffinityConfig.cookieSessionAffinity.name assert.equal(sticky_balancer_instance:cookie_name(), test_backend_cookie_name) end - it("returns an instance containing the corresponding cookie name", function() test(sticky_balanced) end) - it("returns an instance containing the corresponding cookie name", function() test(sticky_persistent) end) + it("returns an instance containing the corresponding cookie name", function() test_with(sticky_balanced) end) + it("returns an instance containing the corresponding cookie name", function() test_with(sticky_persistent) end) end) describe("when backend does not specify cookie name", function() - local function test(sticky) + local function test_with(sticky_balancer_type) local temp_backend = util.deepcopy(test_backend) temp_backend.sessionAffinityConfig.cookieSessionAffinity.name = nil - local sticky_balancer_instance = sticky:new(temp_backend) + local sticky_balancer_instance = sticky_balancer_type:new(temp_backend) local default_cookie_name = "route" assert.equal(sticky_balancer_instance:cookie_name(), default_cookie_name) end - it("returns an instance with 'route' as cookie name", function() test(sticky_balanced) end) - it("returns an instance with 'route' as cookie name", function() test(sticky_persistent) end) + it("returns an instance with 'route' as cookie name", function() test_with(sticky_balanced) end) + it("returns an instance with 'route' as cookie name", function() test_with(sticky_persistent) end) end) describe("backend_key", function() - local function test(sticky) - local sticky_balancer_instance = sticky:new(test_backend) + local function test_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) assert.is_truthy(sticky_balancer_instance.backend_key) end - it("calculates at construction time", function() test(sticky_balanced) end) - it("calculates at construction time", function() test(sticky_persistent) end) + it("calculates at construction time", function() test_with(sticky_balanced) end) + it("calculates at construction time", function() test_with(sticky_persistent) end) end) end) @@ -129,16 +129,16 @@ describe("Sticky", function() describe("when client doesn't have a cookie set and location is in cookie_locations", function() - local function test_pick_endpoint(sticky) - local sticky_balancer_instance = sticky:new(test_backend) + local function test_pick_endpoint_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) local peer = sticky_balancer_instance:balance() assert.equal(test_backend_endpoint, peer) end - it("picks an endpoint for the client", function() test_pick_endpoint(sticky_balanced) end) - it("picks an endpoint for the client", function() test_pick_endpoint(sticky_persistent) end) + it("picks an endpoint for the client", function() test_pick_endpoint_with(sticky_balanced) end) + it("picks an endpoint for the client", function() test_pick_endpoint_with(sticky_persistent) end) - local function test_set_cookie(sticky) + local function test_set_cookie_with(sticky_balancer_type) local s = {} cookie.new = function(self) local cookie_instance = { @@ -159,15 +159,15 @@ describe("Sticky", function() local b = get_test_backend() b.sessionAffinityConfig.cookieSessionAffinity.locations = {} b.sessionAffinityConfig.cookieSessionAffinity.locations["test.com"] = {"/"} - local sticky_balancer_instance = sticky:new(b) + local sticky_balancer_instance = sticky_balancer_type:new(b) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_called() end - it("sets a cookie on the client", function() test_set_cookie(sticky_balanced) end) - it("sets a cookie on the client", function() test_set_cookie(sticky_persistent) end) + it("sets a cookie on the client", function() test_set_cookie_with(sticky_balanced) end) + it("sets a cookie on the client", function() test_set_cookie_with(sticky_persistent) end) - local function test_set_ssl_cookie(sticky) + local function test_set_ssl_cookie_with(sticky_balancer_type) ngx.var.https = "on" local s = {} cookie.new = function(self) @@ -189,17 +189,13 @@ describe("Sticky", function() local b = get_test_backend() b.sessionAffinityConfig.cookieSessionAffinity.locations = {} b.sessionAffinityConfig.cookieSessionAffinity.locations["test.com"] = {"/"} - local sticky_balancer_instance = sticky:new(b) + local sticky_balancer_instance = sticky_balancer_type:new(b) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_called() end - it("sets a secure cookie on the client when being in ssl mode", function() - test_set_ssl_cookie(sticky_balanced) - end) - it("sets a secure cookie on the client when being in ssl mode", function() - test_set_ssl_cookie(sticky_persistent) - end) + it("sets a secure cookie on the client when being in ssl mode", function() test_set_ssl_cookie_with(sticky_balanced) end) + it("sets a secure cookie on the client when being in ssl mode", function() test_set_ssl_cookie_with(sticky_persistent) end) end) describe("when client doesn't have a cookie set and cookie_locations contains a matching wildcard location", function() @@ -211,7 +207,7 @@ describe("Sticky", function() ngx.var.host = "test.com" end) - local function test(sticky) + local function test_with(sticky_balancer_type) local s = {} cookie.new = function(self) local cookie_instance = { @@ -233,27 +229,27 @@ describe("Sticky", function() local b = get_test_backend() b.sessionAffinityConfig.cookieSessionAffinity.locations = {} b.sessionAffinityConfig.cookieSessionAffinity.locations["*.test.com"] = {"/"} - local sticky_balancer_instance = sticky:new(b) + local sticky_balancer_instance = sticky_balancer_type:new(b) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_called() end - it("sets a cookie on the client", function() test(sticky_balanced) end) - it("sets a cookie on the client", function() test(sticky_persistent) end) + it("sets a cookie on the client", function() test_with(sticky_balanced) end) + it("sets a cookie on the client", function() test_with(sticky_persistent) end) end) describe("when client doesn't have a cookie set and location not in cookie_locations", function() - local function test_pick_endpoint(sticky) - local sticky_balancer_instance = sticky:new(test_backend) + local function test_pick_endpoint_with(sticky_balancer_type) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) local peer = sticky_balancer_instance:balance() assert.equal(peer, test_backend_endpoint) end - it("picks an endpoint for the client", function() test_pick_endpoint(sticky_balanced) end) - it("picks an endpoint for the client", function() test_pick_endpoint(sticky_persistent) end) + it("picks an endpoint for the client", function() test_pick_endpoint_with(sticky_balanced) end) + it("picks an endpoint for the client", function() test_pick_endpoint_with(sticky_persistent) end) - local function test_no_cookie(sticky) + local function test_no_cookie_with(sticky_balancer_type) local s = {} cookie.new = function(self) local cookie_instance = { @@ -270,18 +266,18 @@ describe("Sticky", function() s = spy.on(cookie_instance, "set") return cookie_instance, false end - local sticky_balancer_instance = sticky:new(get_test_backend()) + local sticky_balancer_instance = sticky_balancer_type:new(get_test_backend()) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_not_called() end - it("does not set a cookie on the client", function() test_no_cookie(sticky_balanced) end) - it("does not set a cookie on the client", function() test_no_cookie(sticky_persistent) end) + it("does not set a cookie on the client", function() test_no_cookie_with(sticky_balanced) end) + it("does not set a cookie on the client", function() test_no_cookie_with(sticky_persistent) end) end) describe("when client has a cookie set", function() - local function test_no_cookie(sticky) + local function test_no_cookie_with(sticky_balancer_type) local s = {} cookie.new = function(self) local return_obj = { @@ -291,13 +287,13 @@ describe("Sticky", function() s = spy.on(return_obj, "set") return return_obj, false end - local sticky_balancer_instance = sticky:new(test_backend) + local sticky_balancer_instance = sticky_balancer_type:new(test_backend) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_not_called() end - it("does not set a cookie", function() test_no_cookie(sticky_balanced) end) - it("does not set a cookie", function() test_no_cookie(sticky_persistent) end) + it("does not set a cookie", function() test_no_cookie_with(sticky_balanced) end) + it("does not set a cookie", function() test_no_cookie_with(sticky_persistent) end) local function test_correct_endpoint(sticky) local sticky_balancer_instance = sticky:new(test_backend) @@ -342,8 +338,8 @@ describe("Sticky", function() describe("when request to upstream fails", function() - local function test(sticky, change_on_failure) - local sticky_balancer_instance = sticky:new(get_several_test_backends(change_on_failure)) + local function test_with(sticky_balancer_type, change_on_failure) + local sticky_balancer_instance = sticky_balancer_type:new(get_several_test_backends(change_on_failure)) local old_upstream = sticky_balancer_instance:balance() assert.is.Not.Nil(old_upstream) @@ -370,18 +366,11 @@ describe("Sticky", function() end end - it("changes upstream when change_on_failure option is true", function() - test(sticky_balanced, true) - end) - it("changes upstream when change_on_failure option is true", function() - test(sticky_balanced, false) - end) - it("changes upstream when change_on_failure option is true", function() - test(sticky_persistent, true) - end) - it("changes upstream when change_on_failure option is true", function() - test(sticky_persistent, false) - end) + it("changes upstream when change_on_failure option is true", function() test_with(sticky_balanced, true) end) + it("changes upstream when change_on_failure option is true", function() test_with(sticky_persistent, true) end) + + it("changes upstream when change_on_failure option is false", function() test_with(sticky_balanced, false) end) + it("changes upstream when change_on_failure option is false", function() test_with(sticky_persistent, false) end) end) end) @@ -391,7 +380,7 @@ describe("Sticky", function() ngx.var.server_name = "_" end) - local function test(sticky) + local function test_with(sticky_balancer_type) local s = {} cookie.new = function(self) local cookie_instance = { @@ -413,13 +402,13 @@ describe("Sticky", function() local b = get_test_backend() b.sessionAffinityConfig.cookieSessionAffinity.locations = {} b.sessionAffinityConfig.cookieSessionAffinity.locations["_"] = {"/"} - local sticky_balancer_instance = sticky:new(b) + local sticky_balancer_instance = sticky_balancer_type:new(b) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_called() end - it("sets a cookie on the client", function() test(sticky_balanced) end) - it("sets a cookie on the client", function() test(sticky_persistent) end) + it("sets a cookie on the client", function() test_with(sticky_balanced) end) + it("sets a cookie on the client", function() test_with(sticky_persistent) end) end) describe("SameSite settings", function() @@ -433,7 +422,7 @@ describe("Sticky", function() cookie.new = mocked_cookie_new end) - local function test_set_cookie(sticky, samesite, conditional_samesite_none, expected_path, expected_samesite) + local function test_set_cookie_with(sticky_balancer_type, samesite, conditional_samesite_none, expected_path, expected_samesite) local s = {} cookie.new = function(self) local cookie_instance = { @@ -456,33 +445,57 @@ describe("Sticky", function() b.sessionAffinityConfig.cookieSessionAffinity.locations["test.com"] = {"/"} b.sessionAffinityConfig.cookieSessionAffinity.samesite = samesite b.sessionAffinityConfig.cookieSessionAffinity.conditional_samesite_none = conditional_samesite_none - local sticky_balancer_instance = sticky:new(b) + local sticky_balancer_instance = sticky_balancer_type:new(b) assert.has_no.errors(function() sticky_balancer_instance:balance() end) assert.spy(s).was_called() end it("returns a cookie with SameSite=Strict when user specifies samesite strict", function() - test_set_cookie(sticky_balanced, "Strict", false, "/", "Strict") + test_set_cookie_with(sticky_balanced, "Strict", false, "/", "Strict") + end) + it("returns a cookie with SameSite=Strict when user specifies samesite strict and conditional samesite none", function() + test_set_cookie_with(sticky_balanced, "Strict", true, "/", "Strict") + end) + it("returns a cookie with SameSite=Lax when user specifies samesite lax", function() + test_set_cookie_with(sticky_balanced, "Lax", false, "/", "Lax") + end) + it("returns a cookie with SameSite=Lax when user specifies samesite lax and conditional samesite none", function() + test_set_cookie_with(sticky_balanced, "Lax", true, "/", "Lax") + end) + it("returns a cookie with SameSite=None when user specifies samesite None", function() + test_set_cookie_with(sticky_balanced, "None", false, "/", "None") + end) + it("returns a cookie with SameSite=None when user specifies samesite None and conditional samesite none with supported user agent", function() + mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.2704.103 Safari/537.36"} }) + test_set_cookie_with(sticky_balanced, "None", true, "/", "None") + end) + it("returns a cookie without SameSite=None when user specifies samesite None and conditional samesite none with unsupported user agent", function() + mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"} }) + test_set_cookie_with(sticky_balanced, "None", true, "/", nil) + end) + + it("returns a cookie with SameSite=Strict when user specifies samesite strict", function() + test_set_cookie_with(sticky_persistent, "Strict", false, "/", "Strict") end) it("returns a cookie with SameSite=Strict when user specifies samesite strict and conditional samesite none", function() - test_set_cookie(sticky_balanced, "Strict", true, "/", "Strict") + test_set_cookie_with(sticky_persistent, "Strict", true, "/", "Strict") end) it("returns a cookie with SameSite=Lax when user specifies samesite lax", function() - test_set_cookie(sticky_balanced, "Lax", false, "/", "Lax") + test_set_cookie_with(sticky_persistent, "Lax", false, "/", "Lax") end) it("returns a cookie with SameSite=Lax when user specifies samesite lax and conditional samesite none", function() - test_set_cookie(sticky_balanced, "Lax", true, "/", "Lax") + test_set_cookie_with(sticky_persistent, "Lax", true, "/", "Lax") end) it("returns a cookie with SameSite=None when user specifies samesite None", function() - test_set_cookie(sticky_balanced, "None", false, "/", "None") + test_set_cookie_with(sticky_persistent, "None", false, "/", "None") end) it("returns a cookie with SameSite=None when user specifies samesite None and conditional samesite none with supported user agent", function() mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.2704.103 Safari/537.36"} }) - test_set_cookie(sticky_balanced, "None", true, "/", "None") + test_set_cookie_with(sticky_persistent, "None", true, "/", "None") end) it("returns a cookie without SameSite=None when user specifies samesite None and conditional samesite none with unsupported user agent", function() mock_ngx({ var = { location_path = "/", host = "test.com" , http_user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"} }) - test_set_cookie(sticky_balanced, "None", true, "/", nil) + test_set_cookie_with(sticky_persistent, "None", true, "/", nil) end) end) From c89c060e165c7872b15385acc2800425f9c7a4f1 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 10:02:15 -0700 Subject: [PATCH 17/38] Documentation updates. --- docs/developer-guide/getting-started.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/developer-guide/getting-started.md b/docs/developer-guide/getting-started.md index a9f233d99d..68145b43c3 100644 --- a/docs/developer-guide/getting-started.md +++ b/docs/developer-guide/getting-started.md @@ -5,21 +5,25 @@ This document explains how to get started with developing for NGINX Ingress cont ## Prerequisites * [Go 1.14](https://golang.org/dl/) or later - * The project uses [Go modules](https://github.com/golang/go/wiki/Modules). * [Docker](https://docs.docker.com/engine/install/) (v19.03.0 or later with experimental feature on) - * The majority of make tasks run as docker containers. * [Kind](https://kind.sigs.k8s.io/) * [Kubectl](https://kubernetes.io/docs/tasks/tools/) * [Helm](https://helm.sh/docs/intro/install/) +* Optionally install [kubectl plugin](../kubectl-plugin.md) for easier troubleshooting on cluster -## Quick Start +!!! important + The majority of make tasks run as Docker containers. +## Quick Start 1. Fork the repository 2. Clone the repository to any location in your work station 3. Add a `GO111MODULE` environment variable with `export GO111MODULE=on` 4. Run `go mod download` to install dependencies +!!! note + The project uses [Go modules](https://github.com/golang/go/wiki/Modules). + ### Local build Start a local Kubernetes cluster using [kind](https://kind.sigs.k8s.io/), build and deploy the ingress controller From 006c1362fb9880e919830d657fcabacaf3c2ae87 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 10:41:48 -0700 Subject: [PATCH 18/38] Make existing UTs pass. --- internal/ingress/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 15cb16fe19..08ef2d2402 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -1329,7 +1329,7 @@ func mergeAlternativeBackend(ing *ingress.Ingress, priUps *ingress.Backend, altU } } - if ing.ParsedAnnotations.SessionAffinity.CanaryBehavior != "legacy" { + if ing.ParsedAnnotations != nil && ing.ParsedAnnotations.SessionAffinity.CanaryBehavior != "legacy" { priUps.SessionAffinity.DeepCopyInto(&altUps.SessionAffinity) } From 2f3e54d0731089eb3e3e8555b6781065769e201c Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 17:06:15 -0700 Subject: [PATCH 19/38] Added UTs for "sticky" canary behavior. --- .../ingress/controller/controller_test.go | 326 +++++++++++++++++- 1 file changed, 325 insertions(+), 1 deletion(-) diff --git a/internal/ingress/controller/controller_test.go b/internal/ingress/controller/controller_test.go index 22d108ca47..62af4e85d6 100644 --- a/internal/ingress/controller/controller_test.go +++ b/internal/ingress/controller/controller_test.go @@ -44,6 +44,7 @@ import ( "k8s.io/ingress-nginx/internal/ingress/annotations/canary" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/annotations/proxyssl" + "k8s.io/ingress-nginx/internal/ingress/annotations/sessionaffinity" "k8s.io/ingress-nginx/internal/ingress/controller/config" ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config" "k8s.io/ingress-nginx/internal/ingress/controller/store" @@ -786,6 +787,329 @@ func TestMergeAlternativeBackends(t *testing.T) { }, }, }, + "alternative backend gets SessionAffinitySettings configured when CanaryBehavior is 'sticky'": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "example", + }, + Spec: networking.IngressSpec{ + Rules: []networking.IngressRule{ + { + Host: "example.com", + IngressRuleValue: networking.IngressRuleValue{ + HTTP: &networking.HTTPIngressRuleValue{ + Paths: []networking.HTTPIngressPath{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: networking.IngressBackend{ + ServiceName: "http-svc-canary", + ServicePort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 80, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + ParsedAnnotations: &annotations.Ingress{ + SessionAffinity: sessionaffinity.Config{ + CanaryBehavior: "sticky", + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + AlternativeBackends: []string{"example-http-svc-canary-80"}, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + }, + "alternative backend gets SessionAffinitySettings configured when CanaryBehavior is not 'legacy'": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "example", + }, + Spec: networking.IngressSpec{ + Rules: []networking.IngressRule{ + { + Host: "example.com", + IngressRuleValue: networking.IngressRuleValue{ + HTTP: &networking.HTTPIngressRuleValue{ + Paths: []networking.HTTPIngressPath{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: networking.IngressBackend{ + ServiceName: "http-svc-canary", + ServicePort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 80, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + ParsedAnnotations: &annotations.Ingress{ + SessionAffinity: sessionaffinity.Config{ + CanaryBehavior: "", // In fact any value but 'legacy' would do the trick. + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + AlternativeBackends: []string{"example-http-svc-canary-80"}, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + }, + "alternative backend doesn't get SessionAffinitySettings configured when CanaryBehavior is 'legacy'": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "example", + }, + Spec: networking.IngressSpec{ + Rules: []networking.IngressRule{ + { + Host: "example.com", + IngressRuleValue: networking.IngressRuleValue{ + HTTP: &networking.HTTPIngressRuleValue{ + Paths: []networking.HTTPIngressPath{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: networking.IngressBackend{ + ServiceName: "http-svc-canary", + ServicePort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 80, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + ParsedAnnotations: &annotations.Ingress{ + SessionAffinity: sessionaffinity.Config{ + CanaryBehavior: "legacy", + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + map[string]*ingress.Backend{ + "example-http-svc-80": { + Name: "example-http-svc-80", + NoServer: false, + AlternativeBackends: []string{"example-http-svc-canary-80"}, + SessionAffinity: ingress.SessionAffinityConfig{ + AffinityType: "cookie", + AffinityMode: "balanced", + CookieSessionAffinity: ingress.CookieSessionAffinity{ + Name: "test", + }, + }, + }, + "example-http-svc-canary-80": { + Name: "example-http-svc-canary-80", + NoServer: true, + TrafficShapingPolicy: ingress.TrafficShapingPolicy{ + Weight: 20, + }, + }, + }, + map[string]*ingress.Server{ + "example.com": { + Hostname: "example.com", + Locations: []*ingress.Location{ + { + Path: "/", + PathType: &pathTypePrefix, + Backend: "example-http-svc-80", + }, + }, + }, + }, + }, } for title, tc := range testCases { @@ -801,7 +1125,7 @@ func TestMergeAlternativeBackends(t *testing.T) { if !actualUpstream.Equal(expUpstream) { t.Logf("actual upstream %s alternative backends: %s", actualUpstream.Name, actualUpstream.AlternativeBackends) t.Logf("expected upstream %s alternative backends: %s", expUpstream.Name, expUpstream.AlternativeBackends) - t.Errorf("upstream %s was not equal to what was expected: ", upsName) + t.Errorf("upstream %s was not equal to what was expected", actualUpstream.Name) } } From 131b509f31c1c5c78aae1bfe9768916bfbc76ac8 Mon Sep 17 00:00:00 2001 From: wasker Date: Wed, 26 May 2021 17:21:14 -0700 Subject: [PATCH 20/38] Tests for annotations parser. --- .../ingress/annotations/annotations_test.go | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/internal/ingress/annotations/annotations_test.go b/internal/ingress/annotations/annotations_test.go index 1a428e729a..de02a8a16b 100644 --- a/internal/ingress/annotations/annotations_test.go +++ b/internal/ingress/annotations/annotations_test.go @@ -30,19 +30,20 @@ import ( ) var ( - annotationPassthrough = parser.GetAnnotationWithPrefix("ssl-passthrough") - annotationAffinityType = parser.GetAnnotationWithPrefix("affinity") - annotationAffinityMode = parser.GetAnnotationWithPrefix("affinity-mode") - annotationCorsEnabled = parser.GetAnnotationWithPrefix("enable-cors") - annotationCorsAllowMethods = parser.GetAnnotationWithPrefix("cors-allow-methods") - annotationCorsAllowHeaders = parser.GetAnnotationWithPrefix("cors-allow-headers") - annotationCorsExposeHeaders = parser.GetAnnotationWithPrefix("cors-expose-headers") - annotationCorsAllowCredentials = parser.GetAnnotationWithPrefix("cors-allow-credentials") - defaultCorsMethods = "GET, PUT, POST, DELETE, PATCH, OPTIONS" - defaultCorsHeaders = "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization" - annotationAffinityCookieName = parser.GetAnnotationWithPrefix("session-cookie-name") - annotationUpstreamHashBy = parser.GetAnnotationWithPrefix("upstream-hash-by") - annotationCustomHTTPErrors = parser.GetAnnotationWithPrefix("custom-http-errors") + annotationPassthrough = parser.GetAnnotationWithPrefix("ssl-passthrough") + annotationAffinityType = parser.GetAnnotationWithPrefix("affinity") + annotationAffinityMode = parser.GetAnnotationWithPrefix("affinity-mode") + annotationAffinityCanaryBehavior = parser.GetAnnotationWithPrefix("affinity-canary-behavior") + annotationCorsEnabled = parser.GetAnnotationWithPrefix("enable-cors") + annotationCorsAllowMethods = parser.GetAnnotationWithPrefix("cors-allow-methods") + annotationCorsAllowHeaders = parser.GetAnnotationWithPrefix("cors-allow-headers") + annotationCorsExposeHeaders = parser.GetAnnotationWithPrefix("cors-expose-headers") + annotationCorsAllowCredentials = parser.GetAnnotationWithPrefix("cors-allow-credentials") + defaultCorsMethods = "GET, PUT, POST, DELETE, PATCH, OPTIONS" + defaultCorsHeaders = "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization" + annotationAffinityCookieName = parser.GetAnnotationWithPrefix("session-cookie-name") + annotationUpstreamHashBy = parser.GetAnnotationWithPrefix("upstream-hash-by") + annotationCustomHTTPErrors = parser.GetAnnotationWithPrefix("custom-http-errors") ) type mockCfg struct { @@ -162,29 +163,38 @@ func TestAffinitySession(t *testing.T) { ing := buildIngress() fooAnns := []struct { - annotations map[string]string - affinitytype string - affinitymode string - name string + annotations map[string]string + affinitytype string + affinitymode string + cookiename string + canarybehavior string }{ - {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "balanced", annotationAffinityCookieName: "route"}, "cookie", "balanced", "route"}, - {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "persistent", annotationAffinityCookieName: "route1"}, "cookie", "persistent", "route1"}, - {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "balanced", annotationAffinityCookieName: ""}, "cookie", "balanced", "INGRESSCOOKIE"}, - {map[string]string{}, "", "", ""}, - {nil, "", "", ""}, + {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "balanced", annotationAffinityCookieName: "route", annotationAffinityCanaryBehavior: ""}, "cookie", "balanced", "route", ""}, + {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "persistent", annotationAffinityCookieName: "route1", annotationAffinityCanaryBehavior: "sticky"}, "cookie", "persistent", "route1", "sticky"}, + {map[string]string{annotationAffinityType: "cookie", annotationAffinityMode: "balanced", annotationAffinityCookieName: "", annotationAffinityCanaryBehavior: "legacy"}, "cookie", "balanced", "INGRESSCOOKIE", "legacy"}, + {map[string]string{}, "", "", "", ""}, + {nil, "", "", "", ""}, } for _, foo := range fooAnns { ing.SetAnnotations(foo.annotations) r := ec.Extract(ing).SessionAffinity - t.Logf("Testing pass %v %v", foo.affinitytype, foo.name) + t.Logf("Testing pass %v %v", foo.affinitytype, foo.cookiename) + + if r.Type != foo.affinitytype { + t.Errorf("Returned %v but expected %v for Type", r.Type, foo.affinitytype) + } if r.Mode != foo.affinitymode { - t.Errorf("Returned %v but expected %v for Name", r.Mode, foo.affinitymode) + t.Errorf("Returned %v but expected %v for Mode", r.Mode, foo.affinitymode) + } + + if r.CanaryBehavior != foo.canarybehavior { + t.Errorf("Returned %v but expected %v for CanaryBehavior", r.CanaryBehavior, foo.canarybehavior) } - if r.Cookie.Name != foo.name { - t.Errorf("Returned %v but expected %v for Name", r.Cookie.Name, foo.name) + if r.Cookie.Name != foo.cookiename { + t.Errorf("Returned %v but expected %v for Cookie.Name", r.Cookie.Name, foo.cookiename) } } } From dcfafbaefdee56e40b8990769a4ba288710ba1c0 Mon Sep 17 00:00:00 2001 From: wasker Date: Mon, 14 Jun 2021 11:23:40 -0700 Subject: [PATCH 21/38] Fixed lua linter errors. --- rootfs/etc/nginx/lua/balancer.lua | 3 ++- rootfs/etc/nginx/lua/balancer/chashsubset.lua | 2 +- rootfs/etc/nginx/lua/balancer/ewma.lua | 2 +- rootfs/etc/nginx/lua/balancer/resty.lua | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rootfs/etc/nginx/lua/balancer.lua b/rootfs/etc/nginx/lua/balancer.lua index 81440a4151..e83257a6f9 100644 --- a/rootfs/etc/nginx/lua/balancer.lua +++ b/rootfs/etc/nginx/lua/balancer.lua @@ -210,7 +210,8 @@ local function route_to_alternative_balancer(balancer) end if alternative_balancer.is_affinitized(alternative_balancer) then - -- If request is affinitized to an alternative balancer, instruct caller to switch to alternative. + -- If request is affinitized to an alternative balancer, instruct caller to + -- switch to alternative. return true end diff --git a/rootfs/etc/nginx/lua/balancer/chashsubset.lua b/rootfs/etc/nginx/lua/balancer/chashsubset.lua index 1bd625d4d5..d9ceb471e5 100644 --- a/rootfs/etc/nginx/lua/balancer/chashsubset.lua +++ b/rootfs/etc/nginx/lua/balancer/chashsubset.lua @@ -68,7 +68,7 @@ function _M.new(self, backend) return o end -function _M.is_affinitized(self) +function _M.is_affinitized() return false end diff --git a/rootfs/etc/nginx/lua/balancer/ewma.lua b/rootfs/etc/nginx/lua/balancer/ewma.lua index c28760b96e..681866dc16 100644 --- a/rootfs/etc/nginx/lua/balancer/ewma.lua +++ b/rootfs/etc/nginx/lua/balancer/ewma.lua @@ -170,7 +170,7 @@ local function calculate_slow_start_ewma(self) return total_ewma / endpoints_count end -function _M.is_affinitized(self) +function _M.is_affinitized() return false end diff --git a/rootfs/etc/nginx/lua/balancer/resty.lua b/rootfs/etc/nginx/lua/balancer/resty.lua index ee9d698df7..12b24be14e 100644 --- a/rootfs/etc/nginx/lua/balancer/resty.lua +++ b/rootfs/etc/nginx/lua/balancer/resty.lua @@ -14,7 +14,7 @@ function _M.new(self, o) return o end -function _M.is_affinitized(self) +function _M.is_affinitized() return false end From bea476873484d4ea0302b21416126c71f9760a0d Mon Sep 17 00:00:00 2001 From: wasker Date: Mon, 21 Jun 2021 10:46:00 -0700 Subject: [PATCH 22/38] Revert unnecessary changes. --- docs/developer-guide/getting-started.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/developer-guide/getting-started.md b/docs/developer-guide/getting-started.md index 68145b43c3..eb5e7cae5e 100644 --- a/docs/developer-guide/getting-started.md +++ b/docs/developer-guide/getting-started.md @@ -4,26 +4,24 @@ This document explains how to get started with developing for NGINX Ingress cont ## Prerequisites -* [Go 1.14](https://golang.org/dl/) or later -* [Docker](https://docs.docker.com/engine/install/) (v19.03.0 or later with experimental feature on) -* [Kind](https://kind.sigs.k8s.io/) -* [Kubectl](https://kubernetes.io/docs/tasks/tools/) -* [Helm](https://helm.sh/docs/intro/install/) -* Optionally install [kubectl plugin](../kubectl-plugin.md) for easier troubleshooting on cluster +Install [Go 1.14](https://golang.org/dl/) or later. + +!!! note + The project uses [Go Modules](https://github.com/golang/go/wiki/Modules) + +Install [Docker](https://docs.docker.com/engine/install/) (v19.03.0 or later with experimental feature on) !!! important - The majority of make tasks run as Docker containers. + The majority of make tasks run as docker containers ## Quick Start + 1. Fork the repository 2. Clone the repository to any location in your work station 3. Add a `GO111MODULE` environment variable with `export GO111MODULE=on` 4. Run `go mod download` to install dependencies -!!! note - The project uses [Go modules](https://github.com/golang/go/wiki/Modules). - ### Local build Start a local Kubernetes cluster using [kind](https://kind.sigs.k8s.io/), build and deploy the ingress controller From c15b7c5e0f8f73b8a9e6ab07989f973891ae4ec4 Mon Sep 17 00:00:00 2001 From: Ricardo Katz Date: Wed, 23 Jun 2021 18:20:10 -0300 Subject: [PATCH 23/38] Drop v1beta1 from ingress nginx (#7156) * Drop v1beta1 from ingress nginx Signed-off-by: Ricardo Pchevuzinske Katz * Fix intorstr logic in controller Signed-off-by: Ricardo Pchevuzinske Katz * fixing admission Signed-off-by: Ricardo Pchevuzinske Katz * more intorstr fixing * correct template rendering Signed-off-by: Ricardo Pchevuzinske Katz * Fix e2e tests for v1 api Signed-off-by: Ricardo Pchevuzinske Katz * Fix gofmt errors * This is finally working...almost there... Signed-off-by: Ricardo Pchevuzinske Katz * Re-add removed validation of AdmissionReview --- .github/workflows/ci.yaml | 4 +- charts/ingress-nginx/templates/NOTES.txt | 2 +- .../validating-webhook.yaml | 5 +- cmd/nginx/main.go | 41 ++-- cmd/plugin/commands/ingresses/ingresses.go | 29 ++- cmd/plugin/commands/lint/main.go | 2 +- cmd/plugin/lints/ingress.go | 2 +- cmd/plugin/request/request.go | 4 +- .../provider/aws/deploy-tls-termination.yaml | 5 +- deploy/static/provider/aws/deploy.yaml | 5 +- deploy/static/provider/baremetal/deploy.yaml | 5 +- deploy/static/provider/cloud/deploy.yaml | 5 +- deploy/static/provider/do/deploy.yaml | 5 +- deploy/static/provider/exoscale/deploy.yaml | 5 +- deploy/static/provider/kind/deploy.yaml | 5 +- deploy/static/provider/scw/deploy.yaml | 5 +- .../affinity/cookie/ingress-samesite.yaml | 4 +- docs/examples/auth/basic/README.md | 2 +- docs/examples/auth/external-auth/README.md | 4 +- docs/examples/auth/external-auth/ingress.yaml | 2 +- .../dashboard-ingress.yaml | 4 +- docs/examples/chashsubset/deployment.yaml | 2 +- .../docker-registry/ingress-with-tls.yaml | 2 +- .../docker-registry/ingress-without-tls.yaml | 2 +- docs/examples/multi-tls/multi-tls.yaml | 2 +- docs/examples/rewrite/README.md | 4 +- docs/examples/static-ip/nginx-ingress.yaml | 2 +- docs/examples/tls-termination/ingress.yaml | 2 +- docs/troubleshooting.md | 10 +- docs/user-guide/ingress-path-matching.md | 8 +- go.mod | 22 +- go.sum | 175 +++++++++++--- internal/admission/controller/convert.go | 90 ------- internal/admission/controller/main.go | 35 +-- internal/admission/controller/main_test.go | 4 +- internal/admission/controller/server.go | 2 - internal/ingress/annotations/alias/main.go | 2 +- .../ingress/annotations/alias/main_test.go | 2 +- internal/ingress/annotations/annotations.go | 2 +- .../ingress/annotations/annotations_test.go | 21 +- internal/ingress/annotations/auth/main.go | 2 +- .../ingress/annotations/auth/main_test.go | 21 +- internal/ingress/annotations/authreq/main.go | 2 +- .../ingress/annotations/authreq/main_test.go | 22 +- .../ingress/annotations/authreqglobal/main.go | 2 +- .../annotations/authreqglobal/main_test.go | 22 +- internal/ingress/annotations/authtls/main.go | 2 +- .../ingress/annotations/authtls/main_test.go | 21 +- .../annotations/backendprotocol/main.go | 2 +- .../annotations/backendprotocol/main_test.go | 14 +- internal/ingress/annotations/canary/main.go | 2 +- .../ingress/annotations/canary/main_test.go | 21 +- internal/ingress/annotations/class/main.go | 2 +- .../ingress/annotations/class/main_test.go | 2 +- .../annotations/clientbodybuffersize/main.go | 2 +- .../clientbodybuffersize/main_test.go | 2 +- .../ingress/annotations/connection/main.go | 2 +- .../annotations/connection/main_test.go | 2 +- internal/ingress/annotations/cors/main.go | 2 +- .../ingress/annotations/cors/main_test.go | 21 +- .../annotations/customhttperrors/main.go | 2 +- .../annotations/customhttperrors/main_test.go | 14 +- .../annotations/defaultbackend/main.go | 2 +- .../annotations/defaultbackend/main_test.go | 22 +- internal/ingress/annotations/fastcgi/main.go | 2 +- .../ingress/annotations/fastcgi/main_test.go | 14 +- .../annotations/globalratelimit/main.go | 2 +- .../annotations/globalratelimit/main_test.go | 21 +- .../annotations/http2pushpreload/main.go | 2 +- .../annotations/http2pushpreload/main_test.go | 2 +- internal/ingress/annotations/influxdb/main.go | 2 +- .../ingress/annotations/influxdb/main_test.go | 21 +- .../ingress/annotations/ipwhitelist/main.go | 2 +- .../annotations/ipwhitelist/main_test.go | 21 +- .../ingress/annotations/loadbalancing/main.go | 2 +- .../annotations/loadbalancing/main_test.go | 2 +- internal/ingress/annotations/log/main.go | 2 +- internal/ingress/annotations/log/main_test.go | 21 +- internal/ingress/annotations/mirror/main.go | 2 +- .../ingress/annotations/mirror/main_test.go | 2 +- .../ingress/annotations/modsecurity/main.go | 2 +- .../annotations/modsecurity/main_test.go | 2 +- .../ingress/annotations/opentracing/main.go | 2 +- .../annotations/opentracing/main_test.go | 21 +- internal/ingress/annotations/parser/main.go | 2 +- .../ingress/annotations/parser/main_test.go | 2 +- .../annotations/portinredirect/main.go | 2 +- .../annotations/portinredirect/main_test.go | 21 +- internal/ingress/annotations/proxy/main.go | 2 +- .../ingress/annotations/proxy/main_test.go | 21 +- internal/ingress/annotations/proxyssl/main.go | 2 +- .../ingress/annotations/proxyssl/main_test.go | 21 +- .../ingress/annotations/ratelimit/main.go | 2 +- .../annotations/ratelimit/main_test.go | 21 +- .../ingress/annotations/redirect/redirect.go | 2 +- .../annotations/redirect/redirect_test.go | 2 +- internal/ingress/annotations/rewrite/main.go | 2 +- .../ingress/annotations/rewrite/main_test.go | 21 +- internal/ingress/annotations/satisfy/main.go | 2 +- .../ingress/annotations/satisfy/main_test.go | 21 +- .../annotations/secureupstream/main.go | 2 +- .../annotations/secureupstream/main_test.go | 21 +- .../ingress/annotations/serversnippet/main.go | 2 +- .../annotations/serversnippet/main_test.go | 2 +- .../annotations/serviceupstream/main.go | 2 +- .../annotations/serviceupstream/main_test.go | 21 +- .../annotations/sessionaffinity/main.go | 2 +- .../annotations/sessionaffinity/main_test.go | 22 +- internal/ingress/annotations/snippet/main.go | 2 +- .../ingress/annotations/snippet/main_test.go | 2 +- .../ingress/annotations/sslcipher/main.go | 2 +- .../annotations/sslcipher/main_test.go | 2 +- .../annotations/sslpassthrough/main.go | 2 +- .../annotations/sslpassthrough/main_test.go | 14 +- .../annotations/upstreamhashby/main.go | 2 +- .../annotations/upstreamhashby/main_test.go | 2 +- .../ingress/annotations/upstreamvhost/main.go | 2 +- .../annotations/upstreamvhost/main_test.go | 2 +- .../annotations/xforwardedprefix/main.go | 2 +- .../annotations/xforwardedprefix/main_test.go | 2 +- internal/ingress/controller/controller.go | 65 ++--- .../ingress/controller/controller_test.go | 228 ++++++++++-------- .../ingress/controller/store/backend_ssl.go | 2 +- internal/ingress/controller/store/ingress.go | 2 +- internal/ingress/controller/store/store.go | 28 +-- .../ingress/controller/store/store_test.go | 100 +++++--- .../ingress/controller/template/template.go | 21 +- .../controller/template/template_test.go | 37 ++- internal/ingress/controller/util.go | 27 ++- internal/ingress/status/status.go | 2 +- internal/ingress/status/status_test.go | 8 +- internal/ingress/types.go | 2 +- internal/k8s/main.go | 28 +-- test/e2e/admission/admission.go | 78 +----- test/e2e/annotations/affinity.go | 28 ++- test/e2e/annotations/auth.go | 2 +- test/e2e/annotations/canary.go | 2 +- test/e2e/annotations/customhttperrors.go | 2 +- test/e2e/annotations/satisfy.go | 2 +- test/e2e/defaultbackend/with_hosts.go | 13 +- test/e2e/framework/framework.go | 68 ++++-- test/e2e/framework/k8s.go | 8 +- test/e2e/framework/util.go | 4 +- test/e2e/ingress/multiple_rules.go | 26 +- test/e2e/ingress/pathtype_exact.go | 7 +- test/e2e/ingress/pathtype_mixed.go | 7 +- test/e2e/ingress/without_host.go | 13 +- test/e2e/leaks/lua_ssl.go | 2 +- test/e2e/lua/dynamic_certificates.go | 18 +- test/e2e/lua/dynamic_configuration.go | 6 +- test/e2e/servicebackend/service_backend.go | 25 +- .../servicebackend/service_externalname.go | 21 +- test/e2e/settings/disable_catch_all.go | 13 +- test/e2e/settings/global_external_auth.go | 2 +- test/e2e/settings/ingress_class.go | 27 +-- test/e2e/settings/no_auth_locations.go | 26 +- test/e2e/settings/server_tokens.go | 15 +- test/e2e/status/update.go | 6 +- 158 files changed, 1191 insertions(+), 925 deletions(-) delete mode 100644 internal/admission/controller/convert.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d121c2fa39..cdd3a737fe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -65,11 +65,11 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set up Go 1.15 + - name: Set up Go 1.16 id: go uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.16 - name: Set up Docker Buildx id: buildx diff --git a/charts/ingress-nginx/templates/NOTES.txt b/charts/ingress-nginx/templates/NOTES.txt index 60fb2c1f62..2eebba3686 100644 --- a/charts/ingress-nginx/templates/NOTES.txt +++ b/charts/ingress-nginx/templates/NOTES.txt @@ -29,7 +29,7 @@ Get the application URL by running these commands: An example Ingress that makes use of the controller: - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml b/charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml index 2f3dd77848..712f74fdd3 100644 --- a/charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml +++ b/charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml @@ -18,7 +18,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -28,12 +28,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: {{ .Release.Namespace | quote }} name: {{ include "ingress-nginx.controller.fullname" . }}-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses {{- if .Values.controller.admissionWebhooks.timeoutSeconds }} timeoutSeconds: {{ .Values.controller.admissionWebhooks.timeoutSeconds }} {{- end }} diff --git a/cmd/nginx/main.go b/cmd/nginx/main.go index 9c245baa12..b4d3932a1e 100644 --- a/cmd/nginx/main.go +++ b/cmd/nginx/main.go @@ -104,36 +104,29 @@ func main() { conf.FakeCertificate = ssl.GetFakeSSLCert() klog.InfoS("SSL fake certificate created", "file", conf.FakeCertificate.PemFileName) - var isNetworkingIngressAvailable bool - - isNetworkingIngressAvailable, k8s.IsIngressV1Beta1Ready, _ = k8s.NetworkingIngressAvailable(kubeClient) - if !isNetworkingIngressAvailable { - klog.Fatalf("ingress-nginx requires Kubernetes v1.14.0 or higher") + if !k8s.NetworkingIngressAvailable(kubeClient) { + klog.Fatalf("ingress-nginx requires Kubernetes v1.19.0 or higher") } - if k8s.IsIngressV1Beta1Ready { - klog.InfoS("Enabling new Ingress features available since Kubernetes v1.18") - k8s.IngressClass, err = kubeClient.NetworkingV1beta1().IngressClasses(). - Get(context.TODO(), class.IngressClass, metav1.GetOptions{}) - if err != nil { - if !errors.IsNotFound(err) { - if !errors.IsUnauthorized(err) && !errors.IsForbidden(err) { - klog.Fatalf("Error searching IngressClass: %v", err) - } - - klog.ErrorS(err, "Searching IngressClass", "class", class.IngressClass) + k8s.IngressClass, err = kubeClient.NetworkingV1().IngressClasses(). + Get(context.TODO(), class.IngressClass, metav1.GetOptions{}) + if err != nil { + if !errors.IsNotFound(err) { + if !errors.IsUnauthorized(err) && !errors.IsForbidden(err) { + klog.Fatalf("Error searching IngressClass: %v", err) } + klog.ErrorS(err, "Searching IngressClass", "class", class.IngressClass) + } - klog.Warningf("No IngressClass resource with name %v found. Only annotation will be used.", class.IngressClass) + klog.Warningf("No IngressClass resource with name %v found. Only annotation will be used.", class.IngressClass) + // TODO: remove once this is fixed in client-go + k8s.IngressClass = nil - // TODO: remove once this is fixed in client-go - k8s.IngressClass = nil - } + } - if k8s.IngressClass != nil && k8s.IngressClass.Spec.Controller != k8s.IngressNGINXController { - klog.Errorf(`Invalid IngressClass (Spec.Controller) value "%v". Should be "%v"`, k8s.IngressClass.Spec.Controller, k8s.IngressNGINXController) - klog.Fatalf("IngressClass with name %v is not valid for ingress-nginx (invalid Spec.Controller)", class.IngressClass) - } + if k8s.IngressClass != nil && k8s.IngressClass.Spec.Controller != k8s.IngressNGINXController { + klog.Errorf(`Invalid IngressClass (Spec.Controller) value "%v". Should be "%v"`, k8s.IngressClass.Spec.Controller, k8s.IngressNGINXController) + klog.Fatalf("IngressClass with name %v is not valid for ingress-nginx (invalid Spec.Controller)", class.IngressClass) } conf.Client = kubeClient diff --git a/cmd/plugin/commands/ingresses/ingresses.go b/cmd/plugin/commands/ingresses/ingresses.go index 38da629302..4227053200 100644 --- a/cmd/plugin/commands/ingresses/ingresses.go +++ b/cmd/plugin/commands/ingresses/ingresses.go @@ -22,7 +22,8 @@ import ( "text/tabwriter" "github.com/spf13/cobra" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/ingress-nginx/cmd/plugin/request" @@ -157,9 +158,10 @@ func getIngressRows(ingresses *[]networking.Ingress) []ingressRow { defaultBackendService := "" defaultBackendPort := "" - if ing.Spec.Backend != nil { - defaultBackendService = ing.Spec.Backend.ServiceName - defaultBackendPort = ing.Spec.Backend.ServicePort.String() + if ing.Spec.DefaultBackend != nil { + name, port := serviceToNameAndPort(ing.Spec.DefaultBackend.Service) + defaultBackendService = name + defaultBackendPort = port.String() } // Handle catch-all ingress @@ -197,14 +199,15 @@ func getIngressRows(ingresses *[]networking.Ingress) []ingressRow { } for _, path := range rule.HTTP.Paths { + svcName, svcPort := serviceToNameAndPort(path.Backend.Service) row := ingressRow{ Namespace: ing.Namespace, IngressName: ing.Name, Host: rule.Host, Path: path.Path, TLS: hasTLS, - ServiceName: path.Backend.ServiceName, - ServicePort: path.Backend.ServicePort.String(), + ServiceName: svcName, + ServicePort: svcPort.String(), Address: address, } @@ -215,3 +218,17 @@ func getIngressRows(ingresses *[]networking.Ingress) []ingressRow { return rows } + +func serviceToNameAndPort(svc *networking.IngressServiceBackend) (string, intstr.IntOrString) { + var svcName string + if svc != nil { + svcName = svc.Name + if svc.Port.Number > 0 { + return svcName, intstr.FromInt(int(svc.Port.Number)) + } + if svc.Port.Name != "" { + return svcName, intstr.FromString(svc.Port.String()) + } + } + return "", intstr.IntOrString{} +} diff --git a/cmd/plugin/commands/lint/main.go b/cmd/plugin/commands/lint/main.go index d120e93114..2daf8eb870 100644 --- a/cmd/plugin/commands/lint/main.go +++ b/cmd/plugin/commands/lint/main.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" appsv1 "k8s.io/api/apps/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" kmeta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/genericclioptions" diff --git a/cmd/plugin/lints/ingress.go b/cmd/plugin/lints/ingress.go index 0de4661f4e..ea08bfd8bc 100644 --- a/cmd/plugin/lints/ingress.go +++ b/cmd/plugin/lints/ingress.go @@ -20,7 +20,7 @@ import ( "fmt" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" kmeta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/cmd/plugin/util" ) diff --git a/cmd/plugin/request/request.go b/cmd/plugin/request/request.go index b8bc4eaae5..cae90e9d2d 100644 --- a/cmd/plugin/request/request.go +++ b/cmd/plugin/request/request.go @@ -22,12 +22,12 @@ import ( appsv1 "k8s.io/api/apps/v1" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/genericclioptions" appsv1client "k8s.io/client-go/kubernetes/typed/apps/v1" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" - typednetworking "k8s.io/client-go/kubernetes/typed/networking/v1beta1" + typednetworking "k8s.io/client-go/kubernetes/typed/networking/v1" "k8s.io/ingress-nginx/cmd/plugin/util" ) diff --git a/deploy/static/provider/aws/deploy-tls-termination.yaml b/deploy/static/provider/aws/deploy-tls-termination.yaml index 36ad195191..f05a0c7826 100644 --- a/deploy/static/provider/aws/deploy-tls-termination.yaml +++ b/deploy/static/provider/aws/deploy-tls-termination.yaml @@ -440,7 +440,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -450,12 +450,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/aws/deploy.yaml b/deploy/static/provider/aws/deploy.yaml index 6233febd94..8fcfc6f7b6 100644 --- a/deploy/static/provider/aws/deploy.yaml +++ b/deploy/static/provider/aws/deploy.yaml @@ -427,7 +427,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -437,12 +437,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/baremetal/deploy.yaml b/deploy/static/provider/baremetal/deploy.yaml index 01dbd0376b..645ef4cccf 100644 --- a/deploy/static/provider/baremetal/deploy.yaml +++ b/deploy/static/provider/baremetal/deploy.yaml @@ -422,7 +422,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -432,12 +432,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/cloud/deploy.yaml b/deploy/static/provider/cloud/deploy.yaml index ef156a1ad1..ef77b66395 100644 --- a/deploy/static/provider/cloud/deploy.yaml +++ b/deploy/static/provider/cloud/deploy.yaml @@ -424,7 +424,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -434,12 +434,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/do/deploy.yaml b/deploy/static/provider/do/deploy.yaml index e11912f95c..df2be2afd6 100644 --- a/deploy/static/provider/do/deploy.yaml +++ b/deploy/static/provider/do/deploy.yaml @@ -426,7 +426,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -436,12 +436,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/exoscale/deploy.yaml b/deploy/static/provider/exoscale/deploy.yaml index 4ca8022e04..6ecf564865 100644 --- a/deploy/static/provider/exoscale/deploy.yaml +++ b/deploy/static/provider/exoscale/deploy.yaml @@ -432,7 +432,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -442,12 +442,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/kind/deploy.yaml b/deploy/static/provider/kind/deploy.yaml index e949e85979..dd3b8b606f 100644 --- a/deploy/static/provider/kind/deploy.yaml +++ b/deploy/static/provider/kind/deploy.yaml @@ -434,7 +434,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -444,12 +444,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/deploy/static/provider/scw/deploy.yaml b/deploy/static/provider/scw/deploy.yaml index 4647422626..6619d5d597 100644 --- a/deploy/static/provider/scw/deploy.yaml +++ b/deploy/static/provider/scw/deploy.yaml @@ -426,7 +426,7 @@ webhooks: - apiGroups: - networking.k8s.io apiVersions: - - v1beta1 + - v1 operations: - CREATE - UPDATE @@ -436,12 +436,11 @@ webhooks: sideEffects: None admissionReviewVersions: - v1 - - v1beta1 clientConfig: service: namespace: ingress-nginx name: ingress-nginx-controller-admission - path: /networking/v1beta1/ingresses + path: /networking/v1/ingresses --- # Source: ingress-nginx/templates/admission-webhooks/job-patch/serviceaccount.yaml apiVersion: v1 diff --git a/docs/examples/affinity/cookie/ingress-samesite.yaml b/docs/examples/affinity/cookie/ingress-samesite.yaml index 42d1c2e2df..b3f8f4b20c 100644 --- a/docs/examples/affinity/cookie/ingress-samesite.yaml +++ b/docs/examples/affinity/cookie/ingress-samesite.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: cookie-samesite-none @@ -19,7 +19,7 @@ spec: servicePort: 80 path: / --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: cookie-samesite-strict diff --git a/docs/examples/auth/basic/README.md b/docs/examples/auth/basic/README.md index 194bacb3bf..a5fa579e00 100644 --- a/docs/examples/auth/basic/README.md +++ b/docs/examples/auth/basic/README.md @@ -30,7 +30,7 @@ type: Opaque ```console echo " -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-with-auth diff --git a/docs/examples/auth/external-auth/README.md b/docs/examples/auth/external-auth/README.md index a081383731..235cca9cbb 100644 --- a/docs/examples/auth/external-auth/README.md +++ b/docs/examples/auth/external-auth/README.md @@ -13,7 +13,7 @@ NAME HOSTS ADDRESS PORTS AGE external-auth external-auth-01.sample.com 172.17.4.99 80 13s $ kubectl get ing external-auth -o yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: @@ -23,7 +23,7 @@ metadata: name: external-auth namespace: default resourceVersion: "2068378" - selfLink: /apis/networking/v1beta1/namespaces/default/ingresses/external-auth + selfLink: /apis/networking/v1/namespaces/default/ingresses/external-auth uid: 5c388f1d-8970-11e6-9004-080027d2dc94 spec: rules: diff --git a/docs/examples/auth/external-auth/ingress.yaml b/docs/examples/auth/external-auth/ingress.yaml index c7a87a240f..2a58ca2e30 100644 --- a/docs/examples/auth/external-auth/ingress.yaml +++ b/docs/examples/auth/external-auth/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/auth/oauth-external-auth/dashboard-ingress.yaml b/docs/examples/auth/oauth-external-auth/dashboard-ingress.yaml index ade56a9e63..725bf1dc5e 100644 --- a/docs/examples/auth/oauth-external-auth/dashboard-ingress.yaml +++ b/docs/examples/auth/oauth-external-auth/dashboard-ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: @@ -18,7 +18,7 @@ spec: --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: oauth2-proxy diff --git a/docs/examples/chashsubset/deployment.yaml b/docs/examples/chashsubset/deployment.yaml index 9b1bafcb17..82fdc7ac00 100644 --- a/docs/examples/chashsubset/deployment.yaml +++ b/docs/examples/chashsubset/deployment.yaml @@ -54,7 +54,7 @@ spec: targetPort: 8080 --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/docker-registry/ingress-with-tls.yaml b/docs/examples/docker-registry/ingress-with-tls.yaml index fc277b20f1..11ccf66277 100644 --- a/docs/examples/docker-registry/ingress-with-tls.yaml +++ b/docs/examples/docker-registry/ingress-with-tls.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/docker-registry/ingress-without-tls.yaml b/docs/examples/docker-registry/ingress-without-tls.yaml index 1ce1b98fb0..2d713cb8c2 100644 --- a/docs/examples/docker-registry/ingress-without-tls.yaml +++ b/docs/examples/docker-registry/ingress-without-tls.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/multi-tls/multi-tls.yaml b/docs/examples/multi-tls/multi-tls.yaml index c616501be3..29395a2853 100644 --- a/docs/examples/multi-tls/multi-tls.yaml +++ b/docs/examples/multi-tls/multi-tls.yaml @@ -92,7 +92,7 @@ spec: fieldPath: status.podIP --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: foo-tls diff --git a/docs/examples/rewrite/README.md b/docs/examples/rewrite/README.md index 3ad5e4fcdd..824b0966f4 100644 --- a/docs/examples/rewrite/README.md +++ b/docs/examples/rewrite/README.md @@ -34,7 +34,7 @@ Create an Ingress rule with a rewrite annotation: ```console $ echo ' -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: @@ -66,7 +66,7 @@ For example, the ingress definition above will result in the following rewrites: Create an Ingress rule with an app-root annotation: ``` $ echo " -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/static-ip/nginx-ingress.yaml b/docs/examples/static-ip/nginx-ingress.yaml index aa4877e56f..358942f5c5 100644 --- a/docs/examples/static-ip/nginx-ingress.yaml +++ b/docs/examples/static-ip/nginx-ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress-nginx diff --git a/docs/examples/tls-termination/ingress.yaml b/docs/examples/tls-termination/ingress.yaml index fc97b3707e..2e989d1b03 100644 --- a/docs/examples/tls-termination/ingress.yaml +++ b/docs/examples/tls-termination/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-test diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 1707aa0e25..7ecd71c652 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -32,7 +32,7 @@ Rules: /tea tea-svc:80 () /coffee coffee-svc:80 () Annotations: - kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"networking.k8s.io/v1beta1","kind":"Ingress","metadata":{"annotations":{},"name":"cafe-ingress","namespace":"default","selfLink":"/apis/networking/v1beta1/namespaces/default/ingresses/cafe-ingress"},"spec":{"rules":[{"host":"cafe.com","http":{"paths":[{"backend":{"serviceName":"tea-svc","servicePort":80},"path":"/tea"},{"backend":{"serviceName":"coffee-svc","servicePort":80},"path":"/coffee"}]}}]},"status":{"loadBalancer":{"ingress":[{"ip":"169.48.142.110"}]}}} + kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"name":"cafe-ingress","namespace":"default","selfLink":"/apis/networking/v1/namespaces/default/ingresses/cafe-ingress"},"spec":{"rules":[{"host":"cafe.com","http":{"paths":[{"backend":{"serviceName":"tea-svc","servicePort":80},"path":"/tea"},{"backend":{"serviceName":"coffee-svc","servicePort":80},"path":"/coffee"}]}}]},"status":{"loadBalancer":{"ingress":[{"ip":"169.48.142.110"}]}}} Events: Type Reason Age From Message @@ -208,9 +208,9 @@ $ kubectl exec test-701078429-s5kca -- curl --cacert /var/run/secrets/kubernetes "/apis/apps", "/apis/apps/v1alpha1", "/apis/authentication.k8s.io", - "/apis/authentication.k8s.io/v1beta1", + "/apis/authentication.k8s.io/v1", "/apis/authorization.k8s.io", - "/apis/authorization.k8s.io/v1beta1", + "/apis/authorization.k8s.io/v1", "/apis/autoscaling", "/apis/autoscaling/v1", "/apis/batch", @@ -219,13 +219,13 @@ $ kubectl exec test-701078429-s5kca -- curl --cacert /var/run/secrets/kubernetes "/apis/certificates.k8s.io", "/apis/certificates.k8s.io/v1alpha1", "/apis/networking", - "/apis/networking/v1beta1", + "/apis/networking/v1", "/apis/policy", "/apis/policy/v1alpha1", "/apis/rbac.authorization.k8s.io", "/apis/rbac.authorization.k8s.io/v1alpha1", "/apis/storage.k8s.io", - "/apis/storage.k8s.io/v1beta1", + "/apis/storage.k8s.io/v1", "/healthz", "/healthz/ping", "/logs", diff --git a/docs/user-guide/ingress-path-matching.md b/docs/user-guide/ingress-path-matching.md index 092cf9264f..6812e2cb5d 100644 --- a/docs/user-guide/ingress-path-matching.md +++ b/docs/user-guide/ingress-path-matching.md @@ -15,7 +15,7 @@ This can be enabled by setting the `nginx.ingress.kubernetes.io/use-regex` annot See the [description](./nginx-configuration/annotations.md#use-regex) of the `use-regex` annotation for more details. ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress @@ -51,7 +51,7 @@ In NGINX, regular expressions follow a **first match** policy. In order to enabl Let the following two ingress definitions be created: ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress-1 @@ -71,7 +71,7 @@ spec: ``` ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress-2 @@ -125,7 +125,7 @@ This case is expected and a result of NGINX's a first match policy for paths tha Let the following ingress be defined: ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: test-ingress-3 diff --git a/go.mod b/go.mod index b3e3ac7036..281ef94252 100644 --- a/go.mod +++ b/go.mod @@ -29,20 +29,20 @@ require ( github.com/stretchr/testify v1.6.1 github.com/tallclair/mdtoc v1.0.0 github.com/zakjan/cert-chain-resolver v0.0.0-20200729110141-6b99e360f97a - golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 - golang.org/x/net v0.0.0-20201110031124-69a78807bb2b + golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 + golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 google.golang.org/grpc v1.27.1 gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/pool.v3 v3.1.1 - k8s.io/api v0.20.2 - k8s.io/apiextensions-apiserver v0.20.2 - k8s.io/apimachinery v0.20.2 - k8s.io/apiserver v0.20.2 - k8s.io/cli-runtime v0.20.2 - k8s.io/client-go v0.20.2 - k8s.io/code-generator v0.20.2 - k8s.io/component-base v0.20.2 - k8s.io/klog/v2 v2.4.0 + k8s.io/api v0.21.1 + k8s.io/apiextensions-apiserver v0.21.1 + k8s.io/apimachinery v0.21.1 + k8s.io/apiserver v0.21.1 + k8s.io/cli-runtime v0.21.1 + k8s.io/client-go v0.21.1 + k8s.io/code-generator v0.21.1 + k8s.io/component-base v0.21.1 + k8s.io/klog/v2 v2.8.0 k8s.io/utils v0.0.0-20201110183641-67b214c5f920 pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732 sigs.k8s.io/controller-runtime v0.8.0 diff --git a/go.sum b/go.sum index 05782fd6ce..f855ba43ab 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,9 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.1 h1:eVvIXUKiTgv++6YnWb42DUA1YL7qDugnKP0HljexdnQ= github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= +github.com/Azure/go-autorest/autorest v0.11.12 h1:gI8ytXbxMfI+IVbI9mP2JGCTXIuhHLgRlvQ9X4PsnHE= +github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= github.com/Azure/go-autorest/autorest/adal v0.9.5 h1:Y3bBUV4rTuxenJJs41HU3qmqsb+auo+a3Lz+PlJPpL0= github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= @@ -45,7 +46,9 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= @@ -54,6 +57,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -61,14 +65,17 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507 h1:dmVRVC/MmuwC2edm/P6oWIP+9n+p9IgVgK0lq9mBQjU= github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507/go.mod h1:QmP9hvJ91BbJmGVGSbutW19IC0Q9phDCLGaomwTJbgU= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -99,6 +106,7 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/containerd/console v1.0.0/go.mod h1:8Pf4gM6VEbTNRIT26AyyU7hxdQU3MvAvxVI0sc00XBE= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -113,6 +121,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -120,6 +130,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= @@ -161,8 +172,11 @@ github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXt github.com/gavv/httpexpect/v2 v2.1.0 h1:Q7xnFuKqBY2si4DsqxdbWBt9rfrbVTT2/9YSomc9tEw= github.com/gavv/httpexpect/v2 v2.1.0/go.mod h1:lnd0TqJLrP+wkJk3SFwtrpSlOAZQ7HaaIFuOYbgqgUM= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -174,21 +188,56 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v0.3.0 h1:q4c+kbcR0d5rSurhBR8dIgieOaYpXtsdTYfx22Cu6rs= github.com/go-logr/logr v0.3.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= +github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc= +github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/zapr v0.2.0 h1:v6Ji8yBW77pva6NkJKQdHLAJKrIJKRHz0RXwPqCHSR4= github.com/go-logr/zapr v0.2.0/go.mod h1:qhKdvif7YF5GI9NWEpyxTSSBdGmzkNguibrdCNVPunU= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= +github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= +github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc= +github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= +github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= +github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= +github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw= +github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= +github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/go-openapi/validate v0.19.8/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -198,8 +247,9 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -254,6 +304,8 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -269,6 +321,7 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.0.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= @@ -331,22 +384,22 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= @@ -354,11 +407,15 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9 github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= +github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -391,14 +448,18 @@ github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/I github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mmarkdown/mmark v2.0.40+incompatible h1:vMeUeDzBK3H+/mU0oMVfMuhSXJlIA+DE/DMPQNAj5C4= github.com/mmarkdown/mmark v2.0.40+incompatible/go.mod h1:Uvmoz7tvsWpr7bMVxIpqZPyN3FbOtzDmnsJDFp7ltJs= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/moby/sys/mountinfo v0.1.3/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= +github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= github.com/moul/pb v0.0.0-20180404114147-54bdd96e6a52 h1:8zDEa5yAIWYBHSDpPbSgGIBL/SvPSE9/FlB3aQ54d/A= github.com/moul/pb v0.0.0-20180404114147-54bdd96e6a52/go.mod h1:jE2HT8eoucYyUPBFJMreiVlC3KPHkDMtN8wn+ef7Y64= github.com/mrunalp/fileutils v0.0.0-20200520151820-abd8a0e76976/go.mod h1:x8F1gnqOkIEiO4rqoeEEEqQbo7HjGMTvyoq3gej4iT0= @@ -517,13 +578,15 @@ github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f h1:PgA+Olipyj258EIE github.com/savsgio/gotils v0.0.0-20200117113501-90175b0fbe3f/go.mod h1:lHhJedqxCoHN+zMtwGNTXWmF0u9Jt363FYRhV6g0CdY= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -533,6 +596,7 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -541,6 +605,7 @@ github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -559,8 +624,10 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tallclair/mdtoc v1.0.0 h1:+FqBzRdFsgwrkzewUYC8GG6/hckREy9t4cDw4bWjx+M= github.com/tallclair/mdtoc v1.0.0/go.mod h1:BjDk9nfX4091pXLHhvf6Ejr4/r//9NslWmweWb2Hkbs= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -568,6 +635,7 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw= github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= @@ -578,6 +646,9 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.1.0 h1:ngVtJC9TY/lg0AA/1k48FYhBrhRoFlEmWzsehpNAaZg= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI= +github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= @@ -595,12 +666,17 @@ go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= +go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc= +go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -622,14 +698,17 @@ go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -660,11 +739,13 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 h1:xUIPaMhvROX9dhPvRCenIJtU78+lbEenGbgqB5hfHCQ= +golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -673,9 +754,11 @@ golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -694,6 +777,8 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 h1:OgUuv8lsRpBibGNbSizVwKWlysjaNzmC9gYMhPVfqFM= +golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -718,6 +803,7 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -730,7 +816,9 @@ golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -750,6 +838,7 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw= @@ -765,13 +854,15 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e h1:EHBhcS0mlXEAVwNyO2dLfjToGsyY4j24pTs2ScHnX7s= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -782,6 +873,7 @@ golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -887,8 +979,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -911,14 +1004,15 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= +gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -928,37 +1022,40 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo= -k8s.io/api v0.20.2 h1:y/HR22XDZY3pniu9hIFDLpUCPq2w5eQ6aV/VFQ7uJMw= -k8s.io/api v0.20.2/go.mod h1:d7n6Ehyzx+S+cE3VhTGfVNNqtGc/oL9DCdYYahlurV8= +k8s.io/api v0.21.1 h1:94bbZ5NTjdINJEdzOkpS4vdPhkb1VFpTYC9zh43f75c= +k8s.io/api v0.21.1/go.mod h1:FstGROTmsSHBarKc8bylzXih8BLNYTiS3TZcsoEDg2s= k8s.io/apiextensions-apiserver v0.20.1/go.mod h1:ntnrZV+6a3dB504qwC5PN/Yg9PBiDNt1EVqbW2kORVk= -k8s.io/apiextensions-apiserver v0.20.2 h1:rfrMWQ87lhd8EzQWRnbQ4gXrniL/yTRBgYH1x1+BLlo= -k8s.io/apiextensions-apiserver v0.20.2/go.mod h1:F6TXp389Xntt+LUq3vw6HFOLttPa0V8821ogLGwb6Zs= +k8s.io/apiextensions-apiserver v0.21.1 h1:AA+cnsb6w7SZ1vD32Z+zdgfXdXY8X9uGX5bN6EoPEIo= +k8s.io/apiextensions-apiserver v0.21.1/go.mod h1:KESQFCGjqVcVsZ9g0xX5bacMjyX5emuWcS2arzdEouA= k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= -k8s.io/apimachinery v0.20.2 h1:hFx6Sbt1oG0n6DZ+g4bFt5f6BoMkOjKWsQFu077M3Vg= -k8s.io/apimachinery v0.20.2/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= +k8s.io/apimachinery v0.21.1 h1:Q6XuHGlj2xc+hlMCvqyYfbv3H7SRGn2c8NycxJquDVs= +k8s.io/apimachinery v0.21.1/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY= k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= -k8s.io/apiserver v0.20.2 h1:lGno2t3gcZnLtzsKH4oG0xA9/4GTiBzMO1DGp+K+Bak= -k8s.io/apiserver v0.20.2/go.mod h1:2nKd93WyMhZx4Hp3RfgH2K5PhwyTrprrkWYnI7id7jA= -k8s.io/cli-runtime v0.20.2 h1:W0/FHdbApnl9oB7xdG643c/Zaf7TZT+43I+zKxwqvhU= -k8s.io/cli-runtime v0.20.2/go.mod h1:FjH6uIZZZP3XmwrXWeeYCbgxcrD6YXxoAykBaWH0VdM= +k8s.io/apiserver v0.21.1 h1:wTRcid53IhxhbFt4KTrFSw8tAncfr01EP91lzfcygVg= +k8s.io/apiserver v0.21.1/go.mod h1:nLLYZvMWn35glJ4/FZRhzLG/3MPxAaZTgV4FJZdr+tY= +k8s.io/cli-runtime v0.21.1 h1:Oj/iZxa7LLXrhzShaLNF4rFJEIEBTDHj0dJw4ra2vX4= +k8s.io/cli-runtime v0.21.1/go.mod h1:TI9Bvl8lQWZB2KqE91QLCp9AZE4l29zNFnj/x4IX4Fw= k8s.io/client-go v0.20.1/go.mod h1:/zcHdt1TeWSd5HoUe6elJmHSQ6uLLgp4bIJHVEuy+/Y= -k8s.io/client-go v0.20.2 h1:uuf+iIAbfnCSw8IGAv/Rg0giM+2bOzHLOsbbrwrdhNQ= -k8s.io/client-go v0.20.2/go.mod h1:kH5brqWqp7HDxUFKoEgiI4v8G1xzbe9giaCenUWJzgE= +k8s.io/client-go v0.21.1 h1:bhblWYLZKUu+pm50plvQF8WpY6TXdRRtcS/K9WauOj4= +k8s.io/client-go v0.21.1/go.mod h1:/kEw4RgW+3xnBGzvp9IWxKSNA+lXn3A7AuH3gdOAzLs= k8s.io/code-generator v0.20.1/go.mod h1:UsqdF+VX4PU2g46NC2JRs4gc+IfrctnwHb76RNbWHJg= -k8s.io/code-generator v0.20.2 h1:SQaysped4EtUDk3u1zphnUJiOAwFdhHx9xS3WKAE0x8= -k8s.io/code-generator v0.20.2/go.mod h1:UsqdF+VX4PU2g46NC2JRs4gc+IfrctnwHb76RNbWHJg= +k8s.io/code-generator v0.21.1 h1:jvcxHpVu5dm/LMXr3GOj/jroiP8+v2YnJE9i2OVRenk= +k8s.io/code-generator v0.21.1/go.mod h1:hUlps5+9QaTrKx+jiM4rmq7YmH8wPOIko64uZCHDh6Q= k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk= -k8s.io/component-base v0.20.2 h1:LMmu5I0pLtwjpp5009KLuMGFqSc2S2isGw8t1hpYKLE= -k8s.io/component-base v0.20.2/go.mod h1:pzFtCiwe/ASD0iV7ySMu8SYVJjCapNM9bjvk7ptpKh0= +k8s.io/component-base v0.21.1 h1:iLpj2btXbR326s/xNQWmPNGu0gaYSjzn7IN/5i28nQw= +k8s.io/component-base v0.21.1/go.mod h1:NgzFZ2qu4m1juby4TnrmpR8adRk6ka62YdH5DkIIyKA= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20201113003025-83324d819ded h1:JApXBKYyB7l9xx+DK7/+mFjC7A9Bt5A93FPvFD0HIFE= k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027 h1:Uusb3oh8XcdzDF/ndlI4ToKTYVlkCSJP39SRY2mfRAw= +k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.4.0 h1:7+X0fUguPyrKEC4WjH8iGDg3laWgMo5tMnRTIGTTxGQ= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd h1:sOHNzJIkytDF6qadMNKhhDRpc6ODik8lVC6nOur7B2c= +k8s.io/klog/v2 v2.8.0 h1:Q3gmuM9hKEjefWFFYF0Mat+YyFJvsUyYuwyNNJ5C9Ts= +k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= +k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 h1:vEx13qjvaZ4yfObSSXW7BrMc/KQBBT/Jyee8XtLf4x0= +k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e h1:C7q+e9M5nggAvWfVg9Nl66kebKeuJlP3FD58V4RR5wo= @@ -969,12 +1066,16 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/controller-runtime v0.8.0 h1:s0dYdo7lQgJiAf+alP82PRwbz+oAqL3oSyMQ18XRDOc= sigs.k8s.io/controller-runtime v0.8.0/go.mod h1:v9Lbj5oX443uR7GXYY46E0EE2o7k2YxQ58GxVNeXSW4= -sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= -sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2 h1:YHQV7Dajm86OuqnIR6zAelnDWBRjo+YhYV9PmGrh1s8= +sigs.k8s.io/kustomize/api v0.8.8 h1:G2z6JPSSjtWWgMeWSoHdXqyftJNmMmyxXpwENGoOtGE= +sigs.k8s.io/kustomize/api v0.8.8/go.mod h1:He1zoK0nk43Pc6NlV085xDXDXTNprtcyKZVm3swsdNY= +sigs.k8s.io/kustomize/kyaml v0.10.17 h1:4zrV0ym5AYa0e512q7K3Wp1u7mzoWW0xR3UHJcGWGIg= +sigs.k8s.io/kustomize/kyaml v0.10.17/go.mod h1:mlQFagmkm1P+W4lZJbJ/yaxMd8PqMRSC4cPcfUVt5Hg= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= +sigs.k8s.io/structured-merge-diff/v4 v4.1.0 h1:C4r9BgJ98vrKnnVCjwCSXcWjWe0NKcUQkmzDXZXGwH8= +sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/internal/admission/controller/convert.go b/internal/admission/controller/convert.go deleted file mode 100644 index 004e5d057f..0000000000 --- a/internal/admission/controller/convert.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "unsafe" - - admissionv1 "k8s.io/api/admission/v1" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" -) - -// these conversions are copied from https://github.com/kubernetes/kubernetes/blob/4db3a096ce8ac730b2280494422e1c4cf5fe875e/pkg/apis/admission/v1beta1/zz_generated.conversion.go -// to avoid copying in kubernetes/kubernetes -// they are sightly modified to remove complexity - -func convertV1beta1AdmissionReviewToAdmissionAdmissionReview(in *admissionv1beta1.AdmissionReview, out *admissionv1.AdmissionReview) { - if in.Request != nil { - if out.Request == nil { - out.Request = &admissionv1.AdmissionRequest{} - } - in, out := &in.Request, &out.Request - *out = new(admissionv1.AdmissionRequest) - convertV1beta1AdmissionRequestToAdmissionAdmissionRequest(*in, *out) - } else { - out.Request = nil - } - out.Response = (*admissionv1.AdmissionResponse)(unsafe.Pointer(in.Response)) // #nosec -} - -func convertV1beta1AdmissionRequestToAdmissionAdmissionRequest(in *admissionv1beta1.AdmissionRequest, out *admissionv1.AdmissionRequest) { - out.UID = types.UID(in.UID) - out.Kind = in.Kind - out.Resource = in.Resource - out.SubResource = in.SubResource - out.RequestKind = (*metav1.GroupVersionKind)(unsafe.Pointer(in.RequestKind)) // #nosec - out.RequestResource = (*metav1.GroupVersionResource)(unsafe.Pointer(in.RequestResource)) // #nosec - out.RequestSubResource = in.RequestSubResource - out.Name = in.Name - out.Namespace = in.Namespace - out.Operation = admissionv1.Operation(in.Operation) - out.Object = in.Object - out.OldObject = in.OldObject - out.Options = in.Options -} - -func convertAdmissionAdmissionReviewToV1beta1AdmissionReview(in *admissionv1.AdmissionReview, out *admissionv1beta1.AdmissionReview) { - if in.Request != nil { - if out.Request == nil { - out.Request = &admissionv1beta1.AdmissionRequest{} - } - in, out := &in.Request, &out.Request - *out = new(admissionv1beta1.AdmissionRequest) - convertAdmissionAdmissionRequestToV1beta1AdmissionRequest(*in, *out) - } else { - out.Request = nil - } - out.Response = (*admissionv1beta1.AdmissionResponse)(unsafe.Pointer(in.Response)) // #nosec -} - -func convertAdmissionAdmissionRequestToV1beta1AdmissionRequest(in *admissionv1.AdmissionRequest, out *admissionv1beta1.AdmissionRequest) { - out.UID = types.UID(in.UID) - out.Kind = in.Kind - out.Resource = in.Resource - out.SubResource = in.SubResource - out.RequestKind = (*metav1.GroupVersionKind)(unsafe.Pointer(in.RequestKind)) // #nosec - out.RequestResource = (*metav1.GroupVersionResource)(unsafe.Pointer(in.RequestResource)) // #nosec - out.RequestSubResource = in.RequestSubResource - out.Name = in.Name - out.Namespace = in.Namespace - out.Operation = admissionv1beta1.Operation(in.Operation) - out.Object = in.Object - out.OldObject = in.OldObject - out.Options = in.Options -} diff --git a/internal/admission/controller/main.go b/internal/admission/controller/main.go index 7c59cdd9eb..0667473018 100644 --- a/internal/admission/controller/main.go +++ b/internal/admission/controller/main.go @@ -21,12 +21,10 @@ import ( "net/http" admissionv1 "k8s.io/api/admission/v1" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/klog/v2" ) @@ -46,7 +44,7 @@ type IngressAdmission struct { var ( ingressResource = metav1.GroupVersionKind{ Group: networking.GroupName, - Version: "v1beta1", + Version: "v1", Kind: "Ingress", } ) @@ -55,19 +53,10 @@ var ( // with Allowed=false if the Object is an ingress that would prevent nginx to reload the configuration // with Allowed=true otherwise func (ia *IngressAdmission) HandleAdmission(obj runtime.Object) (runtime.Object, error) { - outputVersion := admissionv1.SchemeGroupVersion review, isV1 := obj.(*admissionv1.AdmissionReview) - if !isV1 { - outputVersion = admissionv1beta1.SchemeGroupVersion - reviewv1beta1, isv1beta1 := obj.(*admissionv1beta1.AdmissionReview) - if !isv1beta1 { - return nil, fmt.Errorf("request is not of type AdmissionReview v1 or v1beta1") - } - - review = &admissionv1.AdmissionReview{} - convertV1beta1AdmissionReviewToAdmissionAdmissionReview(reviewv1beta1, review) + return nil, fmt.Errorf("request is not of type AdmissionReview v1 or v1beta1") } if !apiequality.Semantic.DeepEqual(review.Request.Kind, ingressResource) { @@ -94,7 +83,7 @@ func (ia *IngressAdmission) HandleAdmission(obj runtime.Object) (runtime.Object, } review.Response = status - return convertResponse(review, outputVersion), nil + return review, nil } if err := ia.Checker.CheckIngress(&ingress); err != nil { @@ -106,24 +95,12 @@ func (ia *IngressAdmission) HandleAdmission(obj runtime.Object) (runtime.Object, } review.Response = status - return convertResponse(review, outputVersion), nil + return review, nil } klog.InfoS("successfully validated configuration, accepting", "ingress", fmt.Sprintf("%v/%v", review.Request.Name, review.Request.Namespace)) status.Allowed = true review.Response = status - return convertResponse(review, outputVersion), nil -} - -func convertResponse(review *admissionv1.AdmissionReview, outputVersion schema.GroupVersion) runtime.Object { - // reply v1 - if outputVersion.Version == admissionv1.SchemeGroupVersion.Version { - return review - } - - // reply v1beta1 - reviewv1beta1 := &admissionv1beta1.AdmissionReview{} - convertAdmissionAdmissionReviewToV1beta1AdmissionReview(review, reviewv1beta1) - return review + return review, nil } diff --git a/internal/admission/controller/main_test.go b/internal/admission/controller/main_test.go index b745c14a2d..7cc3cd7b43 100644 --- a/internal/admission/controller/main_test.go +++ b/internal/admission/controller/main_test.go @@ -21,7 +21,7 @@ import ( "testing" admissionv1 "k8s.io/api/admission/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/json" @@ -71,7 +71,7 @@ func TestHandleAdmission(t *testing.T) { result, err = adm.HandleAdmission(&admissionv1.AdmissionReview{ Request: &admissionv1.AdmissionRequest{ - Kind: v1.GroupVersionKind{Group: networking.GroupName, Version: "v1beta1", Kind: "Ingress"}, + Kind: v1.GroupVersionKind{Group: networking.GroupName, Version: "v1", Kind: "Ingress"}, Object: runtime.RawExtension{ Raw: []byte{0xff}, }, diff --git a/internal/admission/controller/server.go b/internal/admission/controller/server.go index 8c9235bdc3..913e3b8de9 100644 --- a/internal/admission/controller/server.go +++ b/internal/admission/controller/server.go @@ -21,7 +21,6 @@ import ( "net/http" admissionv1 "k8s.io/api/admission/v1" - admissionv1beta1 "k8s.io/api/admission/v1beta1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer/json" "k8s.io/klog/v2" @@ -32,7 +31,6 @@ var ( ) func init() { - admissionv1beta1.AddToScheme(scheme) admissionv1.AddToScheme(scheme) } diff --git a/internal/ingress/annotations/alias/main.go b/internal/ingress/annotations/alias/main.go index 6cbe4c6dce..bd2067c9f6 100644 --- a/internal/ingress/annotations/alias/main.go +++ b/internal/ingress/annotations/alias/main.go @@ -20,7 +20,7 @@ import ( "sort" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/alias/main_test.go b/internal/ingress/annotations/alias/main_test.go index a482fc7c1c..8e6fca4470 100644 --- a/internal/ingress/annotations/alias/main_test.go +++ b/internal/ingress/annotations/alias/main_test.go @@ -21,7 +21,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/annotations.go b/internal/ingress/annotations/annotations.go index 2c3b3c1cf2..9fb53dd1e6 100644 --- a/internal/ingress/annotations/annotations.go +++ b/internal/ingress/annotations/annotations.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog/v2" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/alias" diff --git a/internal/ingress/annotations/annotations_test.go b/internal/ingress/annotations/annotations_test.go index de02a8a16b..ada81117d5 100644 --- a/internal/ingress/annotations/annotations_test.go +++ b/internal/ingress/annotations/annotations_test.go @@ -20,9 +20,8 @@ import ( "testing" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" @@ -77,8 +76,12 @@ func (m mockCfg) GetAuthCertificate(name string) (*resolver.AuthSSLCert, error) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -87,9 +90,13 @@ func buildIngress() *networking.Ingress { Namespace: apiv1.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/auth/main.go b/internal/ingress/annotations/auth/main.go index 9edfc1751d..9fe54c1f98 100644 --- a/internal/ingress/annotations/auth/main.go +++ b/internal/ingress/annotations/auth/main.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/client-go/tools/cache" "k8s.io/ingress-nginx/internal/file" diff --git a/internal/ingress/annotations/auth/main_test.go b/internal/ingress/annotations/auth/main_test.go index b02741d015..fea465b5f7 100644 --- a/internal/ingress/annotations/auth/main_test.go +++ b/internal/ingress/annotations/auth/main_test.go @@ -26,9 +26,8 @@ import ( "github.com/pkg/errors" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -36,8 +35,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -46,9 +49,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/authreq/main.go b/internal/ingress/annotations/authreq/main.go index afcd84a65f..6cfcc383d4 100644 --- a/internal/ingress/annotations/authreq/main.go +++ b/internal/ingress/annotations/authreq/main.go @@ -23,7 +23,7 @@ import ( "k8s.io/klog/v2" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/authreq/main_test.go b/internal/ingress/annotations/authreq/main_test.go index 276779c1c0..da903fe301 100644 --- a/internal/ingress/annotations/authreq/main_test.go +++ b/internal/ingress/annotations/authreq/main_test.go @@ -22,18 +22,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -42,9 +44,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/authreqglobal/main.go b/internal/ingress/annotations/authreqglobal/main.go index 170f6957db..78dd7d6a57 100644 --- a/internal/ingress/annotations/authreqglobal/main.go +++ b/internal/ingress/annotations/authreqglobal/main.go @@ -17,7 +17,7 @@ limitations under the License. package authreqglobal import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/authreqglobal/main_test.go b/internal/ingress/annotations/authreqglobal/main_test.go index a4096f7da9..0313edcf5e 100644 --- a/internal/ingress/annotations/authreqglobal/main_test.go +++ b/internal/ingress/annotations/authreqglobal/main_test.go @@ -20,18 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -40,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/authtls/main.go b/internal/ingress/annotations/authtls/main.go index 16e218d333..dd89df4f36 100644 --- a/internal/ingress/annotations/authtls/main.go +++ b/internal/ingress/annotations/authtls/main.go @@ -18,7 +18,7 @@ package authtls import ( "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "regexp" diff --git a/internal/ingress/annotations/authtls/main_test.go b/internal/ingress/annotations/authtls/main_test.go index d1a54ad70e..b2c915d187 100644 --- a/internal/ingress/annotations/authtls/main_test.go +++ b/internal/ingress/annotations/authtls/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -30,8 +29,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -40,9 +43,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/backendprotocol/main.go b/internal/ingress/annotations/backendprotocol/main.go index d6e7beb4ce..85a5fde5d3 100644 --- a/internal/ingress/annotations/backendprotocol/main.go +++ b/internal/ingress/annotations/backendprotocol/main.go @@ -20,7 +20,7 @@ import ( "regexp" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/klog/v2" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/backendprotocol/main_test.go b/internal/ingress/annotations/backendprotocol/main_test.go index 4a1c1bf31f..e8c018998c 100644 --- a/internal/ingress/annotations/backendprotocol/main_test.go +++ b/internal/ingress/annotations/backendprotocol/main_test.go @@ -20,12 +20,10 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { @@ -35,9 +33,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, } diff --git a/internal/ingress/annotations/canary/main.go b/internal/ingress/annotations/canary/main.go index 2cc88021be..3930b84d77 100644 --- a/internal/ingress/annotations/canary/main.go +++ b/internal/ingress/annotations/canary/main.go @@ -17,7 +17,7 @@ limitations under the License. package canary import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/canary/main_test.go b/internal/ingress/annotations/canary/main_test.go index f755fe8656..ddfc0a9c4e 100644 --- a/internal/ingress/annotations/canary/main_test.go +++ b/internal/ingress/annotations/canary/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "strconv" @@ -32,8 +31,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -42,9 +45,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/class/main.go b/internal/ingress/annotations/class/main.go index b2fe32d63d..521ba9f0ff 100644 --- a/internal/ingress/annotations/class/main.go +++ b/internal/ingress/annotations/class/main.go @@ -17,7 +17,7 @@ limitations under the License. package class import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/k8s" ) diff --git a/internal/ingress/annotations/class/main_test.go b/internal/ingress/annotations/class/main_test.go index 2d863f072c..b2c863854e 100644 --- a/internal/ingress/annotations/class/main_test.go +++ b/internal/ingress/annotations/class/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/k8s" ) diff --git a/internal/ingress/annotations/clientbodybuffersize/main.go b/internal/ingress/annotations/clientbodybuffersize/main.go index 924ceecd17..9020ee594f 100644 --- a/internal/ingress/annotations/clientbodybuffersize/main.go +++ b/internal/ingress/annotations/clientbodybuffersize/main.go @@ -17,7 +17,7 @@ limitations under the License. package clientbodybuffersize import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/clientbodybuffersize/main_test.go b/internal/ingress/annotations/clientbodybuffersize/main_test.go index 56f64083c4..9932f83143 100644 --- a/internal/ingress/annotations/clientbodybuffersize/main_test.go +++ b/internal/ingress/annotations/clientbodybuffersize/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/connection/main.go b/internal/ingress/annotations/connection/main.go index 7d45fdc364..e9b0c1865d 100644 --- a/internal/ingress/annotations/connection/main.go +++ b/internal/ingress/annotations/connection/main.go @@ -17,7 +17,7 @@ limitations under the License. package connection import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/connection/main_test.go b/internal/ingress/annotations/connection/main_test.go index d86aeb16a2..011a2948cf 100644 --- a/internal/ingress/annotations/connection/main_test.go +++ b/internal/ingress/annotations/connection/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/cors/main.go b/internal/ingress/annotations/cors/main.go index 2f1a0a37b5..44947a014e 100644 --- a/internal/ingress/annotations/cors/main.go +++ b/internal/ingress/annotations/cors/main.go @@ -19,7 +19,7 @@ package cors import ( "regexp" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/cors/main_test.go b/internal/ingress/annotations/cors/main_test.go index 6f75ce6a76..a65bf12cde 100644 --- a/internal/ingress/annotations/cors/main_test.go +++ b/internal/ingress/annotations/cors/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/customhttperrors/main.go b/internal/ingress/annotations/customhttperrors/main.go index 3c5fbf077b..a05fb16c86 100644 --- a/internal/ingress/annotations/customhttperrors/main.go +++ b/internal/ingress/annotations/customhttperrors/main.go @@ -20,7 +20,7 @@ import ( "strconv" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/customhttperrors/main_test.go b/internal/ingress/annotations/customhttperrors/main_test.go index 3827d197fd..1f87247ed9 100644 --- a/internal/ingress/annotations/customhttperrors/main_test.go +++ b/internal/ingress/annotations/customhttperrors/main_test.go @@ -22,12 +22,10 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { @@ -37,9 +35,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, } diff --git a/internal/ingress/annotations/defaultbackend/main.go b/internal/ingress/annotations/defaultbackend/main.go index ff4f41ce3f..7b239497d3 100644 --- a/internal/ingress/annotations/defaultbackend/main.go +++ b/internal/ingress/annotations/defaultbackend/main.go @@ -20,7 +20,7 @@ import ( "fmt" "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/defaultbackend/main_test.go b/internal/ingress/annotations/defaultbackend/main_test.go index 9278602157..ec23d32c2a 100644 --- a/internal/ingress/annotations/defaultbackend/main_test.go +++ b/internal/ingress/annotations/defaultbackend/main_test.go @@ -20,19 +20,21 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -41,9 +43,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/fastcgi/main.go b/internal/ingress/annotations/fastcgi/main.go index 174a2716c5..a7e96a0141 100644 --- a/internal/ingress/annotations/fastcgi/main.go +++ b/internal/ingress/annotations/fastcgi/main.go @@ -21,7 +21,7 @@ import ( "reflect" "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/client-go/tools/cache" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/fastcgi/main_test.go b/internal/ingress/annotations/fastcgi/main_test.go index 6802a41c20..26d85e7cee 100644 --- a/internal/ingress/annotations/fastcgi/main_test.go +++ b/internal/ingress/annotations/fastcgi/main_test.go @@ -20,13 +20,11 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { @@ -36,9 +34,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "fastcgi", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, } diff --git a/internal/ingress/annotations/globalratelimit/main.go b/internal/ingress/annotations/globalratelimit/main.go index e4b18bd662..02a7328472 100644 --- a/internal/ingress/annotations/globalratelimit/main.go +++ b/internal/ingress/annotations/globalratelimit/main.go @@ -21,7 +21,7 @@ import ( "time" "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/globalratelimit/main_test.go b/internal/ingress/annotations/globalratelimit/main_test.go index 38da8f4a9c..341a9883c8 100644 --- a/internal/ingress/annotations/globalratelimit/main_test.go +++ b/internal/ingress/annotations/globalratelimit/main_test.go @@ -23,10 +23,9 @@ import ( "github.com/pkg/errors" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -37,8 +36,12 @@ const expectedUID = "31285d47b1504dcfbd6f12c46d769f6e" func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -48,9 +51,13 @@ func buildIngress() *networking.Ingress { UID: UID, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/http2pushpreload/main.go b/internal/ingress/annotations/http2pushpreload/main.go index c542f03cf5..27d3368f43 100644 --- a/internal/ingress/annotations/http2pushpreload/main.go +++ b/internal/ingress/annotations/http2pushpreload/main.go @@ -17,7 +17,7 @@ limitations under the License. package http2pushpreload import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/http2pushpreload/main_test.go b/internal/ingress/annotations/http2pushpreload/main_test.go index 6b24ecfaee..bb98af93f3 100644 --- a/internal/ingress/annotations/http2pushpreload/main_test.go +++ b/internal/ingress/annotations/http2pushpreload/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/influxdb/main.go b/internal/ingress/annotations/influxdb/main.go index cec014b897..1aee91f331 100644 --- a/internal/ingress/annotations/influxdb/main.go +++ b/internal/ingress/annotations/influxdb/main.go @@ -17,7 +17,7 @@ limitations under the License. package influxdb import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/influxdb/main_test.go b/internal/ingress/annotations/influxdb/main_test.go index 97ba149638..13d6815096 100644 --- a/internal/ingress/annotations/influxdb/main_test.go +++ b/internal/ingress/annotations/influxdb/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/ipwhitelist/main.go b/internal/ingress/annotations/ipwhitelist/main.go index 42d424873b..4fd40ee2be 100644 --- a/internal/ingress/annotations/ipwhitelist/main.go +++ b/internal/ingress/annotations/ipwhitelist/main.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/net" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/ipwhitelist/main_test.go b/internal/ingress/annotations/ipwhitelist/main_test.go index 43aef75735..5042bb2003 100644 --- a/internal/ingress/annotations/ipwhitelist/main_test.go +++ b/internal/ingress/annotations/ipwhitelist/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -30,8 +29,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -40,9 +43,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/loadbalancing/main.go b/internal/ingress/annotations/loadbalancing/main.go index ddae0ccbe5..a8b4335e6f 100644 --- a/internal/ingress/annotations/loadbalancing/main.go +++ b/internal/ingress/annotations/loadbalancing/main.go @@ -17,7 +17,7 @@ limitations under the License. package loadbalancing import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/loadbalancing/main_test.go b/internal/ingress/annotations/loadbalancing/main_test.go index bbda797154..e2be5c0ae4 100644 --- a/internal/ingress/annotations/loadbalancing/main_test.go +++ b/internal/ingress/annotations/loadbalancing/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/log/main.go b/internal/ingress/annotations/log/main.go index 6cf99d9c8b..4bc76dcf7a 100644 --- a/internal/ingress/annotations/log/main.go +++ b/internal/ingress/annotations/log/main.go @@ -17,7 +17,7 @@ limitations under the License. package log import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/log/main_test.go b/internal/ingress/annotations/log/main_test.go index 068b1be16c..c4632b0104 100644 --- a/internal/ingress/annotations/log/main_test.go +++ b/internal/ingress/annotations/log/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/mirror/main.go b/internal/ingress/annotations/mirror/main.go index b2591347e0..e11d4b4fb5 100644 --- a/internal/ingress/annotations/mirror/main.go +++ b/internal/ingress/annotations/mirror/main.go @@ -19,7 +19,7 @@ package mirror import ( "fmt" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/mirror/main_test.go b/internal/ingress/annotations/mirror/main_test.go index 1ecaef3b9c..af7ed1b1fa 100644 --- a/internal/ingress/annotations/mirror/main_test.go +++ b/internal/ingress/annotations/mirror/main_test.go @@ -21,7 +21,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/modsecurity/main.go b/internal/ingress/annotations/modsecurity/main.go index 91a0a5a947..c537394413 100644 --- a/internal/ingress/annotations/modsecurity/main.go +++ b/internal/ingress/annotations/modsecurity/main.go @@ -17,7 +17,7 @@ limitations under the License. package modsecurity import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) diff --git a/internal/ingress/annotations/modsecurity/main_test.go b/internal/ingress/annotations/modsecurity/main_test.go index 34d92533dc..2ddbdf7e3a 100644 --- a/internal/ingress/annotations/modsecurity/main_test.go +++ b/internal/ingress/annotations/modsecurity/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/opentracing/main.go b/internal/ingress/annotations/opentracing/main.go index 875d695f70..2ed4a2182c 100644 --- a/internal/ingress/annotations/opentracing/main.go +++ b/internal/ingress/annotations/opentracing/main.go @@ -17,7 +17,7 @@ limitations under the License. package opentracing import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/opentracing/main_test.go b/internal/ingress/annotations/opentracing/main_test.go index f1e06b087c..77e29cb5d4 100644 --- a/internal/ingress/annotations/opentracing/main_test.go +++ b/internal/ingress/annotations/opentracing/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/parser/main.go b/internal/ingress/annotations/parser/main.go index 3fae804dac..b39e409b9c 100644 --- a/internal/ingress/annotations/parser/main.go +++ b/internal/ingress/annotations/parser/main.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/parser/main_test.go b/internal/ingress/annotations/parser/main_test.go index 2185651831..f63560ca34 100644 --- a/internal/ingress/annotations/parser/main_test.go +++ b/internal/ingress/annotations/parser/main_test.go @@ -21,7 +21,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/internal/ingress/annotations/portinredirect/main.go b/internal/ingress/annotations/portinredirect/main.go index bb5925c31b..25d6655587 100644 --- a/internal/ingress/annotations/portinredirect/main.go +++ b/internal/ingress/annotations/portinredirect/main.go @@ -17,7 +17,7 @@ limitations under the License. package portinredirect import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/portinredirect/main_test.go b/internal/ingress/annotations/portinredirect/main_test.go index 7087ddcd3f..71afd4cdf0 100644 --- a/internal/ingress/annotations/portinredirect/main_test.go +++ b/internal/ingress/annotations/portinredirect/main_test.go @@ -21,9 +21,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" @@ -32,8 +31,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -42,9 +45,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/proxy/main.go b/internal/ingress/annotations/proxy/main.go index f5c2252583..3a89b88557 100644 --- a/internal/ingress/annotations/proxy/main.go +++ b/internal/ingress/annotations/proxy/main.go @@ -17,7 +17,7 @@ limitations under the License. package proxy import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/proxy/main_test.go b/internal/ingress/annotations/proxy/main_test.go index 418db922e9..e377ccb195 100644 --- a/internal/ingress/annotations/proxy/main_test.go +++ b/internal/ingress/annotations/proxy/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" @@ -31,8 +30,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -41,9 +44,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/proxyssl/main.go b/internal/ingress/annotations/proxyssl/main.go index da3bbecc08..2452d90da8 100644 --- a/internal/ingress/annotations/proxyssl/main.go +++ b/internal/ingress/annotations/proxyssl/main.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/pkg/errors" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/proxyssl/main_test.go b/internal/ingress/annotations/proxyssl/main_test.go index a52fcb98a1..29949796c8 100644 --- a/internal/ingress/annotations/proxyssl/main_test.go +++ b/internal/ingress/annotations/proxyssl/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -30,8 +29,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -40,9 +43,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/ratelimit/main.go b/internal/ingress/annotations/ratelimit/main.go index 7b7d6f4dbe..4011c25429 100644 --- a/internal/ingress/annotations/ratelimit/main.go +++ b/internal/ingress/annotations/ratelimit/main.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/ratelimit/main_test.go b/internal/ingress/annotations/ratelimit/main_test.go index 7ffbac3ff6..9f101cc3b9 100644 --- a/internal/ingress/annotations/ratelimit/main_test.go +++ b/internal/ingress/annotations/ratelimit/main_test.go @@ -20,10 +20,9 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" "k8s.io/ingress-nginx/internal/ingress/resolver" @@ -31,8 +30,12 @@ import ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -41,9 +44,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/redirect/redirect.go b/internal/ingress/annotations/redirect/redirect.go index 02ee1d522c..11b08a4a29 100644 --- a/internal/ingress/annotations/redirect/redirect.go +++ b/internal/ingress/annotations/redirect/redirect.go @@ -21,7 +21,7 @@ import ( "net/url" "strings" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/redirect/redirect_test.go b/internal/ingress/annotations/redirect/redirect_test.go index b9bda6688f..b5a87a5d38 100644 --- a/internal/ingress/annotations/redirect/redirect_test.go +++ b/internal/ingress/annotations/redirect/redirect_test.go @@ -23,7 +23,7 @@ import ( "strconv" "testing" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/rewrite/main.go b/internal/ingress/annotations/rewrite/main.go index 902f00f4c3..f92d508dc3 100644 --- a/internal/ingress/annotations/rewrite/main.go +++ b/internal/ingress/annotations/rewrite/main.go @@ -19,7 +19,7 @@ package rewrite import ( "net/url" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/klog/v2" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/rewrite/main_test.go b/internal/ingress/annotations/rewrite/main_test.go index beece494a4..c2cb42c78f 100644 --- a/internal/ingress/annotations/rewrite/main_test.go +++ b/internal/ingress/annotations/rewrite/main_test.go @@ -20,9 +20,8 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/defaults" @@ -35,8 +34,12 @@ const ( func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -46,9 +49,13 @@ func buildIngress() *networking.Ingress { Annotations: map[string]string{}, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/satisfy/main.go b/internal/ingress/annotations/satisfy/main.go index a064bdf96f..0d4fd4ff6b 100644 --- a/internal/ingress/annotations/satisfy/main.go +++ b/internal/ingress/annotations/satisfy/main.go @@ -17,7 +17,7 @@ limitations under the License. package satisfy import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/satisfy/main_test.go b/internal/ingress/annotations/satisfy/main_test.go index a3475316ae..b45205d9f0 100644 --- a/internal/ingress/annotations/satisfy/main_test.go +++ b/internal/ingress/annotations/satisfy/main_test.go @@ -20,18 +20,21 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -40,9 +43,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/secureupstream/main.go b/internal/ingress/annotations/secureupstream/main.go index 6318044644..ebaea20588 100644 --- a/internal/ingress/annotations/secureupstream/main.go +++ b/internal/ingress/annotations/secureupstream/main.go @@ -17,7 +17,7 @@ limitations under the License. package secureupstream import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/klog/v2" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/secureupstream/main_test.go b/internal/ingress/annotations/secureupstream/main_test.go index 508d54a84d..7546cb5cf3 100644 --- a/internal/ingress/annotations/secureupstream/main_test.go +++ b/internal/ingress/annotations/secureupstream/main_test.go @@ -21,18 +21,21 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -41,9 +44,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/serversnippet/main.go b/internal/ingress/annotations/serversnippet/main.go index 33a672650f..70f0af8e5d 100644 --- a/internal/ingress/annotations/serversnippet/main.go +++ b/internal/ingress/annotations/serversnippet/main.go @@ -17,7 +17,7 @@ limitations under the License. package serversnippet import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/serversnippet/main_test.go b/internal/ingress/annotations/serversnippet/main_test.go index 066334f69b..c9e0979ad2 100644 --- a/internal/ingress/annotations/serversnippet/main_test.go +++ b/internal/ingress/annotations/serversnippet/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/serviceupstream/main.go b/internal/ingress/annotations/serviceupstream/main.go index ff90f8160d..4c44356d66 100644 --- a/internal/ingress/annotations/serviceupstream/main.go +++ b/internal/ingress/annotations/serviceupstream/main.go @@ -17,7 +17,7 @@ limitations under the License. package serviceupstream import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/serviceupstream/main_test.go b/internal/ingress/annotations/serviceupstream/main_test.go index c7f44598e6..3fbdb57854 100644 --- a/internal/ingress/annotations/serviceupstream/main_test.go +++ b/internal/ingress/annotations/serviceupstream/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/internal/ingress/annotations/sessionaffinity/main.go b/internal/ingress/annotations/sessionaffinity/main.go index 80b24f13bf..358be14422 100644 --- a/internal/ingress/annotations/sessionaffinity/main.go +++ b/internal/ingress/annotations/sessionaffinity/main.go @@ -19,7 +19,7 @@ package sessionaffinity import ( "regexp" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/klog/v2" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" diff --git a/internal/ingress/annotations/sessionaffinity/main_test.go b/internal/ingress/annotations/sessionaffinity/main_test.go index 51d92ffb07..98f0a1eb61 100644 --- a/internal/ingress/annotations/sessionaffinity/main_test.go +++ b/internal/ingress/annotations/sessionaffinity/main_test.go @@ -20,17 +20,20 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" ) func buildIngress() *networking.Ingress { defaultBackend := networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, } return &networking.Ingress{ @@ -39,9 +42,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, Rules: []networking.IngressRule{ { @@ -64,7 +71,6 @@ func buildIngress() *networking.Ingress { func TestIngressAffinityCookieConfig(t *testing.T) { ing := buildIngress() - data := map[string]string{} data[parser.GetAnnotationWithPrefix(annotationAffinityType)] = "cookie" data[parser.GetAnnotationWithPrefix(annotationAffinityMode)] = "balanced" diff --git a/internal/ingress/annotations/snippet/main.go b/internal/ingress/annotations/snippet/main.go index 9a3878603c..93ec70cf97 100644 --- a/internal/ingress/annotations/snippet/main.go +++ b/internal/ingress/annotations/snippet/main.go @@ -17,7 +17,7 @@ limitations under the License. package snippet import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/snippet/main_test.go b/internal/ingress/annotations/snippet/main_test.go index 0abeaed8a0..0defc3c1f8 100644 --- a/internal/ingress/annotations/snippet/main_test.go +++ b/internal/ingress/annotations/snippet/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/sslcipher/main.go b/internal/ingress/annotations/sslcipher/main.go index d100a0da4b..e4e5baad20 100644 --- a/internal/ingress/annotations/sslcipher/main.go +++ b/internal/ingress/annotations/sslcipher/main.go @@ -17,7 +17,7 @@ limitations under the License. package sslcipher import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/sslcipher/main_test.go b/internal/ingress/annotations/sslcipher/main_test.go index 8110697dcd..6eb9ec0c2c 100644 --- a/internal/ingress/annotations/sslcipher/main_test.go +++ b/internal/ingress/annotations/sslcipher/main_test.go @@ -21,7 +21,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/sslpassthrough/main.go b/internal/ingress/annotations/sslpassthrough/main.go index 20ff1a010d..d1def7172a 100644 --- a/internal/ingress/annotations/sslpassthrough/main.go +++ b/internal/ingress/annotations/sslpassthrough/main.go @@ -17,7 +17,7 @@ limitations under the License. package sslpassthrough import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" ing_errors "k8s.io/ingress-nginx/internal/ingress/errors" diff --git a/internal/ingress/annotations/sslpassthrough/main_test.go b/internal/ingress/annotations/sslpassthrough/main_test.go index d5e54b2e2f..5cf2f979ad 100644 --- a/internal/ingress/annotations/sslpassthrough/main_test.go +++ b/internal/ingress/annotations/sslpassthrough/main_test.go @@ -20,12 +20,10 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" - - "k8s.io/apimachinery/pkg/util/intstr" ) func buildIngress() *networking.Ingress { @@ -35,9 +33,13 @@ func buildIngress() *networking.Ingress { Namespace: api.NamespaceDefault, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "default-backend", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "default-backend", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, } diff --git a/internal/ingress/annotations/upstreamhashby/main.go b/internal/ingress/annotations/upstreamhashby/main.go index bb202f1b05..e6bbca6c33 100644 --- a/internal/ingress/annotations/upstreamhashby/main.go +++ b/internal/ingress/annotations/upstreamhashby/main.go @@ -17,7 +17,7 @@ limitations under the License. package upstreamhashby import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/upstreamhashby/main_test.go b/internal/ingress/annotations/upstreamhashby/main_test.go index 5a71be56f5..d2c2644cac 100644 --- a/internal/ingress/annotations/upstreamhashby/main_test.go +++ b/internal/ingress/annotations/upstreamhashby/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/upstreamvhost/main.go b/internal/ingress/annotations/upstreamvhost/main.go index bf761a70f8..2eed5607e0 100644 --- a/internal/ingress/annotations/upstreamvhost/main.go +++ b/internal/ingress/annotations/upstreamvhost/main.go @@ -17,7 +17,7 @@ limitations under the License. package upstreamvhost import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/upstreamvhost/main_test.go b/internal/ingress/annotations/upstreamvhost/main_test.go index 1506c4f7fb..130d745ee3 100644 --- a/internal/ingress/annotations/upstreamvhost/main_test.go +++ b/internal/ingress/annotations/upstreamvhost/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/xforwardedprefix/main.go b/internal/ingress/annotations/xforwardedprefix/main.go index 2071b64113..60eed8773b 100644 --- a/internal/ingress/annotations/xforwardedprefix/main.go +++ b/internal/ingress/annotations/xforwardedprefix/main.go @@ -17,7 +17,7 @@ limitations under the License. package xforwardedprefix import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/annotations/xforwardedprefix/main_test.go b/internal/ingress/annotations/xforwardedprefix/main_test.go index c94df3ab2d..a78c63d049 100644 --- a/internal/ingress/annotations/xforwardedprefix/main_test.go +++ b/internal/ingress/annotations/xforwardedprefix/main_test.go @@ -20,7 +20,7 @@ import ( "testing" api "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/ingress/annotations/parser" "k8s.io/ingress-nginx/internal/ingress/resolver" diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 08ef2d2402..57a64fc5b2 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -25,7 +25,7 @@ import ( "github.com/mitchellh/hashstructure" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/sets" @@ -231,7 +231,7 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error { return nil } - if n.cfg.DisableCatchAll && ing.Spec.Backend != nil { + if n.cfg.DisableCatchAll && ing.Spec.DefaultBackend != nil { return fmt.Errorf("This deployment is trying to create a catch-all ingress while DisableCatchAll flag is set to true. Remove '.spec.backend' or set DisableCatchAll flag to false.") } @@ -573,7 +573,7 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in } for _, path := range rule.HTTP.Paths { - upsName := upstreamName(ing.Namespace, path.Backend.ServiceName, path.Backend.ServicePort) + upsName := upstreamName(ing.Namespace, path.Backend.Service) ups := upstreams[upsName] @@ -791,8 +791,8 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B anns := ing.ParsedAnnotations var defBackend string - if ing.Spec.Backend != nil { - defBackend = upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort) + if ing.Spec.DefaultBackend != nil && ing.Spec.DefaultBackend.Service != nil { + defBackend = upstreamName(ing.Namespace, ing.Spec.DefaultBackend.Service) klog.V(3).Infof("Creating upstream %q", defBackend) upstreams[defBackend] = newUpstream(defBackend) @@ -806,11 +806,11 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B upstreams[defBackend].LoadBalancing = n.store.GetBackendConfiguration().LoadBalancing } - svcKey := fmt.Sprintf("%v/%v", ing.Namespace, ing.Spec.Backend.ServiceName) + svcKey := fmt.Sprintf("%v/%v", ing.Namespace, ing.Spec.DefaultBackend.Service.Name) // add the service ClusterIP as a single Endpoint instead of individual Endpoints if anns.ServiceUpstream { - endpoint, err := n.getServiceClusterEndpoint(svcKey, ing.Spec.Backend) + endpoint, err := n.getServiceClusterEndpoint(svcKey, ing.Spec.DefaultBackend) if err != nil { klog.Errorf("Failed to determine a suitable ClusterIP Endpoint for Service %q: %v", svcKey, err) } else { @@ -831,7 +831,8 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B } if len(upstreams[defBackend].Endpoints) == 0 { - endps, err := n.serviceEndpoints(svcKey, ing.Spec.Backend.ServicePort.String()) + _, port := upstreamServiceNameAndPort(ing.Spec.DefaultBackend.Service) + endps, err := n.serviceEndpoints(svcKey, port.String()) upstreams[defBackend].Endpoints = append(upstreams[defBackend].Endpoints, endps...) if err != nil { klog.Warningf("Error creating upstream %q: %v", defBackend, err) @@ -851,15 +852,15 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B } for _, path := range rule.HTTP.Paths { - name := upstreamName(ing.Namespace, path.Backend.ServiceName, path.Backend.ServicePort) - + name := upstreamName(ing.Namespace, path.Backend.Service) + svcName, svcPort := upstreamServiceNameAndPort(path.Backend.Service) if _, ok := upstreams[name]; ok { continue } klog.V(3).Infof("Creating upstream %q", name) upstreams[name] = newUpstream(name) - upstreams[name].Port = path.Backend.ServicePort + upstreams[name].Port = svcPort upstreams[name].UpstreamHashBy.UpstreamHashBy = anns.UpstreamHashBy.UpstreamHashBy upstreams[name].UpstreamHashBy.UpstreamHashBySubset = anns.UpstreamHashBy.UpstreamHashBySubset @@ -870,7 +871,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B upstreams[name].LoadBalancing = n.store.GetBackendConfiguration().LoadBalancing } - svcKey := fmt.Sprintf("%v/%v", ing.Namespace, path.Backend.ServiceName) + svcKey := fmt.Sprintf("%v/%v", ing.Namespace, svcName) // add the service ClusterIP as a single Endpoint instead of individual Endpoints if anns.ServiceUpstream { @@ -895,7 +896,8 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B } if len(upstreams[name].Endpoints) == 0 { - endp, err := n.serviceEndpoints(svcKey, path.Backend.ServicePort.String()) + _, port := upstreamServiceNameAndPort(path.Backend.Service) + endp, err := n.serviceEndpoints(svcKey, port.String()) if err != nil { klog.Warningf("Error obtaining Endpoints for Service %q: %v", svcKey, err) continue @@ -933,20 +935,23 @@ func (n *NGINXController) getServiceClusterEndpoint(svcKey string, backend *netw // if the Service port is referenced by name in the Ingress, lookup the // actual port in the service spec - if backend.ServicePort.Type == intstr.String { - var port int32 = -1 - for _, svcPort := range svc.Spec.Ports { - if svcPort.Name == backend.ServicePort.String() { - port = svcPort.Port - break + if backend.Service != nil { + _, svcportintorstr := upstreamServiceNameAndPort(backend.Service) + if svcportintorstr.Type == intstr.String { + var port int32 = -1 + for _, svcPort := range svc.Spec.Ports { + if svcPort.Name == svcportintorstr.String() { + port = svcPort.Port + break + } } + if port == -1 { + return endpoint, fmt.Errorf("service %q does not have a port named %q", svc.Name, svcportintorstr.String()) + } + endpoint.Port = fmt.Sprintf("%d", port) + } else { + endpoint.Port = svcportintorstr.String() } - if port == -1 { - return endpoint, fmt.Errorf("service %q does not have a port named %q", svc.Name, backend.ServicePort) - } - endpoint.Port = fmt.Sprintf("%d", port) - } else { - endpoint.Port = backend.ServicePort.String() } return endpoint, err @@ -1077,8 +1082,8 @@ func (n *NGINXController) createServers(data []*ingress.Ingress, continue } - if ing.Spec.Backend != nil { - defUpstream := upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort) + if ing.Spec.DefaultBackend != nil && ing.Spec.DefaultBackend.Service != nil { + defUpstream := upstreamName(ing.Namespace, ing.Spec.DefaultBackend.Service) if backendUpstream, ok := upstreams[defUpstream]; ok { // use backend specified in Ingress as the default backend for all its rules @@ -1347,8 +1352,8 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres servers map[string]*ingress.Server) { // merge catch-all alternative backends - if ing.Spec.Backend != nil { - upsName := upstreamName(ing.Namespace, ing.Spec.Backend.ServiceName, ing.Spec.Backend.ServicePort) + if ing.Spec.DefaultBackend != nil { + upsName := upstreamName(ing.Namespace, ing.Spec.DefaultBackend.Service) altUps := upstreams[upsName] @@ -1390,7 +1395,7 @@ func mergeAlternativeBackends(ing *ingress.Ingress, upstreams map[string]*ingres } for _, path := range rule.HTTP.Paths { - upsName := upstreamName(ing.Namespace, path.Backend.ServiceName, path.Backend.ServicePort) + upsName := upstreamName(ing.Namespace, path.Backend.Service) altUps := upstreams[upsName] diff --git a/internal/ingress/controller/controller_test.go b/internal/ingress/controller/controller_test.go index 62af4e85d6..dbea966915 100644 --- a/internal/ingress/controller/controller_test.go +++ b/internal/ingress/controller/controller_test.go @@ -33,9 +33,8 @@ import ( "github.com/eapache/channels" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes/fake" "k8s.io/ingress-nginx/internal/file" @@ -258,7 +257,7 @@ func TestCheckIngress(t *testing.T) { }) t.Run("When a new catch-all ingress is being created despite catch-alls being disabled ", func(t *testing.T) { - backendBefore := ing.Spec.Backend + backendBefore := ing.Spec.DefaultBackend disableCatchAllBefore := nginx.cfg.DisableCatchAll nginx.command = testNginxTestCommand{ @@ -267,10 +266,12 @@ func TestCheckIngress(t *testing.T) { } nginx.cfg.DisableCatchAll = true - ing.Spec.Backend = &networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.IntOrString{ - IntVal: 80, + ing.Spec.DefaultBackend = &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, } @@ -279,7 +280,7 @@ func TestCheckIngress(t *testing.T) { } // reset backend and catch-all flag - ing.Spec.Backend = backendBefore + ing.Spec.DefaultBackend = backendBefore nginx.cfg.DisableCatchAll = disableCatchAllBefore }) @@ -332,10 +333,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -416,10 +418,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "foo-http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "foo-http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -436,10 +439,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -554,10 +558,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -589,10 +594,12 @@ func TestMergeAlternativeBackends(t *testing.T) { Namespace: "example", }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - IntVal: 80, + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -657,10 +664,12 @@ func TestMergeAlternativeBackends(t *testing.T) { Namespace: "example", }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - IntVal: 80, + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -721,9 +730,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1325,10 +1336,12 @@ func TestGetBackendServers(t *testing.T) { Namespace: "example", }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - IntVal: 80, + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1368,10 +1381,12 @@ func TestGetBackendServers(t *testing.T) { Namespace: "example", }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - IntVal: 80, + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1388,10 +1403,12 @@ func TestGetBackendServers(t *testing.T) { Namespace: "example", }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.IntOrString{ - IntVal: 80, + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1441,10 +1458,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1501,10 +1519,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1538,10 +1557,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1607,10 +1627,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/a", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-1", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-1", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1644,10 +1665,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/a", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-2", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-2", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1681,10 +1703,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/b", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-2", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-2", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1718,10 +1741,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/b", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-1", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-1", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1755,10 +1779,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/c", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-1", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-1", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1792,10 +1817,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/c", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-2", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-2", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1877,10 +1903,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/path1", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "path1-svc", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "path1-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1917,10 +1944,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/path2", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "path2-svc", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "path2-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1982,10 +2010,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/path1", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "path1-svc", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "path1-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -2022,10 +2051,11 @@ func TestGetBackendServers(t *testing.T) { Path: "/path2", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "path2-svc", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "path2-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, diff --git a/internal/ingress/controller/store/backend_ssl.go b/internal/ingress/controller/store/backend_ssl.go index fe9138c6f0..377f620158 100644 --- a/internal/ingress/controller/store/backend_ssl.go +++ b/internal/ingress/controller/store/backend_ssl.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/internal/file" diff --git a/internal/ingress/controller/store/ingress.go b/internal/ingress/controller/store/ingress.go index dafc489245..1d8ccb3428 100644 --- a/internal/ingress/controller/store/ingress.go +++ b/internal/ingress/controller/store/ingress.go @@ -17,7 +17,7 @@ limitations under the License. package store import ( - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/client-go/tools/cache" "k8s.io/ingress-nginx/internal/ingress" ) diff --git a/internal/ingress/controller/store/store.go b/internal/ingress/controller/store/store.go index 0088c3b019..d4e8935154 100644 --- a/internal/ingress/controller/store/store.go +++ b/internal/ingress/controller/store/store.go @@ -28,7 +28,7 @@ import ( "github.com/eapache/channels" corev1 "k8s.io/api/core/v1" - networkingv1beta1 "k8s.io/api/networking/v1beta1" + networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" k8sruntime "k8s.io/apimachinery/pkg/runtime" @@ -293,7 +293,7 @@ func New( informers.WithTweakListOptions(secretsTweakListOptionsFunc), ) - store.informers.Ingress = infFactory.Networking().V1beta1().Ingresses().Informer() + store.informers.Ingress = infFactory.Networking().V1().Ingresses().Informer() store.listers.Ingress.Store = store.informers.Ingress.GetStore() store.informers.Endpoint = infFactory.Core().V1().Endpoints().Informer() @@ -317,7 +317,7 @@ func New( klog.ErrorS(nil, "Error obtaining object from tombstone", "key", obj) return } - ing, ok = tombstone.Obj.(*networkingv1beta1.Ingress) + ing, ok = tombstone.Obj.(*networkingv1.Ingress) if !ok { klog.Errorf("Tombstone contained object that is not an Ingress: %#v", obj) return @@ -626,17 +626,17 @@ func New( // hasCatchAllIngressRule returns whether or not an ingress produces a // catch-all server, and so should be ignored when --disable-catch-all is set -func hasCatchAllIngressRule(spec networkingv1beta1.IngressSpec) bool { - return spec.Backend != nil +func hasCatchAllIngressRule(spec networkingv1.IngressSpec) bool { + return spec.DefaultBackend != nil } // syncIngress parses ingress annotations converting the value of the // annotation to a go struct -func (s *k8sStore) syncIngress(ing *networkingv1beta1.Ingress) { +func (s *k8sStore) syncIngress(ing *networkingv1.Ingress) { key := k8s.MetaNamespaceKey(ing) klog.V(3).Infof("updating annotations information for ingress %v", key) - copyIng := &networkingv1beta1.Ingress{} + copyIng := &networkingv1.Ingress{} ing.ObjectMeta.DeepCopyInto(©Ing.ObjectMeta) ing.Spec.DeepCopyInto(©Ing.Spec) ing.Status.DeepCopyInto(©Ing.Status) @@ -666,7 +666,7 @@ func (s *k8sStore) syncIngress(ing *networkingv1beta1.Ingress) { // updateSecretIngressMap takes an Ingress and updates all Secret objects it // references in secretIngressMap. -func (s *k8sStore) updateSecretIngressMap(ing *networkingv1beta1.Ingress) { +func (s *k8sStore) updateSecretIngressMap(ing *networkingv1.Ingress) { key := k8s.MetaNamespaceKey(ing) klog.V(3).Infof("updating references to secrets for ingress %v", key) @@ -710,7 +710,7 @@ func (s *k8sStore) updateSecretIngressMap(ing *networkingv1beta1.Ingress) { // objectRefAnnotationNsKey returns an object reference formatted as a // 'namespace/name' key from the given annotation name. -func objectRefAnnotationNsKey(ann string, ing *networkingv1beta1.Ingress) (string, error) { +func objectRefAnnotationNsKey(ann string, ing *networkingv1.Ingress) (string, error) { annValue, err := parser.GetStringAnnotation(ann, ing) if err != nil { return "", err @@ -729,7 +729,7 @@ func objectRefAnnotationNsKey(ann string, ing *networkingv1beta1.Ingress) (strin // syncSecrets synchronizes data from all Secrets referenced by the given // Ingress with the local store and file system. -func (s *k8sStore) syncSecrets(ing *networkingv1beta1.Ingress) { +func (s *k8sStore) syncSecrets(ing *networkingv1.Ingress) { key := k8s.MetaNamespaceKey(ing) for _, secrKey := range s.secretIngressMap.ReferencedBy(key) { s.syncSecret(secrKey) @@ -759,7 +759,7 @@ func (s *k8sStore) GetService(key string) (*corev1.Service, error) { } // getIngress returns the Ingress matching key. -func (s *k8sStore) getIngress(key string) (*networkingv1beta1.Ingress, error) { +func (s *k8sStore) getIngress(key string) (*networkingv1.Ingress, error) { ing, err := s.listers.IngressWithAnnotation.ByKey(key) if err != nil { return nil, err @@ -900,11 +900,11 @@ func (s *k8sStore) Run(stopCh chan struct{}) { var runtimeScheme = k8sruntime.NewScheme() func init() { - utilruntime.Must(networkingv1beta1.AddToScheme(runtimeScheme)) + utilruntime.Must(networkingv1.AddToScheme(runtimeScheme)) } -func toIngress(obj interface{}) (*networkingv1beta1.Ingress, bool) { - if ing, ok := obj.(*networkingv1beta1.Ingress); ok { +func toIngress(obj interface{}) (*networkingv1.Ingress, bool) { + if ing, ok := obj.(*networkingv1.Ingress); ok { k8s.SetDefaultNGINXPathType(ing) return ing, true } diff --git a/internal/ingress/controller/store/store_test.go b/internal/ingress/controller/store/store_test.go index bcc8f67d68..1421f9111d 100644 --- a/internal/ingress/controller/store/store_test.go +++ b/internal/ingress/controller/store/store_test.go @@ -29,10 +29,9 @@ import ( "github.com/eapache/channels" v1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" k8sErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/cache" "sigs.k8s.io/controller-runtime/pkg/envtest" @@ -43,10 +42,14 @@ import ( "k8s.io/ingress-nginx/test/e2e/framework" ) +var pathPrefix networking.PathType = networking.PathTypePrefix + func TestStore(t *testing.T) { //TODO: move env definition to docker image? os.Setenv("KUBEBUILDER_ASSETS", "/usr/local/bin") + pathPrefix = networking.PathTypePrefix + te := &envtest.Environment{} cfg, err := te.Start() if err != nil { @@ -109,7 +112,7 @@ func TestStore(t *testing.T) { t.Errorf("expected an error but none returned") } if svc != nil { - t.Errorf("expected an Ingres but none returned") + t.Errorf("expected an Ingress but none returned") } }) @@ -177,10 +180,15 @@ func TestStore(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -214,10 +222,15 @@ func TestStore(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -238,7 +251,7 @@ func TestStore(t *testing.T) { // Secret takes a bit to update time.Sleep(3 * time.Second) - err = clientSet.NetworkingV1beta1().Ingresses(ni.Namespace).Delete(context.TODO(), ni.Name, metav1.DeleteOptions{}) + err = clientSet.NetworkingV1().Ingresses(ni.Namespace).Delete(context.TODO(), ni.Name, metav1.DeleteOptions{}) if err != nil { t.Errorf("error creating ingress: %v", err) } @@ -328,10 +341,15 @@ func TestStore(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -514,9 +532,13 @@ func TestStore(t *testing.T) { SecretName: secretName, }, }, - Backend: &networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, clientSet, t) @@ -630,10 +652,15 @@ func TestStore(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "http-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -725,13 +752,13 @@ func createConfigMap(clientSet kubernetes.Interface, ns string, t *testing.T) st func ensureIngress(ingress *networking.Ingress, clientSet kubernetes.Interface, t *testing.T) *networking.Ingress { t.Helper() - ing, err := clientSet.NetworkingV1beta1().Ingresses(ingress.Namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) + ing, err := clientSet.NetworkingV1().Ingresses(ingress.Namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) if err != nil { if k8sErrors.IsNotFound(err) { t.Logf("Ingress %v not found, creating", ingress) - ing, err = clientSet.NetworkingV1beta1().Ingresses(ingress.Namespace).Create(context.TODO(), ingress, metav1.CreateOptions{}) + ing, err = clientSet.NetworkingV1().Ingresses(ingress.Namespace).Create(context.TODO(), ingress, metav1.CreateOptions{}) if err != nil { t.Fatalf("error creating ingress %+v: %v", ingress, err) } @@ -748,7 +775,7 @@ func ensureIngress(ingress *networking.Ingress, clientSet kubernetes.Interface, func deleteIngress(ingress *networking.Ingress, clientSet kubernetes.Interface, t *testing.T) { t.Helper() - err := clientSet.NetworkingV1beta1().Ingresses(ingress.Namespace).Delete(context.TODO(), ingress.Name, metav1.DeleteOptions{}) + err := clientSet.NetworkingV1().Ingresses(ingress.Namespace).Delete(context.TODO(), ingress.Name, metav1.DeleteOptions{}) if err != nil { t.Errorf("failed to delete ingress %+v: %v", ingress, err) @@ -852,9 +879,13 @@ func TestListIngresses(t *testing.T) { CreationTimestamp: metav1.NewTime(time.Now()), }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "demo", - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "demo", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -877,8 +908,12 @@ func TestListIngresses(t *testing.T) { Paths: []networking.HTTPIngressPath{ { Backend: networking.IngressBackend{ - ServiceName: "demo", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "demo", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -909,10 +944,15 @@ func TestListIngresses(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/demo", + Path: "/demo", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "demo", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "demo", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, diff --git a/internal/ingress/controller/template/template.go b/internal/ingress/controller/template/template.go index 3aa521c877..3d46262b42 100644 --- a/internal/ingress/controller/template/template.go +++ b/internal/ingress/controller/template/template.go @@ -32,13 +32,14 @@ import ( "reflect" "regexp" "sort" + "strconv" "strings" text_template "text/template" "time" "github.com/pkg/errors" - networkingv1beta1 "k8s.io/api/networking/v1beta1" + networkingv1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog/v2" @@ -519,7 +520,7 @@ func buildLocation(input interface{}, enforceRegex bool) string { return fmt.Sprintf(`~* "^%s"`, path) } - if location.PathType != nil && *location.PathType == networkingv1beta1.PathTypeExact { + if location.PathType != nil && *location.PathType == networkingv1.PathTypeExact { return fmt.Sprintf(`= %s`, path) } @@ -983,10 +984,10 @@ func getIngressInformation(i, h, p interface{}) *ingressInformation { info.Path = "/" } - if ing.Spec.Backend != nil { - info.Service = ing.Spec.Backend.ServiceName - if ing.Spec.Backend.ServicePort.String() != "0" { - info.ServicePort = ing.Spec.Backend.ServicePort.String() + if ing.Spec.DefaultBackend != nil && ing.Spec.DefaultBackend.Service != nil { + info.Service = ing.Spec.DefaultBackend.Service.Name + if ing.Spec.DefaultBackend.Service.Port.Number > 0 { + info.ServicePort = strconv.Itoa(int(ing.Spec.DefaultBackend.Service.Port.Number)) } } @@ -1013,14 +1014,14 @@ func getIngressInformation(i, h, p interface{}) *ingressInformation { continue } - if info.Service != "" && rPath.Backend.ServiceName == "" { + if info.Service != "" && rPath.Backend.Service.Name == "" { // empty rule. Only contains a Path and PathType return info } - info.Service = rPath.Backend.ServiceName - if rPath.Backend.ServicePort.String() != "0" { - info.ServicePort = rPath.Backend.ServicePort.String() + info.Service = rPath.Backend.Service.Name + if rPath.Backend.Service.Port.Number > 0 { + info.ServicePort = strconv.Itoa(int(rPath.Backend.Service.Port.Number)) } return info diff --git a/internal/ingress/controller/template/template_test.go b/internal/ingress/controller/template/template_test.go index 411b243492..2c6b62ea47 100644 --- a/internal/ingress/controller/template/template_test.go +++ b/internal/ingress/controller/template/template_test.go @@ -32,9 +32,8 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/pmezard/go-difflib/difflib" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress" "k8s.io/ingress-nginx/internal/ingress/annotations/authreq" @@ -57,6 +56,8 @@ func init() { } var ( + pathPrefix networking.PathType = networking.PathTypePrefix + // TODO: add tests for SSLPassthrough tmplFuncTestcases = map[string]struct { Path string @@ -207,11 +208,11 @@ func TestBuildLuaSharedDictionaries(t *testing.T) { servers := []*ingress.Server{ { Hostname: "foo.bar", - Locations: []*ingress.Location{{Path: "/"}}, + Locations: []*ingress.Location{{Path: "/", PathType: &pathPrefix}}, }, { Hostname: "another.host", - Locations: []*ingress.Location{{Path: "/"}}, + Locations: []*ingress.Location{{Path: "/", PathType: &pathPrefix}}, }, } // returns value from config @@ -293,8 +294,9 @@ func TestBuildLocation(t *testing.T) { for k, tc := range tmplFuncTestcases { loc := &ingress.Location{ - Path: tc.Path, - Rewrite: rewrite.Config{Target: tc.Target}, + Path: tc.Path, + PathType: &pathPrefix, + Rewrite: rewrite.Config{Target: tc.Target}, } newLoc := buildLocation(loc, tc.enforceRegex) @@ -311,6 +313,7 @@ func TestBuildProxyPass(t *testing.T) { for k, tc := range tmplFuncTestcases { loc := &ingress.Location{ Path: tc.Path, + PathType: &pathPrefix, Rewrite: rewrite.Config{Target: tc.Target}, Backend: defaultBackend, XForwardedPrefix: tc.XForwardedPrefix, @@ -838,6 +841,7 @@ func TestBuildUpstreamName(t *testing.T) { for k, tc := range tmplFuncTestcases { loc := &ingress.Location{ Path: tc.Path, + PathType: &pathPrefix, Rewrite: rewrite.Config{Target: tc.Target}, Backend: defaultBackend, XForwardedPrefix: tc.XForwardedPrefix, @@ -947,8 +951,10 @@ func TestGetIngressInformation(t *testing.T) { }, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: "a-svc", + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "a-svc", + }, }, }, }, @@ -958,6 +964,7 @@ func TestGetIngressInformation(t *testing.T) { &ingressInformation{ Namespace: "default", Rule: "validIng", + Path: "/", Annotations: map[string]string{ "ingress.annotation": "ok", }, @@ -982,10 +989,15 @@ func TestGetIngressInformation(t *testing.T) { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/ok", + Path: "/ok", + PathType: &pathPrefix, Backend: networking.IngressBackend{ - ServiceName: "b-svc", - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: "b-svc", + Port: networking.ServiceBackendPort{ + Number: 80, + }, + }, }, }, }, @@ -1259,7 +1271,8 @@ func TestEnforceRegexModifier(t *testing.T) { Target: "/alright", UseRegex: true, }, - Path: "/ok", + Path: "/ok", + PathType: &pathPrefix, }, } expected = true diff --git a/internal/ingress/controller/util.go b/internal/ingress/controller/util.go index 5946cb47c6..766f07b38a 100644 --- a/internal/ingress/controller/util.go +++ b/internal/ingress/controller/util.go @@ -27,6 +27,7 @@ import ( "syscall" api "k8s.io/api/core/v1" + networking "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress" "k8s.io/klog/v2" @@ -47,8 +48,30 @@ func newUpstream(name string) *ingress.Backend { } // upstreamName returns a formatted upstream name based on namespace, service, and port -func upstreamName(namespace string, service string, port intstr.IntOrString) string { - return fmt.Sprintf("%v-%v-%v", namespace, service, port.String()) +func upstreamName(namespace string, service *networking.IngressServiceBackend) string { + if service != nil { + if service.Port.Number > 0 { + return fmt.Sprintf("%s-%s-%d", namespace, service.Name, service.Port.Number) + } + if service.Port.Name != "" { + return fmt.Sprintf("%s-%s-%s", namespace, service.Name, service.Port.Name) + } + } + return fmt.Sprintf("%s-INVALID", namespace) +} + +// upstreamServiceNameAndPort verifies if service is not nil, and then return the +// correct serviceName and Port +func upstreamServiceNameAndPort(service *networking.IngressServiceBackend) (string, intstr.IntOrString) { + if service != nil { + if service.Port.Number > 0 { + return service.Name, intstr.FromInt(int(service.Port.Number)) + } + if service.Port.Name != "" { + return service.Name, intstr.FromString(service.Port.Name) + } + } + return "", intstr.IntOrString{} } // sysctlSomaxconn returns the maximum number of connections that can be queued diff --git a/internal/ingress/status/status.go b/internal/ingress/status/status.go index 506ae398cc..cabc6b3a2c 100644 --- a/internal/ingress/status/status.go +++ b/internal/ingress/status/status.go @@ -275,7 +275,7 @@ func runUpdate(ing *ingress.Ingress, status []apiv1.LoadBalancerIngress, return nil, nil } - ingClient := client.NetworkingV1beta1().Ingresses(ing.Namespace) + ingClient := client.NetworkingV1().Ingresses(ing.Namespace) currIng, err := ingClient.Get(context.TODO(), ing.Name, metav1.GetOptions{}) if err != nil { return nil, errors.Wrap(err, fmt.Sprintf("unexpected error searching Ingress %v/%v", ing.Namespace, ing.Name)) diff --git a/internal/ingress/status/status_test.go b/internal/ingress/status/status_test.go index 9ad0c29cf4..9578c8f731 100644 --- a/internal/ingress/status/status_test.go +++ b/internal/ingress/status/status_test.go @@ -24,7 +24,7 @@ import ( "time" apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testclient "k8s.io/client-go/kubernetes/fake" @@ -328,7 +328,7 @@ func TestStatusActions(t *testing.T) { newIPs := []apiv1.LoadBalancerIngress{{ IP: "11.0.0.2", }} - fooIngress1, err1 := fk.Client.NetworkingV1beta1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{}) + fooIngress1, err1 := fk.Client.NetworkingV1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{}) if err1 != nil { t.Fatalf("unexpected error") } @@ -343,7 +343,7 @@ func TestStatusActions(t *testing.T) { fk.Shutdown() // ingress should be empty newIPs2 := []apiv1.LoadBalancerIngress{} - fooIngress2, err2 := fk.Client.NetworkingV1beta1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{}) + fooIngress2, err2 := fk.Client.NetworkingV1().Ingresses(apiv1.NamespaceDefault).Get(context.TODO(), "foo_ingress_1", metav1.GetOptions{}) if err2 != nil { t.Fatalf("unexpected error") } @@ -352,7 +352,7 @@ func TestStatusActions(t *testing.T) { t.Fatalf("returned %v but expected %v", fooIngress2CurIPs, newIPs2) } - oic, err := fk.Client.NetworkingV1beta1().Ingresses(metav1.NamespaceDefault).Get(context.TODO(), "foo_ingress_different_class", metav1.GetOptions{}) + oic, err := fk.Client.NetworkingV1().Ingresses(metav1.NamespaceDefault).Get(context.TODO(), "foo_ingress_different_class", metav1.GetOptions{}) if err != nil { t.Fatalf("unexpected error") } diff --git a/internal/ingress/types.go b/internal/ingress/types.go index 84d964b7a0..a1cbdf685d 100644 --- a/internal/ingress/types.go +++ b/internal/ingress/types.go @@ -18,7 +18,7 @@ package ingress import ( apiv1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/internal/ingress/annotations" diff --git a/internal/k8s/main.go b/internal/k8s/main.go index 364d7c8ec1..8539c7d2fd 100644 --- a/internal/k8s/main.go +++ b/internal/k8s/main.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog/v2" apiv1 "k8s.io/api/core/v1" - networkingv1beta1 "k8s.io/api/networking/v1beta1" + networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/version" clientset "k8s.io/client-go/kubernetes" @@ -121,46 +121,40 @@ func MetaNamespaceKey(obj interface{}) string { return key } -// IsIngressV1Beta1Ready indicates if the running Kubernetes version is at least v1.18.0 -var IsIngressV1Beta1Ready bool - // IsIngressV1Ready indicates if the running Kubernetes version is at least v1.19.0 var IsIngressV1Ready bool // IngressClass indicates the class of the Ingress to use as filter -var IngressClass *networkingv1beta1.IngressClass +var IngressClass *networkingv1.IngressClass // IngressNGINXController defines the valid value of IngressClass // Controller field for ingress-nginx const IngressNGINXController = "k8s.io/ingress-nginx" -// NetworkingIngressAvailable checks if the package "k8s.io/api/networking/v1beta1" -// is available or not and if Ingress V1 is supported (k8s >= v1.18.0) -func NetworkingIngressAvailable(client clientset.Interface) (bool, bool, bool) { - // check kubernetes version to use new ingress package or not - version114, _ := version.ParseGeneric("v1.14.0") - version118, _ := version.ParseGeneric("v1.18.0") +// NetworkingIngressAvailable checks if the package "k8s.io/api/networking/v1" +// is available or not and if Ingress V1 is supported (k8s >= v1.19.0) +func NetworkingIngressAvailable(client clientset.Interface) bool { version119, _ := version.ParseGeneric("v1.19.0") serverVersion, err := client.Discovery().ServerVersion() if err != nil { - return false, false, false + return false } runningVersion, err := version.ParseGeneric(serverVersion.String()) if err != nil { klog.ErrorS(err, "unexpected error parsing running Kubernetes version") - return false, false, false + return false } - return runningVersion.AtLeast(version114), runningVersion.AtLeast(version118), runningVersion.AtLeast(version119) + return runningVersion.AtLeast(version119) } // default path type is Prefix to not break existing definitions -var defaultPathType = networkingv1beta1.PathTypePrefix +var defaultPathType = networkingv1.PathTypePrefix // SetDefaultNGINXPathType sets a default PathType when is not defined. -func SetDefaultNGINXPathType(ing *networkingv1beta1.Ingress) { +func SetDefaultNGINXPathType(ing *networkingv1.Ingress) { for _, rule := range ing.Spec.Rules { if rule.IngressRuleValue.HTTP == nil { continue @@ -172,7 +166,7 @@ func SetDefaultNGINXPathType(ing *networkingv1beta1.Ingress) { p.PathType = &defaultPathType } - if *p.PathType == networkingv1beta1.PathTypeImplementationSpecific { + if *p.PathType == networkingv1.PathTypeImplementationSpecific { p.PathType = &defaultPathType } } diff --git a/test/e2e/admission/admission.go b/test/e2e/admission/admission.go index b6cf638fe4..71b86200d6 100644 --- a/test/e2e/admission/admission.go +++ b/test/e2e/admission/admission.go @@ -56,14 +56,14 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { ginkgo.By("rejects ingress when memcached is not configured") - _, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) + _, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) assert.NotNil(ginkgo.GinkgoT(), err, "creating ingress with global throttle annotations when memcached is not configured") ginkgo.By("accepts ingress when memcached is not configured") f.UpdateNginxConfigMapData("global-rate-limit-memcached-host", "memc.default.svc.cluster.local") - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "creating ingress with global throttle annotations when memcached is configured") f.WaitForNginxServer(host, @@ -76,7 +76,7 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { host := "admission-test" firstIngress := framework.NewSingleIngress("first-ingress", "/", host, f.Namespace, framework.EchoService, 80, nil) - _, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) + _, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "creating ingress") f.WaitForNginxServer(host, @@ -85,7 +85,7 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { }) secondIngress := framework.NewSingleIngress("second-ingress", "/", host, f.Namespace, framework.EchoService, 80, nil) - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), secondIngress, metav1.CreateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), secondIngress, metav1.CreateOptions{}) assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress with the same host and path should return an error") }) @@ -93,7 +93,7 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { host := "admission-test" firstIngress := framework.NewSingleIngress("first-ingress", "/", host, f.Namespace, framework.EchoService, 80, nil) - _, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) + _, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "creating ingress") f.WaitForNginxServer(host, @@ -106,7 +106,7 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { "nginx.ingress.kubernetes.io/canary-by-header": "CanaryByHeader", } secondIngress := framework.NewSingleIngress("second-ingress", "/", host, f.Namespace, framework.SlowEchoService, 80, canaryAnnotations) - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), secondIngress, metav1.CreateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), secondIngress, metav1.CreateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "creating an ingress with the same host and path should not return an error using a canary annotation") }) @@ -117,35 +117,10 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { "nginx.ingress.kubernetes.io/configuration-snippet": "something invalid", } firstIngress := framework.NewSingleIngress("first-ingress", "/", host, f.Namespace, framework.EchoService, 80, annotations) - _, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) + _, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Create(context.TODO(), firstIngress, metav1.CreateOptions{}) assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress with invalid configuration should return an error") }) - ginkgo.It("should not return an error the ingress definition uses the deprecated extensions package", func() { - err := createIngress(f.Namespace, validIngress) - assert.Nil(ginkgo.GinkgoT(), err, "creating an ingress using kubectl") - - f.WaitForNginxConfiguration(func(cfg string) bool { - return strings.Contains(cfg, "extensions") - }) - - f.HTTPTestClient(). - GET("/"). - WithHeader("Host", "extensions"). - Expect(). - Status(http.StatusOK) - }) - - ginkgo.It("should return an error if the ingress definition uses the deprecated extensions package and invalid annotations", func() { - err := createIngress(f.Namespace, invalidIngress) - assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress using kubectl") - - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), "extensions", metav1.GetOptions{}) - if !apierrors.IsNotFound(err) { - assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress with invalid configuration should return an error") - } - }) - ginkgo.It("should not return an error if the Ingress V1 definition is valid", func() { if !f.IsIngressV1Ready { ginkgo.Skip("Test requires Kubernetes v1.19 or higher") @@ -173,7 +148,7 @@ var _ = framework.IngressNginxDescribe("[Serial] admission controller", func() { err := createIngress(f.Namespace, invalidV1Ingress) assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress using kubectl") - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), "extensions", metav1.GetOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), "extensions", metav1.GetOptions{}) if !apierrors.IsNotFound(err) { assert.NotNil(ginkgo.GinkgoT(), err, "creating an ingress with invalid configuration should return an error") } @@ -191,43 +166,6 @@ func uninstallChart(f *framework.Framework) error { } const ( - validIngress = ` -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: extensions -spec: - rules: - - host: extensions - http: - paths: - - path: / - backend: - serviceName: echo - servicePort: 80 ---- -` - - invalidIngress = ` -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: extensions - annotations: - nginx.ingress.kubernetes.io/configuration-snippet: | - invalid directive -spec: - rules: - - host: extensions - http: - paths: - - path: / - backend: - serviceName: echo - servicePort: 80 ---- -` - validV1Ingress = ` apiVersion: networking.k8s.io/v1 kind: Ingress diff --git a/test/e2e/annotations/affinity.go b/test/e2e/annotations/affinity.go index a17df1cc6b..a4512ce151 100644 --- a/test/e2e/annotations/affinity.go +++ b/test/e2e/annotations/affinity.go @@ -25,9 +25,8 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -84,7 +83,7 @@ var _ = framework.DescribeAnnotation("affinity session-cookie-name", func() { ing.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/session-cookie-name"] = "OTHERCOOKIENAME" - _, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "updating ingress") framework.Sleep() @@ -119,6 +118,7 @@ var _ = framework.DescribeAnnotation("affinity session-cookie-name", func() { }) ginkgo.It("does not set the path to / on the generated cookie if there's more than one rule referring to the same backend", func() { + pathtype := networking.PathTypePrefix host := "morethanonerule.foo.com" annotations := make(map[string]string) annotations["nginx.ingress.kubernetes.io/affinity"] = "cookie" @@ -138,17 +138,27 @@ var _ = framework.DescribeAnnotation("affinity session-cookie-name", func() { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/something", + Path: "/something", + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, { - Path: "/somewhereelse", + Path: "/somewhereelse", + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, diff --git a/test/e2e/annotations/auth.go b/test/e2e/annotations/auth.go index 781a32b1b5..a1b0ba7bc2 100644 --- a/test/e2e/annotations/auth.go +++ b/test/e2e/annotations/auth.go @@ -30,7 +30,7 @@ import ( "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/test/e2e/framework" diff --git a/test/e2e/annotations/canary.go b/test/e2e/annotations/canary.go index c66e9b9815..b452ef3b0e 100644 --- a/test/e2e/annotations/canary.go +++ b/test/e2e/annotations/canary.go @@ -24,7 +24,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) diff --git a/test/e2e/annotations/customhttperrors.go b/test/e2e/annotations/customhttperrors.go index 7369ebe6e7..6f7c26b3c6 100644 --- a/test/e2e/annotations/customhttperrors.go +++ b/test/e2e/annotations/customhttperrors.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) diff --git a/test/e2e/annotations/satisfy.go b/test/e2e/annotations/satisfy.go index dba710b4b6..8c0f88d2f0 100644 --- a/test/e2e/annotations/satisfy.go +++ b/test/e2e/annotations/satisfy.go @@ -26,7 +26,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/test/e2e/framework" diff --git a/test/e2e/defaultbackend/with_hosts.go b/test/e2e/defaultbackend/with_hosts.go index 9a3d87a274..89c5f08a5c 100644 --- a/test/e2e/defaultbackend/with_hosts.go +++ b/test/e2e/defaultbackend/with_hosts.go @@ -22,9 +22,8 @@ import ( "github.com/onsi/ginkgo" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -48,9 +47,13 @@ var _ = framework.IngressNginxDescribe("[Default Backend] change default setting Annotations: annotations, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 8f5fb3884f..f1baf80be8 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -29,12 +29,11 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" apiextcs "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" @@ -62,8 +61,7 @@ var ( type Framework struct { BaseName string - IsIngressV1Ready bool - IsIngressV1Beta1Ready bool + IsIngressV1Ready bool // A Kubernetes and Service Catalog client KubeClientSet kubernetes.Interface @@ -104,7 +102,7 @@ func (f *Framework) BeforeEach() { f.KubeClientSet, err = kubernetes.NewForConfig(f.KubeConfig) assert.Nil(ginkgo.GinkgoT(), err, "creating a kubernetes client") - _, f.IsIngressV1Beta1Ready, f.IsIngressV1Ready = k8s.NetworkingIngressAvailable(f.KubeClientSet) + f.IsIngressV1Ready = k8s.NetworkingIngressAvailable(f.KubeClientSet) } f.Namespace, err = CreateKubeNamespace(f.BaseName, f.KubeClientSet) @@ -542,7 +540,7 @@ func waitForDeploymentRollout(kubeClientSet kubernetes.Interface, resource *apps // UpdateIngress runs the given updateFunc on the ingress func UpdateIngress(kubeClientSet kubernetes.Interface, namespace string, name string, updateFunc func(d *networking.Ingress) error) error { - ingress, err := kubeClientSet.NetworkingV1beta1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) + ingress, err := kubeClientSet.NetworkingV1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return err } @@ -559,7 +557,7 @@ func UpdateIngress(kubeClientSet kubernetes.Interface, namespace string, name st return err } - _, err = kubeClientSet.NetworkingV1beta1().Ingresses(namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) + _, err = kubeClientSet.NetworkingV1().Ingresses(namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) if err != nil { return err } @@ -580,6 +578,7 @@ func NewSingleIngress(name, path, host, ns, service string, port int, annotation // NewSingleIngressWithMultiplePaths creates a simple ingress rule with multiple paths func NewSingleIngressWithMultiplePaths(name string, paths []string, host, ns, service string, port int, annotations map[string]string) *networking.Ingress { + pathtype := networking.PathTypePrefix spec := networking.IngressSpec{ Rules: []networking.IngressRule{ { @@ -593,10 +592,15 @@ func NewSingleIngressWithMultiplePaths(name string, paths []string, host, ns, se for _, path := range paths { spec.Rules[0].IngressRuleValue.HTTP.Paths = append(spec.Rules[0].IngressRuleValue.HTTP.Paths, networking.HTTPIngressPath{ - Path: path, + Path: path, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: service, - ServicePort: intstr.FromInt(port), + Service: &networking.IngressServiceBackend{ + Name: service, + Port: networking.ServiceBackendPort{ + Number: int32(port), + }, + }, }, }) } @@ -605,6 +609,7 @@ func NewSingleIngressWithMultiplePaths(name string, paths []string, host, ns, se } func newSingleIngressWithRules(name, path, host, ns, service string, port int, annotations map[string]string, tlsHosts []string) *networking.Ingress { + pathtype := networking.PathTypePrefix spec := networking.IngressSpec{ Rules: []networking.IngressRule{ { @@ -612,10 +617,15 @@ func newSingleIngressWithRules(name, path, host, ns, service string, port int, a HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: path, + Path: path, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: service, - ServicePort: intstr.FromInt(port), + Service: &networking.IngressServiceBackend{ + Name: service, + Port: networking.ServiceBackendPort{ + Number: int32(port), + }, + }, }, }, }, @@ -644,10 +654,15 @@ func newSingleIngressWithRules(name, path, host, ns, service string, port int, a // NewSingleIngressWithBackendAndRules creates an ingress with both a default backend and a rule func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService string, defaultPort int, service string, port int, annotations map[string]string) *networking.Ingress { + pathtype := networking.PathTypePrefix spec := networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: defaultService, - ServicePort: intstr.FromInt(defaultPort), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: defaultService, + Port: networking.ServiceBackendPort{ + Number: int32(defaultPort), + }, + }, }, Rules: []networking.IngressRule{ { @@ -656,10 +671,15 @@ func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService st HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: path, + Path: path, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: service, - ServicePort: intstr.FromInt(port), + Service: &networking.IngressServiceBackend{ + Name: service, + Port: networking.ServiceBackendPort{ + Number: int32(port), + }, + }, }, }, }, @@ -675,9 +695,13 @@ func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService st // NewSingleCatchAllIngress creates a simple ingress with a catch-all backend func NewSingleCatchAllIngress(name, ns, service string, port int, annotations map[string]string) *networking.Ingress { spec := networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: service, - ServicePort: intstr.FromInt(port), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: service, + Port: networking.ServiceBackendPort{ + Number: int32(port), + }, + }, }, } return newSingleIngress(name, ns, annotations, spec) diff --git a/test/e2e/framework/k8s.go b/test/e2e/framework/k8s.go index 3ca4a3c465..14937e6bd4 100644 --- a/test/e2e/framework/k8s.go +++ b/test/e2e/framework/k8s.go @@ -28,7 +28,7 @@ import ( api "k8s.io/api/core/v1" core "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" k8sErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilnet "k8s.io/apimachinery/pkg/util/net" @@ -63,7 +63,7 @@ func (f *Framework) EnsureConfigMap(configMap *api.ConfigMap) (*api.ConfigMap, e // GetIngress gets an Ingress object from the given namespace, name and returns it, throws error if it does not exists. func (f *Framework) GetIngress(namespace string, name string) *networking.Ingress { - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "getting ingress") assert.NotNil(ginkgo.GinkgoT(), ing, "expected an ingress but none returned") return ing @@ -334,7 +334,7 @@ func createIngressWithRetries(c kubernetes.Interface, namespace string, obj *net return fmt.Errorf("Object provided to create is empty") } createFunc := func() (bool, error) { - _, err := c.NetworkingV1beta1().Ingresses(namespace).Create(context.TODO(), obj, metav1.CreateOptions{}) + _, err := c.NetworkingV1().Ingresses(namespace).Create(context.TODO(), obj, metav1.CreateOptions{}) if err == nil { return true, nil } @@ -355,7 +355,7 @@ func updateIngressWithRetries(c kubernetes.Interface, namespace string, obj *net return fmt.Errorf("Object provided to create is empty") } updateFunc := func() (bool, error) { - _, err := c.NetworkingV1beta1().Ingresses(namespace).Update(context.TODO(), obj, metav1.UpdateOptions{}) + _, err := c.NetworkingV1().Ingresses(namespace).Update(context.TODO(), obj, metav1.UpdateOptions{}) if err == nil { return true, nil } diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index e094166f1b..b0fa92b153 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -223,7 +223,7 @@ func WaitForNoIngressInNamespace(c kubernetes.Interface, namespace, name string) func noIngressInNamespace(c kubernetes.Interface, namespace, name string) wait.ConditionFunc { return func() (bool, error) { - ing, err := c.NetworkingV1beta1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) + ing, err := c.NetworkingV1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { return true, nil } @@ -245,7 +245,7 @@ func WaitForIngressInNamespace(c kubernetes.Interface, namespace, name string) e func ingressInNamespace(c kubernetes.Interface, namespace, name string) wait.ConditionFunc { return func() (bool, error) { - ing, err := c.NetworkingV1beta1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) + ing, err := c.NetworkingV1().Ingresses(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { return false, nil } diff --git a/test/e2e/ingress/multiple_rules.go b/test/e2e/ingress/multiple_rules.go index dd5abd7ae2..030be172ab 100644 --- a/test/e2e/ingress/multiple_rules.go +++ b/test/e2e/ingress/multiple_rules.go @@ -22,15 +22,14 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networkingv1beta1 "k8s.io/api/networking/v1beta1" - "k8s.io/apimachinery/pkg/util/intstr" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) var _ = framework.IngressNginxDescribe("single ingress - multiple hosts", func() { f := framework.NewDefaultFramework("simh") - + pathprefix := networking.PathTypePrefix ginkgo.BeforeEach(func() { f.NewEchoDeploymentWithNameAndReplicas("first-service", 1) f.NewEchoDeploymentWithNameAndReplicas("second-service", 1) @@ -43,16 +42,21 @@ var _ = framework.IngressNginxDescribe("single ingress - multiple hosts", func() ing := framework.NewSingleIngress("simh", "/", "first.host", f.Namespace, "first-service", 80, annotations) - ing.Spec.Rules = append(ing.Spec.Rules, networkingv1beta1.IngressRule{ + ing.Spec.Rules = append(ing.Spec.Rules, networking.IngressRule{ Host: "second.host", - IngressRuleValue: networkingv1beta1.IngressRuleValue{ - HTTP: &networkingv1beta1.HTTPIngressRuleValue{ - Paths: []networkingv1beta1.HTTPIngressPath{ + IngressRuleValue: networking.IngressRuleValue{ + HTTP: &networking.HTTPIngressRuleValue{ + Paths: []networking.HTTPIngressPath{ { - Path: "/", - Backend: networkingv1beta1.IngressBackend{ - ServiceName: "second-service", - ServicePort: intstr.FromInt(80), + Path: "/", + PathType: &pathprefix, + Backend: networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "second-service", + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, diff --git a/test/e2e/ingress/pathtype_exact.go b/test/e2e/ingress/pathtype_exact.go index 01e37836a2..38df19fcc8 100644 --- a/test/e2e/ingress/pathtype_exact.go +++ b/test/e2e/ingress/pathtype_exact.go @@ -22,7 +22,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networkingv1beta1 "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -35,9 +35,6 @@ var _ = framework.IngressNginxDescribe("[Ingress] [PathType] exact", func() { }) ginkgo.It("should choose exact location for /exact", func() { - if !f.IsIngressV1Beta1Ready { - ginkgo.Skip("Test requires Kubernetes v1.18 or higher") - } host := "exact.path" @@ -45,7 +42,7 @@ var _ = framework.IngressNginxDescribe("[Ingress] [PathType] exact", func() { "nginx.ingress.kubernetes.io/configuration-snippet": `more_set_input_headers "pathType: exact";`, } - var exactPathType = networkingv1beta1.PathTypeExact + var exactPathType = networking.PathTypeExact ing := framework.NewSingleIngress("exact", "/exact", host, f.Namespace, framework.EchoService, 80, annotations) ing.Spec.Rules[0].IngressRuleValue.HTTP.Paths[0].PathType = &exactPathType f.EnsureIngress(ing) diff --git a/test/e2e/ingress/pathtype_mixed.go b/test/e2e/ingress/pathtype_mixed.go index aac7d9ffa4..28e3049c92 100644 --- a/test/e2e/ingress/pathtype_mixed.go +++ b/test/e2e/ingress/pathtype_mixed.go @@ -23,7 +23,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networkingv1beta1 "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -34,12 +34,9 @@ var _ = framework.IngressNginxDescribe("[Ingress] [PathType] mix Exact and Prefi f.NewEchoDeployment() }) - var exactPathType = networkingv1beta1.PathTypeExact + var exactPathType = networking.PathTypeExact ginkgo.It("should choose the correct location", func() { - if !f.IsIngressV1Beta1Ready { - ginkgo.Skip("Test requires Kubernetes v1.18 or higher") - } host := "mixed.path" diff --git a/test/e2e/ingress/without_host.go b/test/e2e/ingress/without_host.go index 154767fa45..88cf62f00c 100644 --- a/test/e2e/ingress/without_host.go +++ b/test/e2e/ingress/without_host.go @@ -22,9 +22,8 @@ import ( "strings" "github.com/onsi/ginkgo" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -62,9 +61,13 @@ var _ = framework.IngressNginxDescribe("[Ingress] definition without host", func Namespace: f.Namespace, }, Spec: networking.IngressSpec{ - Backend: &networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, Rules: []networking.IngressRule{ { diff --git a/test/e2e/leaks/lua_ssl.go b/test/e2e/leaks/lua_ssl.go index 6eb8bbc63c..8756a973d8 100644 --- a/test/e2e/leaks/lua_ssl.go +++ b/test/e2e/leaks/lua_ssl.go @@ -103,7 +103,7 @@ func checkIngress(hostname string, f *framework.Framework) { } func deleteIngress(hostname string, f *framework.Framework) { - err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Delete(context.TODO(), hostname, metav1.DeleteOptions{}) + err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Delete(context.TODO(), hostname, metav1.DeleteOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "unexpected error deleting ingress") } diff --git a/test/e2e/lua/dynamic_certificates.go b/test/e2e/lua/dynamic_certificates.go index 455bf0fc29..f5585995eb 100644 --- a/test/e2e/lua/dynamic_certificates.go +++ b/test/e2e/lua/dynamic_certificates.go @@ -28,7 +28,7 @@ import ( "github.com/prometheus/common/expfmt" "github.com/prometheus/common/model" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/test/e2e/framework" @@ -45,7 +45,7 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { ginkgo.It("picks up the certificate when we add TLS spec to existing ingress", func() { ensureIngress(f, host, framework.EchoService) - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Spec.TLS = []networking.IngressTLS{ { @@ -59,7 +59,7 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { ing.Namespace) assert.Nil(ginkgo.GinkgoT(), err) - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) time.Sleep(waitForLuaSync) @@ -147,7 +147,7 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { }) ginkgo.It("picks up the updated certificate without reloading", func() { - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host) @@ -183,7 +183,7 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { }) ginkgo.It("falls back to using default certificate when secret gets deleted without reloading", func() { - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ensureHTTPSRequest(f, fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.GetURL(framework.HTTPS)), host, host) @@ -217,11 +217,11 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { ginkgo.It("picks up a non-certificate only change", func() { newHost := "foo2.com" - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Spec.Rules[0].Host = newHost - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) time.Sleep(waitForLuaSync) @@ -231,11 +231,11 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic certificates", func() { }) ginkgo.It("removes HTTPS configuration when we delete TLS spec", func() { - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Spec.TLS = []networking.IngressTLS{} - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) time.Sleep(waitForLuaSync) diff --git a/test/e2e/lua/dynamic_configuration.go b/test/e2e/lua/dynamic_configuration.go index 5fcebac7dc..0a88fb07bb 100644 --- a/test/e2e/lua/dynamic_configuration.go +++ b/test/e2e/lua/dynamic_configuration.go @@ -26,7 +26,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/ingress-nginx/test/e2e/framework" @@ -172,11 +172,11 @@ var _ = framework.IngressNginxDescribe("[Lua] dynamic configuration", func() { return true }) - ingress, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), "foo.com", metav1.GetOptions{}) + ingress, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), "foo.com", metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ingress.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/load-balance"] = "round_robin" - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ingress, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) f.HTTPTestClient(). diff --git a/test/e2e/servicebackend/service_backend.go b/test/e2e/servicebackend/service_backend.go index 86f39b8425..9fe883b7ee 100644 --- a/test/e2e/servicebackend/service_backend.go +++ b/test/e2e/servicebackend/service_backend.go @@ -22,13 +22,14 @@ import ( "github.com/onsi/ginkgo" corev1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) +var pathtype = networking.PathTypePrefix var _ = framework.IngressNginxDescribe("[Service] backend status code 503", func() { f := framework.NewDefaultFramework("service-backend") @@ -86,10 +87,15 @@ func buildIngressWithNonexistentService(host, namespace, path string) *networkin HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: path, + Path: path, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: backendService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: backendService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, @@ -116,10 +122,15 @@ func buildIngressWithUnavailableServiceEndpoints(host, namespace, path string) ( HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: path, + Path: path, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: backendService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: backendService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, diff --git a/test/e2e/servicebackend/service_externalname.go b/test/e2e/servicebackend/service_externalname.go index bd10519e77..437b35144b 100644 --- a/test/e2e/servicebackend/service_externalname.go +++ b/test/e2e/servicebackend/service_externalname.go @@ -27,6 +27,7 @@ import ( "github.com/stretchr/testify/assert" core "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -203,7 +204,15 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() { "nginx.ingress.kubernetes.io/upstream-vhost": "httpbin.org", } ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, annotations) - ing.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort = intstr.FromString(host) + namedBackend := networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: framework.HTTPBinService, + Port: networking.ServiceBackendPort{ + Name: host, + }, + }, + } + ing.Spec.Rules[0].HTTP.Paths[0].Backend = namedBackend f.EnsureIngress(ing) f.WaitForNginxServer(host, @@ -276,7 +285,15 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() { "nginx.ingress.kubernetes.io/upstream-vhost": "httpbin.org", } ing := framework.NewSingleIngress(host, "/", host, f.Namespace, framework.HTTPBinService, 80, annotations) - ing.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort = intstr.FromString(host) + namedBackend := networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: framework.HTTPBinService, + Port: networking.ServiceBackendPort{ + Name: host, + }, + }, + } + ing.Spec.Rules[0].HTTP.Paths[0].Backend = namedBackend f.EnsureIngress(ing) f.WaitForNginxServer(host, diff --git a/test/e2e/settings/disable_catch_all.go b/test/e2e/settings/disable_catch_all.go index 1a8791d807..f5d9bfadc4 100644 --- a/test/e2e/settings/disable_catch_all.go +++ b/test/e2e/settings/disable_catch_all.go @@ -24,9 +24,8 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -98,9 +97,13 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() { err := framework.UpdateIngress(f.KubeClientSet, f.Namespace, host, func(ingress *networking.Ingress) error { ingress.Spec.Rules = nil - ingress.Spec.Backend = &networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + ingress.Spec.DefaultBackend = &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, } return nil }) diff --git a/test/e2e/settings/global_external_auth.go b/test/e2e/settings/global_external_auth.go index 7960b6ca75..1e5bf4301c 100755 --- a/test/e2e/settings/global_external_auth.go +++ b/test/e2e/settings/global_external_auth.go @@ -25,7 +25,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" "k8s.io/ingress-nginx/test/e2e/framework" ) diff --git a/test/e2e/settings/ingress_class.go b/test/e2e/settings/ingress_class.go index 1fa02183f1..646efc7fac 100644 --- a/test/e2e/settings/ingress_class.go +++ b/test/e2e/settings/ingress_class.go @@ -26,7 +26,7 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" rbacv1 "k8s.io/api/rbac/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -67,11 +67,7 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { }, }, metav1.CreateOptions{}) - if !f.IsIngressV1Beta1Ready { - return - } - - _, err := f.KubeClientSet.NetworkingV1beta1().IngressClasses(). + _, err := f.KubeClientSet.NetworkingV1().IngressClasses(). Create(context.TODO(), &networking.IngressClass{ ObjectMeta: metav1.ObjectMeta{ Name: testIngressClassName, @@ -192,11 +188,11 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { Expect(). Status(http.StatusOK) - ing, err := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) delete(ing.Annotations, class.IngressKey) - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(ing.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(ing.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) framework.Sleep() @@ -214,9 +210,6 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { }) ginkgo.It("check scenarios for IngressClass and ingress.class annotation", func() { - if !f.IsIngressV1Beta1Ready { - ginkgo.Skip("Test requires Kubernetes v1.18 or higher") - } pod := f.GetIngressNGINXPod() @@ -269,7 +262,7 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { Status(http.StatusOK) ginkgo.By("only having ingress.class annotation") - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Annotations = map[string]string{ @@ -277,7 +270,7 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { } ing.Spec.IngressClassName = nil - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) f.WaitForNginxConfiguration(func(cfg string) bool { @@ -293,7 +286,7 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { Status(http.StatusOK) ginkgo.By("having an invalid ingress.class annotation and no IngressClassName") - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Annotations = map[string]string{ @@ -301,7 +294,7 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { } ing.Spec.IngressClassName = nil - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) framework.Sleep() @@ -317,13 +310,13 @@ var _ = framework.IngressNginxDescribe("[Flag] ingress-class", func() { Status(http.StatusNotFound) ginkgo.By("not having ingress.class annotation and invalid IngressClassName") - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err) ing.Annotations = map[string]string{} invalidClassName := "invalidclass" ing.Spec.IngressClassName = &invalidClassName - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Update(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err) framework.Sleep() diff --git a/test/e2e/settings/no_auth_locations.go b/test/e2e/settings/no_auth_locations.go index dd7112b5ae..8475b02181 100644 --- a/test/e2e/settings/no_auth_locations.go +++ b/test/e2e/settings/no_auth_locations.go @@ -25,9 +25,8 @@ import ( "github.com/onsi/ginkgo" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) @@ -96,6 +95,7 @@ var _ = framework.DescribeSetting("[Security] no-auth-locations", func() { }) func buildBasicAuthIngressWithSecondPath(host, namespace, secretName, pathName string) *networking.Ingress { + pathtype := networking.PathTypePrefix return &networking.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: host, @@ -113,17 +113,27 @@ func buildBasicAuthIngressWithSecondPath(host, namespace, secretName, pathName s HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, { - Path: pathName, + Path: pathName, + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, diff --git a/test/e2e/settings/server_tokens.go b/test/e2e/settings/server_tokens.go index 43ccc86d3e..d65d7b0213 100644 --- a/test/e2e/settings/server_tokens.go +++ b/test/e2e/settings/server_tokens.go @@ -21,13 +21,13 @@ import ( "github.com/onsi/ginkgo" - networking "k8s.io/api/networking/v1beta1" + networking "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/ingress-nginx/test/e2e/framework" ) var _ = framework.DescribeSetting("server-tokens", func() { + pathtype := networking.PathTypePrefix f := framework.NewDefaultFramework("server-tokens") serverTokens := "server-tokens" @@ -64,10 +64,15 @@ var _ = framework.DescribeSetting("server-tokens", func() { HTTP: &networking.HTTPIngressRuleValue{ Paths: []networking.HTTPIngressPath{ { - Path: "/", + Path: "/", + PathType: &pathtype, Backend: networking.IngressBackend{ - ServiceName: framework.EchoService, - ServicePort: intstr.FromInt(80), + Service: &networking.IngressServiceBackend{ + Name: framework.EchoService, + Port: networking.ServiceBackendPort{ + Number: int32(80), + }, + }, }, }, }, diff --git a/test/e2e/status/update.go b/test/e2e/status/update.go index af0c6b9a4f..07d30243f8 100644 --- a/test/e2e/status/update.go +++ b/test/e2e/status/update.go @@ -84,11 +84,11 @@ var _ = framework.IngressNginxDescribe("[Status] status update", func() { err = cmd.Process.Kill() assert.Nil(ginkgo.GinkgoT(), err, "unexpected error terminating kubectl proxy") - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "unexpected error getting %s/%v Ingress", f.Namespace, host) ing.Status.LoadBalancer.Ingress = []apiv1.LoadBalancerIngress{} - _, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).UpdateStatus(context.TODO(), ing, metav1.UpdateOptions{}) + _, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).UpdateStatus(context.TODO(), ing, metav1.UpdateOptions{}) assert.Nil(ginkgo.GinkgoT(), err, "unexpected error cleaning Ingress status") framework.Sleep(10 * time.Second) @@ -109,7 +109,7 @@ var _ = framework.IngressNginxDescribe("[Status] status update", func() { }() err = wait.Poll(5*time.Second, 4*time.Minute, func() (done bool, err error) { - ing, err = f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) + ing, err = f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace).Get(context.TODO(), host, metav1.GetOptions{}) if err != nil { return false, nil } From f2b73ce6e5fbefe6b551e5bce84f24ef6c3cb54c Mon Sep 17 00:00:00 2001 From: Tianhao Guo Date: Mon, 28 Jun 2021 02:47:24 +0800 Subject: [PATCH 24/38] add docs for syslog feature (#7219) --- docs/user-guide/nginx-configuration/configmap.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index df357d5e9f..5434f49653 100755 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -178,6 +178,9 @@ The following table shows a configuration option's name, type, and the default v |[proxy-buffering](#proxy-buffering)|string|"off"| |[limit-req-status-code](#limit-req-status-code)|int|503| |[limit-conn-status-code](#limit-conn-status-code)|int|503| +|[enable-syslog](#enable-syslog)|bool|false| +|[syslog-host](#syslog-host)|string|""| +|[syslog-port](#syslog-port)|int|514| |[no-tls-redirect-locations](#no-tls-redirect-locations)|string|"/.well-known/acme-challenge"| |[global-auth-url](#global-auth-url)|string|""| |[global-auth-method](#global-auth-method)|string|""| @@ -1071,6 +1074,18 @@ Sets the [status code to return in response to rejected requests](http://nginx.o Sets the [status code to return in response to rejected connections](http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_status). _**default:**_ 503 +## enable-syslog + +Enable [syslog](http://nginx.org/en/docs/syslog.html) feature for access log and error log. _**default:**_ false + +## syslog-host + +Sets the address of syslog server. The address can be specified as a domain name or IP address. + +## syslog-port + +Sets the port of syslog server. _**default:**_ 514 + ## no-tls-redirect-locations A comma-separated list of locations on which http requests will never get redirected to their https counterpart. From 60afa7d6acac18316c78076d00498437c696d6b1 Mon Sep 17 00:00:00 2001 From: Ray <61553+rctay@users.noreply.github.com> Date: Mon, 28 Jun 2021 02:53:24 +0800 Subject: [PATCH 25/38] Fix link to e2e-tests.md in developer-guide (#7201) --- docs/developer-guide/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-guide/getting-started.md b/docs/developer-guide/getting-started.md index eb5e7cae5e..1f648533e4 100644 --- a/docs/developer-guide/getting-started.md +++ b/docs/developer-guide/getting-started.md @@ -67,7 +67,7 @@ FOCUS="no-auth-locations" make kind-e2e-test Valid values are defined in the describe definition of the e2e tests like [Default Backend](https://github.com/kubernetes/ingress-nginx/blob/master/test/e2e/defaultbackend/default_backend.go#L29) -The complete list of tests can be found [here](e2e-tests.md) +The complete list of tests can be found [here](../e2e-tests.md) ### Custom docker image From cfde9df26fe15ed6acc3794dd9e4118e66d77059 Mon Sep 17 00:00:00 2001 From: Bill Cassidy Date: Sun, 27 Jun 2021 17:09:24 -0400 Subject: [PATCH 26/38] Use ENV expansion for namespace in args (#7146) Update the DaemonSet namespace references to use the `POD_NAMESPACE` environment variable in the same way that the Deployment does. --- .../ingress-nginx/templates/controller-daemonset.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/ingress-nginx/templates/controller-daemonset.yaml b/charts/ingress-nginx/templates/controller-daemonset.yaml index 2f6def5897..2d03d40c80 100644 --- a/charts/ingress-nginx/templates/controller-daemonset.yaml +++ b/charts/ingress-nginx/templates/controller-daemonset.yaml @@ -74,22 +74,22 @@ spec: args: - /nginx-ingress-controller {{- if .Values.defaultBackend.enabled }} - - --default-backend-service={{ .Release.Namespace }}/{{ include "ingress-nginx.defaultBackend.fullname" . }} + - --default-backend-service=$(POD_NAMESPACE)/{{ include "ingress-nginx.defaultBackend.fullname" . }} {{- end }} {{- if .Values.controller.publishService.enabled }} - --publish-service={{ template "ingress-nginx.controller.publishServicePath" . }} {{- end }} - --election-id={{ .Values.controller.electionID }} - --ingress-class={{ .Values.controller.ingressClass }} - - --configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.controller.fullname" . }} + - --configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.controller.fullname" . }} {{- if .Values.tcp }} - - --tcp-services-configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.fullname" . }}-tcp + - --tcp-services-configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.fullname" . }}-tcp {{- end }} {{- if .Values.udp }} - - --udp-services-configmap={{ .Release.Namespace }}/{{ include "ingress-nginx.fullname" . }}-udp + - --udp-services-configmap=$(POD_NAMESPACE)/{{ include "ingress-nginx.fullname" . }}-udp {{- end }} {{- if .Values.controller.scope.enabled }} - - --watch-namespace={{ default .Release.Namespace .Values.controller.scope.namespace }} + - --watch-namespace={{ default "$(POD_NAMESPACE)" .Values.controller.scope.namespace }} {{- end }} {{- if and .Values.controller.reportNodeInternalIp .Values.controller.hostNetwork }} - --report-node-internal-ip-address={{ .Values.controller.reportNodeInternalIp }} From 9898bae89402d5efc5ae10e1badcd15d3aec6326 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Mon, 28 Jun 2021 05:51:24 +0800 Subject: [PATCH 27/38] chart: using Helm builtin capabilities check (#7190) Signed-off-by: Jintao Zhang --- charts/ingress-nginx/templates/controller-servicemonitor.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/ingress-nginx/templates/controller-servicemonitor.yaml b/charts/ingress-nginx/templates/controller-servicemonitor.yaml index 066488a040..17894c8be2 100644 --- a/charts/ingress-nginx/templates/controller-servicemonitor.yaml +++ b/charts/ingress-nginx/templates/controller-servicemonitor.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}} +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.controller.metrics.enabled .Values.controller.metrics.serviceMonitor.enabled -}} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: From 4168ab9296592fb66e35aa1196f8741c0ddbf5c1 Mon Sep 17 00:00:00 2001 From: Sathish Ramani Date: Mon, 28 Jun 2021 06:21:24 +0800 Subject: [PATCH 28/38] Update proper default value for HTTP2MaxConcurrentStreams in Docs (#6944) It should be 128 as documented in https://github.com/kubernetes/ingress-nginx/blob/master/internal/ingress/controller/config/config.go#L780 --- docs/user-guide/nginx-configuration/configmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 5434f49653..0258d7954c 100755 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -54,7 +54,7 @@ The following table shows a configuration option's name, type, and the default v |[http2-max-field-size](#http2-max-field-size)|string|"4k"| |[http2-max-header-size](#http2-max-header-size)|string|"16k"| |[http2-max-requests](#http2-max-requests)|int|1000| -|[http2-max-concurrent-streams](#http2-max-concurrent-streams)|int|1000| +|[http2-max-concurrent-streams](#http2-max-concurrent-streams)|int|128| |[hsts](#hsts)|bool|"true"| |[hsts-include-subdomains](#hsts-include-subdomains)|bool|"true"| |[hsts-max-age](#hsts-max-age)|string|"15724800"| From 62609f2849b839489097b9adc6a5151e93301bc1 Mon Sep 17 00:00:00 2001 From: Mansur Marvanov Date: Tue, 29 Jun 2021 22:14:41 +0900 Subject: [PATCH 29/38] Fix MaxWorkerOpenFiles calculation on high cores nodes (#7107) * Fix MaxWorkerOpenFiles calculation on high cores nodes * Add e2e test for rlimit_nofile * Fix doc for max-worker-open-files --- .../nginx-configuration/configmap.md | 2 +- internal/ingress/controller/nginx.go | 7 +-- test/e2e/settings/global_options.go | 58 +++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 test/e2e/settings/global_options.go diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 0258d7954c..c947c7a86d 100755 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -454,7 +454,7 @@ _**default:**_ 16384 ## max-worker-open-files Sets the [maximum number of files](http://nginx.org/en/docs/ngx_core_module.html#worker_rlimit_nofile) that can be opened by each worker process. -The default of 0 means "max open files (system's limit) / [worker-processes](#worker-processes) - 1024". +The default of 0 means "max open files (system's limit) - 1024". _**default:**_ 0 ## map-hash-bucket-size diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 664d36b754..9fa139cb7e 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -512,12 +512,7 @@ func (n NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressC if cfg.MaxWorkerOpenFiles == 0 { // the limit of open files is per worker process // and we leave some room to avoid consuming all the FDs available - wp, err := strconv.Atoi(cfg.WorkerProcesses) - klog.V(3).InfoS("Worker processes", "count", wp) - if err != nil { - wp = 1 - } - maxOpenFiles := (rlimitMaxNumFiles() / wp) - 1024 + maxOpenFiles := rlimitMaxNumFiles() - 1024 klog.V(3).InfoS("Maximum number of open file descriptors", "value", maxOpenFiles) if maxOpenFiles < 1024 { // this means the value of RLIMIT_NOFILE is too low. diff --git a/test/e2e/settings/global_options.go b/test/e2e/settings/global_options.go new file mode 100644 index 0000000000..ef0487cc57 --- /dev/null +++ b/test/e2e/settings/global_options.go @@ -0,0 +1,58 @@ +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package settings + +import ( + "fmt" + "strings" + "syscall" + + "github.com/onsi/ginkgo" + "k8s.io/ingress-nginx/test/e2e/framework" +) + +var _ = framework.IngressNginxDescribe("global-options", func() { + f := framework.NewDefaultFramework("global-options") + + ginkgo.It("should have worker_rlimit_nofile option", func() { + f.WaitForNginxConfiguration(func(server string) bool { + return strings.Contains(server, fmt.Sprintf("worker_rlimit_nofile %d;", rlimitMaxNumFiles()-1024)) + + }) + }) + + ginkgo.It("should have worker_rlimit_nofile option and be independent on amount of worker processes", func() { + f.SetNginxConfigMapData(map[string]string{ + "worker-processes": "11", + }) + + f.WaitForNginxConfiguration(func(server string) bool { + return strings.Contains(server, "worker_processes 11;") && + strings.Contains(server, fmt.Sprintf("worker_rlimit_nofile %d;", rlimitMaxNumFiles()-1024)) + }) + }) +}) + +// rlimitMaxNumFiles returns hard limit for RLIMIT_NOFILE +func rlimitMaxNumFiles() int { + var rLimit syscall.Rlimit + err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) + if err != nil { + return 0 + } + return int(rLimit.Max) +} From 39e1d31f6ff19057364346af26a91d54c916865f Mon Sep 17 00:00:00 2001 From: wasker Date: Thu, 1 Jul 2021 11:10:15 -0700 Subject: [PATCH 30/38] Use v1 API contract. --- .../ingress/controller/controller_test.go | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/internal/ingress/controller/controller_test.go b/internal/ingress/controller/controller_test.go index dbea966915..2cbc650250 100644 --- a/internal/ingress/controller/controller_test.go +++ b/internal/ingress/controller/controller_test.go @@ -815,10 +815,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -925,10 +926,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, @@ -1035,10 +1037,11 @@ func TestMergeAlternativeBackends(t *testing.T) { Path: "/", PathType: &pathTypePrefix, Backend: networking.IngressBackend{ - ServiceName: "http-svc-canary", - ServicePort: intstr.IntOrString{ - Type: intstr.Int, - IntVal: 80, + Service: &networking.IngressServiceBackend{ + Name: "http-svc-canary", + Port: networking.ServiceBackendPort{ + Number: 80, + }, }, }, }, From 67ec22a8fcb99cc81dcddaec235b6ee8d9bc4fc7 Mon Sep 17 00:00:00 2001 From: wasker Date: Thu, 1 Jul 2021 11:10:29 -0700 Subject: [PATCH 31/38] Fixed setup for SSL UTs. --- build/run-in-docker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/run-in-docker.sh b/build/run-in-docker.sh index d6723c7a18..e31b985247 100755 --- a/build/run-in-docker.sh +++ b/build/run-in-docker.sh @@ -25,6 +25,9 @@ set -o pipefail # temporal directory for the /etc/ingress-controller directory INGRESS_VOLUME=$(mktemp -d) +# make sure directory for SSL cert storage exists under ingress volume +mkdir "${INGRESS_VOLUME}/ssl" + if [[ "$OSTYPE" == darwin* ]]; then INGRESS_VOLUME=/private$INGRESS_VOLUME fi From 55ea3784cdfb2c83111a94a13be631f95cf3173f Mon Sep 17 00:00:00 2001 From: Matt1360 <568198+Matt1360@users.noreply.github.com> Date: Tue, 29 Jun 2021 15:27:39 -0400 Subject: [PATCH 32/38] ingress/tcp: add additional error logging on failed (#7208) --- internal/ingress/controller/tcp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/ingress/controller/tcp.go b/internal/ingress/controller/tcp.go index a97c46a7ed..eedecc71ab 100644 --- a/internal/ingress/controller/tcp.go +++ b/internal/ingress/controller/tcp.go @@ -82,6 +82,7 @@ func (p *TCPProxy) Handle(conn net.Conn) { hostPort := net.JoinHostPort(proxy.IP, fmt.Sprintf("%v", proxy.Port)) clientConn, err := net.Dial("tcp", hostPort) if err != nil { + klog.V(4).ErrorS(err, "error dialing proxy", "ip", proxy.IP, "port", proxy.Port, "hostname", proxy.Hostname) return } defer clientConn.Close() From 8ca9c12765e78fb237a6371c781a57f684b37647 Mon Sep 17 00:00:00 2001 From: Arsh Sharma <56963264+RinkiyaKeDad@users.noreply.github.com> Date: Thu, 1 Jul 2021 18:13:54 +0530 Subject: [PATCH 33/38] replacing master with main for k/k8s.io links (#7307) Signed-off-by: RinkiyaKeDad --- RELEASE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 50324bf71c..69ed202448 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -32,7 +32,7 @@ The sha is available in output from [cloud build](https://console.cloud.google.c 2a. Promote images: -* Open pull request to promote [staging image](https://github.com/kubernetes/k8s.io/blob/master/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml) +* Open pull request to promote [staging image](https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml) * e2e-test-runner * e2e-test-cfssl * e2e-test-echo @@ -53,7 +53,7 @@ The sha is available in output from [cloud build](https://console.cloud.google.c 4a. Promote images: -* Open pull request to promote [staging image](https://github.com/kubernetes/k8s.io/blob/master/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml) +* Open pull request to promote [staging image](https://github.com/kubernetes/k8s.io/blob/main/k8s.gcr.io/images/k8s-staging-ingress-nginx/images.yaml) * controller 5. Release helm chart: From 2adde8681f7b8a51d46ef3402cb4b67086b88ee3 Mon Sep 17 00:00:00 2001 From: Ricardo Katz Date: Thu, 1 Jul 2021 15:59:42 -0300 Subject: [PATCH 34/38] Add file containing stable release (#7313) --- RELEASE.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 69ed202448..c752b2a348 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -74,5 +74,7 @@ The sha is available in output from [cloud build](https://console.cloud.google.c * Update the version in [docs/deploy/index.md](docs/deploy/index.md) * Update Supported versions in the Support Versions table in the README.md * Merge + +* Update the stable.txt file to reflect the release to be created -7. Github release \ No newline at end of file +7. Github release From a26d8f888e1f62f8a3d0faefe4ab5a535830abd2 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Sun, 4 Jul 2021 23:06:18 +0200 Subject: [PATCH 35/38] Handle named (non-numeric) ports correctly (#7311) Signed-off-by: Carlos Panato --- cmd/plugin/commands/ingresses/ingresses.go | 2 +- .../commands/ingresses/ingresses_test.go | 75 +++++++++++ .../ingress/controller/template/template.go | 4 + .../controller/template/template_test.go | 120 ++++++++++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 cmd/plugin/commands/ingresses/ingresses_test.go diff --git a/cmd/plugin/commands/ingresses/ingresses.go b/cmd/plugin/commands/ingresses/ingresses.go index 4227053200..dff9671038 100644 --- a/cmd/plugin/commands/ingresses/ingresses.go +++ b/cmd/plugin/commands/ingresses/ingresses.go @@ -227,7 +227,7 @@ func serviceToNameAndPort(svc *networking.IngressServiceBackend) (string, intstr return svcName, intstr.FromInt(int(svc.Port.Number)) } if svc.Port.Name != "" { - return svcName, intstr.FromString(svc.Port.String()) + return svcName, intstr.FromString(svc.Port.Name) } } return "", intstr.IntOrString{} diff --git a/cmd/plugin/commands/ingresses/ingresses_test.go b/cmd/plugin/commands/ingresses/ingresses_test.go new file mode 100644 index 0000000000..6a8d8837ff --- /dev/null +++ b/cmd/plugin/commands/ingresses/ingresses_test.go @@ -0,0 +1,75 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package ingresses + +import ( + "testing" + + networking "k8s.io/api/networking/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +func TestGetIngressInformation(t *testing.T) { + + testcases := map[string]struct { + ServiceBackend *networking.IngressServiceBackend + wantName string + wantPort intstr.IntOrString + }{ + "empty ingressServiceBackend": { + ServiceBackend: &networking.IngressServiceBackend{}, + wantName: "", + wantPort: intstr.IntOrString{}, + }, + "ingressServiceBackend with port 8080": { + ServiceBackend: &networking.IngressServiceBackend{ + Name: "test", + Port: networking.ServiceBackendPort{ + Number: 8080, + }, + }, + wantName: "test", + wantPort: intstr.IntOrString{ + Type: intstr.Int, + IntVal: 8080, + }, + }, + "ingressServiceBackend with port name a-svc": { + ServiceBackend: &networking.IngressServiceBackend{ + Name: "test", + Port: networking.ServiceBackendPort{ + Name: "a-svc", + }, + }, + wantName: "test", + wantPort: intstr.IntOrString{ + Type: intstr.String, + StrVal: "a-svc", + }, + }, + } + + for title, testCase := range testcases { + gotName, gotPort := serviceToNameAndPort(testCase.ServiceBackend) + if gotName != testCase.wantName { + t.Fatalf("%s: expected '%v' but returned %v", title, testCase.wantName, gotName) + } + if gotPort != testCase.wantPort { + t.Fatalf("%s: expected '%v' but returned %v", title, testCase.wantPort, gotPort) + } + } +} diff --git a/internal/ingress/controller/template/template.go b/internal/ingress/controller/template/template.go index 3d46262b42..5388b6f782 100644 --- a/internal/ingress/controller/template/template.go +++ b/internal/ingress/controller/template/template.go @@ -988,6 +988,8 @@ func getIngressInformation(i, h, p interface{}) *ingressInformation { info.Service = ing.Spec.DefaultBackend.Service.Name if ing.Spec.DefaultBackend.Service.Port.Number > 0 { info.ServicePort = strconv.Itoa(int(ing.Spec.DefaultBackend.Service.Port.Number)) + } else { + info.ServicePort = ing.Spec.DefaultBackend.Service.Port.Name } } @@ -1022,6 +1024,8 @@ func getIngressInformation(i, h, p interface{}) *ingressInformation { info.Service = rPath.Backend.Service.Name if rPath.Backend.Service.Port.Number > 0 { info.ServicePort = strconv.Itoa(int(rPath.Backend.Service.Port.Number)) + } else { + info.ServicePort = rPath.Backend.Service.Port.Name } return info diff --git a/internal/ingress/controller/template/template_test.go b/internal/ingress/controller/template/template_test.go index 2c6b62ea47..2d6ef8ae81 100644 --- a/internal/ingress/controller/template/template_test.go +++ b/internal/ingress/controller/template/template_test.go @@ -940,6 +940,76 @@ func TestGetIngressInformation(t *testing.T) { 10, &ingressInformation{}, }, + "valid ingress definition with name validIng in namespace default using a service with name a-svc port number 8080": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "validIng", + Namespace: apiv1.NamespaceDefault, + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + }, + Spec: networking.IngressSpec{ + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "a-svc", + Port: networking.ServiceBackendPort{ + Number: 8080, + }, + }, + }, + }, + }, + }, + "host1", + "", + &ingressInformation{ + Namespace: "default", + Rule: "validIng", + Path: "/", + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + Service: "a-svc", + ServicePort: "8080", + }, + }, + "valid ingress definition with name validIng in namespace default using a service with name a-svc port name b-svc": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "validIng", + Namespace: apiv1.NamespaceDefault, + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + }, + Spec: networking.IngressSpec{ + DefaultBackend: &networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "a-svc", + Port: networking.ServiceBackendPort{ + Name: "b-svc", + }, + }, + }, + }, + }, + }, + "host1", + "", + &ingressInformation{ + Namespace: "default", + Rule: "validIng", + Path: "/", + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + Service: "a-svc", + ServicePort: "b-svc", + }, + }, "valid ingress definition with name validIng in namespace default": { &ingress.Ingress{ Ingress: networking.Ingress{ @@ -1021,6 +1091,56 @@ func TestGetIngressInformation(t *testing.T) { ServicePort: "80", }, }, + "valid ingress definition with name demo in namespace something and path /ok using a service with name b-svc port name b-svc-80": { + &ingress.Ingress{ + Ingress: networking.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "demo", + Namespace: "something", + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + }, + Spec: networking.IngressSpec{ + Rules: []networking.IngressRule{ + { + Host: "foo.bar", + IngressRuleValue: networking.IngressRuleValue{ + HTTP: &networking.HTTPIngressRuleValue{ + Paths: []networking.HTTPIngressPath{ + { + Path: "/ok", + PathType: &pathPrefix, + Backend: networking.IngressBackend{ + Service: &networking.IngressServiceBackend{ + Name: "b-svc", + Port: networking.ServiceBackendPort{ + Name: "b-svc-80", + }, + }, + }, + }, + }, + }, + }, + }, + {}, + }, + }, + }, + }, + "foo.bar", + "/ok", + &ingressInformation{ + Namespace: "something", + Rule: "demo", + Annotations: map[string]string{ + "ingress.annotation": "ok", + }, + Service: "b-svc", + ServicePort: "b-svc-80", + }, + }, } for title, testCase := range testcases { From bfc5a8a55420ef96d23a565b8bfc6a61d7c7cd23 Mon Sep 17 00:00:00 2001 From: Kundan Kumar Date: Mon, 5 Jul 2021 02:38:19 +0530 Subject: [PATCH 36/38] Updated v1beta1 to v1 as its deprecated (#7308) --- docs/examples/affinity/cookie/ingress.yaml | 2 +- docs/examples/auth/client-certs/ingress.yaml | 2 +- .../customization/configuration-snippets/ingress.yaml | 2 +- .../external-auth-headers/deploy/echo-service.yaml | 4 ++-- docs/examples/grpc/ingress.yaml | 2 +- docs/examples/tls-termination/README.md | 2 +- docs/user-guide/fcgi-services.md | 2 +- docs/user-guide/nginx-configuration/annotations.md | 2 +- docs/user-guide/third-party-addons/opentracing.md | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/examples/affinity/cookie/ingress.yaml b/docs/examples/affinity/cookie/ingress.yaml index 57edbdbd3e..eac973fde2 100644 --- a/docs/examples/affinity/cookie/ingress.yaml +++ b/docs/examples/affinity/cookie/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-test diff --git a/docs/examples/auth/client-certs/ingress.yaml b/docs/examples/auth/client-certs/ingress.yaml index cf5f701b2a..7172081b46 100644 --- a/docs/examples/auth/client-certs/ingress.yaml +++ b/docs/examples/auth/client-certs/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/customization/configuration-snippets/ingress.yaml b/docs/examples/customization/configuration-snippets/ingress.yaml index 07af3552f9..70d9042c7d 100644 --- a/docs/examples/customization/configuration-snippets/ingress.yaml +++ b/docs/examples/customization/configuration-snippets/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-configuration-snippet diff --git a/docs/examples/customization/external-auth-headers/deploy/echo-service.yaml b/docs/examples/customization/external-auth-headers/deploy/echo-service.yaml index 1c3667c7c1..075421807b 100644 --- a/docs/examples/customization/external-auth-headers/deploy/echo-service.yaml +++ b/docs/examples/customization/external-auth-headers/deploy/echo-service.yaml @@ -43,7 +43,7 @@ spec: selector: k8s-app: demo-echo-service --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: public-demo-echo-service @@ -61,7 +61,7 @@ spec: servicePort: 80 path: / --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: secure-demo-echo-service diff --git a/docs/examples/grpc/ingress.yaml b/docs/examples/grpc/ingress.yaml index 1d76476d11..1d45665edb 100644 --- a/docs/examples/grpc/ingress.yaml +++ b/docs/examples/grpc/ingress.yaml @@ -1,4 +1,4 @@ -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/examples/tls-termination/README.md b/docs/examples/tls-termination/README.md index 1a17d6d218..f3096db2ee 100644 --- a/docs/examples/tls-termination/README.md +++ b/docs/examples/tls-termination/README.md @@ -11,7 +11,7 @@ You need a [TLS cert](../PREREQUISITES.md#tls-certificates) and a [test HTTP ser Create a `ingress.yaml` file. ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-test diff --git a/docs/user-guide/fcgi-services.md b/docs/user-guide/fcgi-services.md index 7c9dd6138b..62271c2cef 100644 --- a/docs/user-guide/fcgi-services.md +++ b/docs/user-guide/fcgi-services.md @@ -60,7 +60,7 @@ data: --- -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/user-guide/nginx-configuration/annotations.md b/docs/user-guide/nginx-configuration/annotations.md index ef9a4e5ef5..c6d3767025 100755 --- a/docs/user-guide/nginx-configuration/annotations.md +++ b/docs/user-guide/nginx-configuration/annotations.md @@ -394,7 +394,7 @@ For more information please see [the `server_name` documentation](http://nginx.o Using the annotation `nginx.ingress.kubernetes.io/server-snippet` it is possible to add custom configuration in the server configuration block. ```yaml -apiVersion: networking.k8s.io/v1beta1 +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: diff --git a/docs/user-guide/third-party-addons/opentracing.md b/docs/user-guide/third-party-addons/opentracing.md index 3bef8332c7..916b296373 100644 --- a/docs/user-guide/third-party-addons/opentracing.md +++ b/docs/user-guide/third-party-addons/opentracing.md @@ -168,7 +168,7 @@ In the Zipkin interface we can see the details: # Apply the Ingress Resource $ echo ' - apiVersion: networking.k8s.io/v1beta1 + apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: echo-ingress From f152efeddc074207102e8b1f7123a5d6da827668 Mon Sep 17 00:00:00 2001 From: boxjan Date: Mon, 5 Jul 2021 06:24:18 +0800 Subject: [PATCH 37/38] use listen to ensure the port is free (#6990) --- internal/net/net.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/net/net.go b/internal/net/net.go index b7fefb8b3b..712262f3a4 100644 --- a/internal/net/net.go +++ b/internal/net/net.go @@ -29,12 +29,12 @@ func IsIPV6(ip _net.IP) bool { // IsPortAvailable checks if a TCP port is available or not func IsPortAvailable(p int) bool { - conn, err := _net.Dial("tcp", fmt.Sprintf(":%v", p)) + ln, err := _net.Listen("tcp", fmt.Sprintf(":%v", p)) if err != nil { - return true + return false } - defer conn.Close() - return false + defer ln.Close() + return true } // IsIPv6Enabled checks if IPV6 is enabled or not and we have From b5507fba35e0f254f1e1228810511970f5ae564e Mon Sep 17 00:00:00 2001 From: Tom Hayward Date: Sun, 4 Jul 2021 20:08:20 -0700 Subject: [PATCH 38/38] remove mercurial from build (#7031) --- images/nginx/rootfs/build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/images/nginx/rootfs/build.sh b/images/nginx/rootfs/build.sh index ebea37cf64..501feffc4d 100755 --- a/images/nginx/rootfs/build.sh +++ b/images/nginx/rootfs/build.sh @@ -93,7 +93,6 @@ apk add \ geoip-dev \ perl-dev \ libedit-dev \ - mercurial \ alpine-sdk \ findutils \ curl ca-certificates \