From b2bde942d0bde05bffffef05407672d0ca407454 Mon Sep 17 00:00:00 2001 From: Jakub Warczarek Date: Thu, 25 May 2023 17:36:05 +0200 Subject: [PATCH 1/2] chore(deps): bump github.com/kong/kubernetes-testing-framework from 0.30.1 to 0.31.0 (#4079) --- go.mod | 25 +++--- go.sum | 42 ++++----- test/e2e/features_test.go | 11 +-- test/integration/webhook_test.go | 146 +------------------------------ 4 files changed, 38 insertions(+), 186 deletions(-) diff --git a/go.mod b/go.mod index 2104667333..76e79cd3bf 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,10 @@ module github.com/kong/kubernetes-ingress-controller/v2 go 1.20 // TODO: https://github.com/Kong/kubernetes-ingress-controller/issues/2953 -exclude sigs.k8s.io/gateway-api v0.6.2 +exclude ( + sigs.k8s.io/gateway-api v0.6.2 + sigs.k8s.io/gateway-api v0.7.0 +) require ( cloud.google.com/go/container v1.18.1 @@ -19,7 +22,7 @@ require ( github.com/kong/deck v1.20.0 github.com/kong/go-kong v0.42.0 github.com/kong/kubernetes-telemetry v0.0.4 - github.com/kong/kubernetes-testing-framework v0.30.1 + github.com/kong/kubernetes-testing-framework v0.31.0 github.com/lithammer/dedent v1.1.0 github.com/miekg/dns v1.1.54 github.com/mitchellh/mapstructure v1.5.0 @@ -44,8 +47,8 @@ require ( knative.dev/pkg v0.0.0-20230502134655-db8a35330281 sigs.k8s.io/controller-runtime v0.15.0 sigs.k8s.io/gateway-api v0.6.1 - sigs.k8s.io/kustomize/api v0.12.1 - sigs.k8s.io/kustomize/kyaml v0.13.9 + sigs.k8s.io/kustomize/api v0.13.4 + sigs.k8s.io/kustomize/kyaml v0.14.2 sigs.k8s.io/yaml v1.3.0 ) @@ -81,7 +84,7 @@ require ( github.com/chai2010/gettext-go v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v20.10.24+incompatible // indirect + github.com/docker/docker v20.10.25+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect @@ -92,7 +95,7 @@ require ( github.com/fatih/color v1.15.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fvbommel/sortorder v1.0.1 // indirect - github.com/go-errors/errors v1.0.1 // indirect + github.com/go-errors/errors v1.4.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.1 // indirect @@ -183,13 +186,13 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/cli-runtime v0.26.3 // indirect - k8s.io/klog/v2 v2.90.1 // indirect + k8s.io/cli-runtime v0.27.2 // indirect + k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/kubectl v0.26.3 // indirect - k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect + k8s.io/kubectl v0.27.2 // indirect + k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect knative.dev/serving v0.37.1 sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kind v0.17.0 // indirect + sigs.k8s.io/kind v0.19.0 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/go.sum b/go.sum index f578db9ce4..353353087c 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/deepmap/oapi-codegen v1.12.4 h1:pPmn6qI9MuOtCz82WY2Xaw46EQjgvxednXXrP github.com/deepmap/oapi-codegen v1.12.4/go.mod h1:3lgHGMu6myQ2vqbbTXH2H1o4eXFTGnFiDaOaKKl5yas= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= -github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v20.10.25+incompatible h1:URiHXOEOlhi6FS5U+YUE8YnsnZjIV3R+TFezL2ngdW0= +github.com/docker/docker v20.10.25+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -123,8 +123,8 @@ github.com/gammazero/deque v0.2.0/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZ github.com/gammazero/workerpool v1.1.3 h1:WixN4xzukFoN0XSeXF6puqEqFTl2mECI9S6W44HWy9Q= github.com/gammazero/workerpool v1.1.3/go.mod h1:wPjyBLDbyKnUn2XwwyD3EEwo9dHutia9/fwNmSHWACc= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -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-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logr/logr v1.0.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -220,8 +220,8 @@ github.com/hashicorp/go-memdb v1.3.4 h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8Io github.com/hashicorp/go-memdb v1.3.4/go.mod h1:uBTr1oQbtuMgd1SSGoR8YV27eT3sBHbYiNm53bMpgSg= github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= @@ -252,8 +252,8 @@ github.com/kong/go-kong v0.42.0 h1:N0Rth32eGq6S5x33Txu+Gv9ZJ3gG5noffDjqezwutfA= github.com/kong/go-kong v0.42.0/go.mod h1:YUq7A3gcwk+9Z1ajwzVY2HnSyL/IKq/TJHsJDqT8hJM= github.com/kong/kubernetes-telemetry v0.0.4 h1:6iDDocM4b/pIKJ/KrSSoQjvyaHBIBtBb4U9LdOqg8Js= github.com/kong/kubernetes-telemetry v0.0.4/go.mod h1:xopN/XY+5xCXoY8kfnjHf83yT6n4ezVcWKJxA7gmJUw= -github.com/kong/kubernetes-testing-framework v0.30.1 h1:FZCThCgf2xOi/pUbSzd5hW1ghUnZYihmvy9a3DHMRAE= -github.com/kong/kubernetes-testing-framework v0.30.1/go.mod h1:gnq+/PEPMXqH1lc1/tR4O9goQ3P2pR0T9llthQYebGQ= +github.com/kong/kubernetes-testing-framework v0.31.0 h1:3MTlUeiD/jV3ArdZWfRLidi7kchg19HI222dXQHwasw= +github.com/kong/kubernetes-testing-framework v0.31.0/go.mod h1:RKFMHJCDByNnHiw+hRLwR26eIZRgd5ImhwYjwK+yUQg= github.com/kong/semver/v4 v4.0.1 h1:DIcNR8W3gfx0KabFBADPalxxsp+q/5COwIFkkhrFQ2Y= github.com/kong/semver/v4 v4.0.1/go.mod h1:LImQ0oT15pJvSns/hs2laLca2zcYoHu5EsSNY0J6/QA= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -620,20 +620,20 @@ k8s.io/apiextensions-apiserver v0.27.2 h1:iwhyoeS4xj9Y7v8YExhUwbVuBhMr3Q4bd/laCl k8s.io/apiextensions-apiserver v0.27.2/go.mod h1:Oz9UdvGguL3ULgRdY9QMUzL2RZImotgxvGjdWRq6ZXQ= k8s.io/apimachinery v0.27.2 h1:vBjGaKKieaIreI+oQwELalVG4d8f3YAMNpWLzDXkxeg= k8s.io/apimachinery v0.27.2/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= -k8s.io/cli-runtime v0.26.3 h1:3ULe0oI28xmgeLMVXIstB+ZL5CTGvWSMVMLeHxitIuc= -k8s.io/cli-runtime v0.26.3/go.mod h1:5YEhXLV4kLt/OSy9yQwtSSNZU2Z7aTEYta1A+Jg4VC4= +k8s.io/cli-runtime v0.27.2 h1:9HI8gfReNujKXt16tGOAnb8b4NZ5E+e0mQQHKhFGwYw= +k8s.io/cli-runtime v0.27.2/go.mod h1:9UecpyPDTkhiYY4d9htzRqN+rKomJgyb4wi0OfrmCjw= k8s.io/client-go v0.27.2 h1:vDLSeuYvCHKeoQRhCXjxXO45nHVv2Ip4Fe0MfioMrhE= k8s.io/client-go v0.27.2/go.mod h1:tY0gVmUsHrAmjzHX9zs7eCjxcBsf8IiNe7KQ52biTcQ= k8s.io/component-base v0.27.2 h1:neju+7s/r5O4x4/txeUONNTS9r1HsPbyoPBAtHsDCpo= k8s.io/component-base v0.27.2/go.mod h1:5UPk7EjfgrfgRIuDBFtsEFAe4DAvP3U+M8RTzoSJkpo= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= -k8s.io/kubectl v0.26.3 h1:bZ5SgFyeEXw6XTc1Qji0iNdtqAC76lmeIIQULg2wNXM= -k8s.io/kubectl v0.26.3/go.mod h1:02+gv7Qn4dupzN3fi/9OvqqdW+uG/4Zi56vc4Zmsp1g= -k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= -k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kubectl v0.27.2 h1:sSBM2j94MHBFRWfHIWtEXWCicViQzZsb177rNsKBhZg= +k8s.io/kubectl v0.27.2/go.mod h1:GCOODtxPcrjh+EC611MqREkU8RjYBh10ldQCQ6zpFKw= +k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= +k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= knative.dev/networking v0.0.0-20230504184058-77975a12b2ee h1:d2dytSnwikNVtttk/lTjn7t6A9447DkUXADHR+zLOdU= knative.dev/networking v0.0.0-20230504184058-77975a12b2ee/go.mod h1:OG9AEepHd3dofzrkzb0IelqN5uzu10RjbSdhl5UruSE= knative.dev/pkg v0.0.0-20230502134655-db8a35330281 h1:9mN8O5XO68DKlkzEhFAShUx+O/I+TQR71vmTvYt8oF4= @@ -646,12 +646,12 @@ sigs.k8s.io/gateway-api v0.6.1 h1:d/nIkhtbU0zVoFsriKi8lXwBYKNopz3EGeSwDqxeTRs= sigs.k8s.io/gateway-api v0.6.1/go.mod h1:EYJT+jlPWTeNskjV0JTki/03WX1cyAnBhwBJfYHpV/0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kind v0.17.0 h1:CScmGz/wX66puA06Gj8OZb76Wmk7JIjgWf5JDvY7msM= -sigs.k8s.io/kind v0.17.0/go.mod h1:Qqp8AiwOlMZmJWs37Hgs31xcbiYXjtXlRBSftcnZXQk= -sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM= -sigs.k8s.io/kustomize/api v0.12.1/go.mod h1:y3JUhimkZkR6sbLNwfJHxvo1TCLwuwm14sCYnkH6S1s= -sigs.k8s.io/kustomize/kyaml v0.13.9 h1:Qz53EAaFFANyNgyOEJbT/yoIHygK40/ZcvU3rgry2Tk= -sigs.k8s.io/kustomize/kyaml v0.13.9/go.mod h1:QsRbD0/KcU+wdk0/L0fIp2KLnohkVzs6fQ85/nOXac4= +sigs.k8s.io/kind v0.19.0 h1:ZSUh6/kpab6fiowT6EqL4k8xSbedI2NWxyuUOtoPFe4= +sigs.k8s.io/kind v0.19.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs= +sigs.k8s.io/kustomize/api v0.13.4 h1:E38Hfx0G9R9v7vRgKshviPotJQETG0S2gD3JdHLCAsI= +sigs.k8s.io/kustomize/api v0.13.4/go.mod h1:Bkaavz5RKK6ZzP0zgPrB7QbpbBJKiHuD3BB0KujY7Ls= +sigs.k8s.io/kustomize/kyaml v0.14.2 h1:9WSwztbzwGszG1bZTziQUmVMrJccnyrLb5ZMKpJGvXw= +sigs.k8s.io/kustomize/kyaml v0.14.2/go.mod h1:AN1/IpawKilWD7V+YvQwRGUvuUOOWpjsHu6uHwonSF4= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/test/e2e/features_test.go b/test/e2e/features_test.go index d16bc0f184..a0a62d27bd 100644 --- a/test/e2e/features_test.go +++ b/test/e2e/features_test.go @@ -9,7 +9,6 @@ import ( "crypto/tls" "fmt" "net/http" - "os" "strings" "testing" "time" @@ -143,16 +142,8 @@ func TestWebhookUpdate(t *testing.T) { defer cancel() t.Log("building test cluster and environment") - configFile, err := os.CreateTemp(os.TempDir(), "webhook-kind-config-") - require.NoError(t, err) - defer os.Remove(configFile.Name()) - defer configFile.Close() - written, err := configFile.Write([]byte(webhookKINDConfig)) - require.NoError(t, err) - require.Equal(t, len(webhookKINDConfig), written) - clusterBuilder := kind.NewBuilder() - clusterBuilder.WithConfig(configFile.Name()) + clusterBuilder.WithConfigReader(strings.NewReader(webhookKINDConfig)) if clusterVersionStr != "" { clusterVersion, err := semver.ParseTolerant(clusterVersionStr) require.NoError(t, err) diff --git a/test/integration/webhook_test.go b/test/integration/webhook_test.go index ef30822c71..d8fb09ea94 100644 --- a/test/integration/webhook_test.go +++ b/test/integration/webhook_test.go @@ -6,7 +6,6 @@ package integration import ( "context" "fmt" - "net" "strings" "testing" "time" @@ -14,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/kong/kubernetes-testing-framework/pkg/clusters" "github.com/kong/kubernetes-testing-framework/pkg/clusters/types/kind" + "github.com/kong/kubernetes-testing-framework/pkg/utils/kubernetes/networking" "github.com/samber/lo" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +23,6 @@ import ( apierrors "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" "github.com/kong/kubernetes-ingress-controller/v2/internal/annotations" testutils "github.com/kong/kubernetes-ingress-controller/v2/internal/util/test" @@ -687,7 +686,7 @@ func waitForWebhookServiceConnective(ctx context.Context, configResourceName str waitCtx, cancel := context.WithTimeout(ctx, ingressWait) defer cancel() - return waitForConnectionOnServicePort(waitCtx, env.Cluster().Client(), consts.ControllerNamespace, svcName, svcPort, 10*time.Second) + return networking.WaitForConnectionOnServicePort(waitCtx, env.Cluster().Client(), consts.ControllerNamespace, svcName, svcPort, 10*time.Second) } func ensureAdmissionRegistration(ctx context.Context, configResourceName string, rules []admregv1.RuleWithOperations) (func() error, error) { @@ -730,144 +729,3 @@ func ensureAdmissionRegistration(ctx context.Context, configResourceName string, return closer, nil } - -// TODO: Below helper functions were copied from https://github.com/Kong/kubernetes-testing-framework/pull/643 -// and should be removed once a new version of KTF (with that PR) will be released and it will be possible -// to upgrade it in KIC. Read more about required steps in https://github.com/Kong/kubernetes-ingress-controller/issues/3981. - -// waitForServiceLoadBalancerAddress waits for a service provided by -// namespace/name to have an ingress IP or Host provisioned and returns that -// address. This function will throw an error if the service gets provisioned -// more than a single address, that is not supported. The context provided -// should have a timeout associated with it or you're going to have a bad time. -func waitForServiceLoadBalancerAddress(ctx context.Context, c kubernetes.Interface, namespace, name string) (string, bool, error) { - for { - select { - case <-ctx.Done(): - return "", false, fmt.Errorf("context completed while waiting for loadbalancer service to provision: %w", ctx.Err()) - default: - // retrieve a fresh copy of the service - service, err := c.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{}) - if err != nil { - return "", false, fmt.Errorf("error while trying to retrieve registry service: %w", err) - } - lbing := service.Status.LoadBalancer.Ingress - - // don't support services which have multiple addresses - if len(lbing) > 1 { - return "", false, fmt.Errorf("services with more than one load balancer address are not supported (found %d)", len(lbing)) - } - - // verify whether the loadbalancer details are provisioned - if len(lbing) == 1 { - for _, ing := range lbing { - if ing.Hostname != "" { - return ing.Hostname, false, nil - } - if ing.IP != "" { - return ing.IP, true, nil - } - } - } - } - } -} - -// waitForConnectionOnServicePort waits until it can make successful TCP connections -// to a service (provided by namespace/name). This will temporarily create a LoadBalancer -// type Service to allow connections to the Service and port from outside the cluster while -// the connection attempts are made using the LoadBalancer public address. -func waitForConnectionOnServicePort(ctx context.Context, c kubernetes.Interface, namespace, name string, port int, dialTimeout time.Duration) error { - svcClient := c.CoreV1().Services(namespace) - service, err := svcClient.Get(ctx, name, metav1.GetOptions{}) - if err != nil { - return err - } - const correspondingSvcNameLabel = "corresponding-service" - lbServiceName := "templb-" + name - tempLoadBalancer := &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: namespace, - Name: lbServiceName, - Labels: map[string]string{ - correspondingSvcNameLabel: name, - }, - }, - Spec: corev1.ServiceSpec{ - Type: corev1.ServiceTypeLoadBalancer, - // Copy the selector and ports of the service to check. - Selector: service.Spec.Selector, - Ports: service.Spec.Ports, - }, - } - - // Empty selector, we should create the endpoints separately. - // If the target service does not have a selector, it usually means that - // the endpoints of the target server is manually created, but not chosen from pods by labels in selector. - // so we need to manually create the same endpoints as the target service has here. - if len(service.Spec.Selector) == 0 { - epsClient := c.DiscoveryV1().EndpointSlices(namespace) - endpointSlices, err := epsClient.List( - ctx, metav1.ListOptions{LabelSelector: discoveryv1.LabelServiceName + "=" + name}, - ) - if err != nil { - return err - } - - // Recreate EndpointSlices for the lb service with proper metadata. - tempEndpointSlices := endpointSlices.DeepCopy().Items - for i := range tempEndpointSlices { - epsName := fmt.Sprintf("%s-%d", lbServiceName, i) - tempEndpointSlices[i].ObjectMeta = metav1.ObjectMeta{ - Namespace: namespace, - Name: epsName, - Labels: map[string]string{ - discoveryv1.LabelServiceName: lbServiceName, // Maps EndpointSlice to Service. - correspondingSvcNameLabel: name, - }, - } - if _, err = epsClient.Create(ctx, &tempEndpointSlices[i], metav1.CreateOptions{}); err != nil { - return err - } - // For each successfully created temporary EndpointSlice ensure deletion on return from the function. - defer func(epsName string) { - err := epsClient.Delete(ctx, epsName, metav1.DeleteOptions{}) - if err != nil && !apierrors.IsNotFound(err) { - fmt.Printf("failed to delete EndpointSlice %s/%s after testing, error %v\n", - namespace, epsName, err, - ) - } - }(epsName) - } - } - - if _, err = svcClient.Create(ctx, tempLoadBalancer, metav1.CreateOptions{}); err != nil { - return err - } - defer func() { - err := svcClient.Delete(ctx, lbServiceName, metav1.DeleteOptions{}) - if err != nil && !apierrors.IsNotFound(err) { - fmt.Printf("failed to delete service %s/%s after testing, error %v\n", - namespace, lbServiceName, err) - } - }() - - ip, _, err := waitForServiceLoadBalancerAddress(ctx, c, namespace, lbServiceName) - if err != nil { - return err - } - - ticker := time.NewTicker(time.Second) - address := fmt.Sprintf("%s:%d", ip, port) - for { - select { - case <-ctx.Done(): - return fmt.Errorf("context completed or dialTimeout reached while waiting for %s:%d to be connected", ip, port) - case <-ticker.C: - dialer := &net.Dialer{Timeout: dialTimeout} - if _, err := dialer.DialContext(ctx, "tcp", address); err == nil { - return nil - } - } - } -} From 74b39d2fa569fefb3ba96cdf268fd0d51fb6d182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Thu, 25 May 2023 17:44:55 +0200 Subject: [PATCH 2/2] chore: bump gateway to 3.3 (#4080) --- .github/workflows/_integration_tests.yaml | 4 ++-- config/image/enterprise/kustomization.yaml | 4 ++-- config/image/oss/kustomization.yaml | 2 +- deploy/single/all-in-one-dbless-enterprise.yaml | 2 +- deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml | 2 +- deploy/single/all-in-one-dbless-konnect-enterprise.yaml | 2 +- deploy/single/all-in-one-dbless-konnect.yaml | 2 +- deploy/single/all-in-one-dbless-legacy.yaml | 2 +- deploy/single/all-in-one-dbless.yaml | 2 +- deploy/single/all-in-one-postgres-enterprise.yaml | 8 ++++---- deploy/single/all-in-one-postgres.yaml | 8 ++++---- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/_integration_tests.yaml b/.github/workflows/_integration_tests.yaml index 56e3e45d15..93ef6e670e 100644 --- a/.github/workflows/_integration_tests.yaml +++ b/.github/workflows/_integration_tests.yaml @@ -11,7 +11,7 @@ on: type: string # TODO: Consider changing to "kong:latest" # See https://github.com/Kong/kubernetes-testing-framework/issues/542 - default: "3.2" + default: "3.3" required: false kong-enterprise-container-repo: type: string @@ -21,7 +21,7 @@ on: type: string # TODO: Consider changing to "kong/kong-gateway:latest" # See https://github.com/Kong/kubernetes-testing-framework/issues/542 - default: "3.2" + default: "3.3" required: false jobs: diff --git a/config/image/enterprise/kustomization.yaml b/config/image/enterprise/kustomization.yaml index a0eb5c3f4f..57ceb599ef 100644 --- a/config/image/enterprise/kustomization.yaml +++ b/config/image/enterprise/kustomization.yaml @@ -6,7 +6,7 @@ kind: Component images: - name: kong newName: kong/kong-gateway - newTag: '3.2' + newTag: '3.3' - name: kong-placeholder newName: kong/kong-gateway - newTag: '3.2' + newTag: '3.3' diff --git a/config/image/oss/kustomization.yaml b/config/image/oss/kustomization.yaml index aca02f2e43..91ebeeb84f 100644 --- a/config/image/oss/kustomization.yaml +++ b/config/image/oss/kustomization.yaml @@ -4,7 +4,7 @@ kind: Component images: - name: kong-placeholder newName: kong - newTag: '3.2' + newTag: '3.3' - name: kic-placeholder newName: kong/kubernetes-ingress-controller newTag: '2.9.3' diff --git a/deploy/single/all-in-one-dbless-enterprise.yaml b/deploy/single/all-in-one-dbless-enterprise.yaml index 1b98c4c31e..b5ccc06ff0 100644 --- a/deploy/single/all-in-one-dbless-enterprise.yaml +++ b/deploy/single/all-in-one-dbless-enterprise.yaml @@ -1769,7 +1769,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml b/deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml index 4201a615f8..ed46fbbd9d 100644 --- a/deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml +++ b/deploy/single/all-in-one-dbless-k4k8s-enterprise.yaml @@ -1774,7 +1774,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-dbless-konnect-enterprise.yaml b/deploy/single/all-in-one-dbless-konnect-enterprise.yaml index ffa0e01913..8a57f64329 100644 --- a/deploy/single/all-in-one-dbless-konnect-enterprise.yaml +++ b/deploy/single/all-in-one-dbless-konnect-enterprise.yaml @@ -1784,7 +1784,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-dbless-konnect.yaml b/deploy/single/all-in-one-dbless-konnect.yaml index 0daca271c6..e071c35a22 100644 --- a/deploy/single/all-in-one-dbless-konnect.yaml +++ b/deploy/single/all-in-one-dbless-konnect.yaml @@ -1784,7 +1784,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong:3.2 + image: kong:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-dbless-legacy.yaml b/deploy/single/all-in-one-dbless-legacy.yaml index fe3bb8c18a..a9bee3b880 100644 --- a/deploy/single/all-in-one-dbless-legacy.yaml +++ b/deploy/single/all-in-one-dbless-legacy.yaml @@ -1660,7 +1660,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong:3.2 + image: kong:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-dbless.yaml b/deploy/single/all-in-one-dbless.yaml index 7be7726d76..8542e230c9 100644 --- a/deploy/single/all-in-one-dbless.yaml +++ b/deploy/single/all-in-one-dbless.yaml @@ -1769,7 +1769,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong:3.2 + image: kong:3.3 lifecycle: preStop: exec: diff --git a/deploy/single/all-in-one-postgres-enterprise.yaml b/deploy/single/all-in-one-postgres-enterprise.yaml index 3bc7964ff5..ec4815de1f 100644 --- a/deploy/single/all-in-one-postgres-enterprise.yaml +++ b/deploy/single/all-in-one-postgres-enterprise.yaml @@ -1723,7 +1723,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 lifecycle: preStop: exec: @@ -1842,7 +1842,7 @@ spec: value: postgres - name: KONG_PG_PASSWORD value: kong - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 name: wait-for-migrations serviceAccountName: kong-serviceaccount volumes: @@ -1941,7 +1941,7 @@ spec: value: postgres - name: KONG_PG_PORT value: "5432" - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 name: kong-migrations imagePullSecrets: - name: kong-enterprise-edition-docker @@ -1956,7 +1956,7 @@ spec: value: postgres - name: KONG_PG_PORT value: "5432" - image: kong/kong-gateway:3.2 + image: kong/kong-gateway:3.3 name: wait-for-postgres restartPolicy: OnFailure --- diff --git a/deploy/single/all-in-one-postgres.yaml b/deploy/single/all-in-one-postgres.yaml index 3d94ee0faf..ac40449c38 100644 --- a/deploy/single/all-in-one-postgres.yaml +++ b/deploy/single/all-in-one-postgres.yaml @@ -1678,7 +1678,7 @@ spec: value: /dev/stderr - name: KONG_ROUTER_FLAVOR value: traditional - image: kong:3.2 + image: kong:3.3 lifecycle: preStop: exec: @@ -1779,7 +1779,7 @@ spec: value: postgres - name: KONG_PG_PASSWORD value: kong - image: kong:3.2 + image: kong:3.3 name: wait-for-migrations serviceAccountName: kong-serviceaccount volumes: @@ -1868,7 +1868,7 @@ spec: value: postgres - name: KONG_PG_PORT value: "5432" - image: kong:3.2 + image: kong:3.3 name: kong-migrations initContainers: - command: @@ -1881,7 +1881,7 @@ spec: value: postgres - name: KONG_PG_PORT value: "5432" - image: kong:3.2 + image: kong:3.3 name: wait-for-postgres restartPolicy: OnFailure ---