diff --git a/Makefile b/Makefile index 4bda085..1adc5cb 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,10 @@ define add_helm_repo helm repo add argo https://argoproj.github.io/argo-helm endef -define install_helm_charts +define setup_cluster + kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/experimental-install.yaml helm install argo-rollouts argo/argo-rollouts --values ./test/cluster-setup/argo-rollouts-values.yml --version 2.37.2 - helm install traefik traefik/traefik --values ./test/cluster-setup/traefik-values.yml --version 29.0.1 + helm install traefik traefik/traefik --values ./test/cluster-setup/traefik-values.yml --version 31.0.0 endef define install_k8s_resources @@ -55,7 +56,7 @@ setup-e2e-cluster: ifeq (${IS_E2E_CLUSTER},) kind create cluster --name ${E2E_CLUSTER_NAME} --config ./test/cluster-setup/cluster-config.yml $(call add_helm_repo) - $(call install_helm_charts) + $(call setup_cluster) $(call install_k8s_resources) endif diff --git a/docs/features/grpc.md b/docs/features/grpc.md index 7c4b918..d330ff1 100644 --- a/docs/features/grpc.md +++ b/docs/features/grpc.md @@ -1,8 +1,5 @@ # GRPC routes -!!! warning - We tested grpc support only by looking at resources state as traffic providers didn't support grpc well at the moment of development, but it would be great if you contribute a real example. Due to this, gRPC support is not included in the released builds, but can be tested by building the plugin from the source code. - To use GRPCRoute: 1. Install your traffic provider @@ -27,7 +24,7 @@ spec: - name: argo-rollouts-canary-service # canary service you have created on the 5th step port: 80 ``` -7. Create Rollout resource +1. Create Rollout resource ```yaml apiVersion: argoproj.io/v1alpha1 kind: Rollout diff --git a/go.mod b/go.mod index 730a897..8737f45 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,8 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 k8s.io/client-go v0.30.1 - sigs.k8s.io/gateway-api v1.0.0 + sigs.k8s.io/e2e-framework v0.4.0 + sigs.k8s.io/gateway-api v1.1.0 ) require ( @@ -27,7 +28,7 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/imdario/mergo v0.3.16 // indirect @@ -55,7 +56,6 @@ require ( google.golang.org/grpc v1.63.2 // indirect k8s.io/component-base v0.30.1 // indirect sigs.k8s.io/controller-runtime v0.18.2 // indirect - sigs.k8s.io/e2e-framework v0.4.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index ee78514..3516458 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,9 @@ github.com/argoproj/argo-rollouts v1.6.6 h1:JCJ0cGAwWkh2xCAHZ1OQmrobysRjCatmG9IZaLJpS1g= github.com/argoproj/argo-rollouts v1.6.6/go.mod h1:X2kTiBaYCSounmw1kmONdIZTwJNzNQYC0SrXUgSw9UI= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= @@ -25,6 +26,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= @@ -60,6 +63,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= @@ -93,7 +98,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -111,10 +115,10 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= -github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= +github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= +github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= +github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= +github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -141,13 +145,22 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk= github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk= +github.com/vladimirvivien/gexe v0.2.0 h1:nbdAQ6vbZ+ZNsolCgSVb9Fno60kzSuvtzVh6Ytqi/xY= +github.com/vladimirvivien/gexe v0.2.0/go.mod h1:LHQL00w/7gDUKIak24n801ABp8C+ni6eBht9vGVst8w= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 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.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -209,16 +222,12 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= -k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= -k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= -k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs= +k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= -k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= @@ -235,6 +244,8 @@ sigs.k8s.io/e2e-framework v0.4.0 h1:4yYmFDNNoTnazqmZJXQ6dlQF1vrnDbutmxlyvBpC5rY= sigs.k8s.io/e2e-framework v0.4.0/go.mod h1:JilFQPF1OL1728ABhMlf9huse7h+uBJDXl9YeTs49A8= sigs.k8s.io/gateway-api v1.0.0 h1:iPTStSv41+d9p0xFydll6d7f7MOBGuqXM6p2/zVYMAs= sigs.k8s.io/gateway-api v1.0.0/go.mod h1:4cUgr0Lnp5FZ0Cdq8FdRwCvpiWws7LVhLHGIudLlf4c= +sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM= +sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs= 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/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/pkg/mocks/plugin.go b/pkg/mocks/plugin.go index 11a517c..f5cba69 100644 --- a/pkg/mocks/plugin.go +++ b/pkg/mocks/plugin.go @@ -71,15 +71,15 @@ var HTTPRouteObj = gatewayv1.HTTPRoute{ }, } -var GRPCRouteObj = v1alpha2.GRPCRoute{ +var GRPCRouteObj = gatewayv1.GRPCRoute{ ObjectMeta: metav1.ObjectMeta{ Name: GRPCRouteName, Namespace: RolloutNamespace, }, - Spec: v1alpha2.GRPCRouteSpec{ - Rules: []v1alpha2.GRPCRouteRule{ + Spec: gatewayv1.GRPCRouteSpec{ + Rules: []gatewayv1.GRPCRouteRule{ { - BackendRefs: []v1alpha2.GRPCBackendRef{ + BackendRefs: []gatewayv1.GRPCBackendRef{ { BackendRef: gatewayv1.BackendRef{ BackendObjectReference: gatewayv1.BackendObjectReference{ diff --git a/pkg/plugin/grpcroute.go b/pkg/plugin/grpcroute.go index 32fd00c..f8eb30b 100644 --- a/pkg/plugin/grpcroute.go +++ b/pkg/plugin/grpcroute.go @@ -11,7 +11,6 @@ import ( pluginTypes "github.com/argoproj/argo-rollouts/utils/plugin/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" ) const ( @@ -22,8 +21,8 @@ func (r *RpcPlugin) setGRPCRouteWeight(rollout *v1alpha1.Rollout, desiredWeight ctx := context.TODO() grpcRouteClient := r.GRPCRouteClient if !r.IsTest { - gatewayV1alpha2 := r.GatewayAPIClientset.GatewayV1alpha2() - grpcRouteClient = gatewayV1alpha2.GRPCRoutes(gatewayAPIConfig.Namespace) + gatewayClientv1 := r.GatewayAPIClientset.GatewayV1() + grpcRouteClient = gatewayClientv1.GRPCRoutes(gatewayAPIConfig.Namespace) } grpcRoute, err := grpcRouteClient.Get(ctx, gatewayAPIConfig.GRPCRoute, metav1.GetOptions{}) if err != nil { @@ -80,8 +79,8 @@ func (r *RpcPlugin) setGRPCHeaderRoute(rollout *v1alpha1.Rollout, headerRouting grpcRouteName := gatewayAPIConfig.GRPCRoute clientset := r.TestClientset if !r.IsTest { - gatewayV1alpha2 := r.GatewayAPIClientset.GatewayV1alpha2() - grpcRouteClient = gatewayV1alpha2.GRPCRoutes(gatewayAPIConfig.Namespace) + gatewayClientV1 := r.GatewayAPIClientset.GatewayV1() + grpcRouteClient = gatewayClientV1.GRPCRoutes(gatewayAPIConfig.Namespace) clientset = r.Clientset.CoreV1().ConfigMaps(gatewayAPIConfig.Namespace) } configMap, err := utils.GetOrCreateConfigMap(gatewayAPIConfig.ConfigMap, utils.CreateConfigMapOptions{ @@ -129,12 +128,12 @@ func (r *RpcPlugin) setGRPCHeaderRoute(rollout *v1alpha1.Rollout, headerRouting break } } - grpcHeaderRouteRule := v1alpha2.GRPCRouteRule{ - Matches: []v1alpha2.GRPCRouteMatch{}, - BackendRefs: []v1alpha2.GRPCBackendRef{ + grpcHeaderRouteRule := gatewayv1.GRPCRouteRule{ + Matches: []gatewayv1.GRPCRouteMatch{}, + BackendRefs: []gatewayv1.GRPCBackendRef{ { - BackendRef: v1alpha2.BackendRef{ - BackendObjectReference: v1alpha2.BackendObjectReference{ + BackendRef: gatewayv1.BackendRef{ + BackendObjectReference: gatewayv1.BackendObjectReference{ Group: &canaryServiceGroup, Kind: &canaryServiceKind, Name: canaryServiceName, @@ -146,14 +145,14 @@ func (r *RpcPlugin) setGRPCHeaderRoute(rollout *v1alpha1.Rollout, headerRouting } matchLength := len(grpcRouteRule.Matches) if matchLength == 0 { - grpcHeaderRouteRule.Matches = []v1alpha2.GRPCRouteMatch{ + grpcHeaderRouteRule.Matches = []gatewayv1.GRPCRouteMatch{ { Headers: grpcHeaderRouteRuleList, }, } } else { for i := 0; i < matchLength; i++ { - grpcHeaderRouteRule.Matches = append(grpcHeaderRouteRule.Matches, v1alpha2.GRPCRouteMatch{ + grpcHeaderRouteRule.Matches = append(grpcHeaderRouteRule.Matches, gatewayv1.GRPCRouteMatch{ Method: grpcRouteRule.Matches[i].Method, Headers: grpcHeaderRouteRuleList, }) @@ -231,11 +230,11 @@ func (r *RpcPlugin) setGRPCHeaderRoute(rollout *v1alpha1.Rollout, headerRouting return pluginTypes.RpcError{} } -func getGRPCHeaderRouteRuleList(headerRouting *v1alpha1.SetHeaderRoute) ([]v1alpha2.GRPCHeaderMatch, pluginTypes.RpcError) { - grpcHeaderRouteRuleList := []v1alpha2.GRPCHeaderMatch{} +func getGRPCHeaderRouteRuleList(headerRouting *v1alpha1.SetHeaderRoute) ([]gatewayv1.GRPCHeaderMatch, pluginTypes.RpcError) { + grpcHeaderRouteRuleList := []gatewayv1.GRPCHeaderMatch{} for _, headerRule := range headerRouting.Match { - grpcHeaderRouteRule := v1alpha2.GRPCHeaderMatch{ - Name: v1alpha2.GRPCHeaderName(headerRule.HeaderName), + grpcHeaderRouteRule := gatewayv1.GRPCHeaderMatch{ + Name: gatewayv1.GRPCHeaderName(headerRule.HeaderName), } switch { case headerRule.HeaderValue.Exact != "": @@ -267,8 +266,8 @@ func (r *RpcPlugin) removeGRPCManagedRoutes(managedRouteNameList []v1alpha1.Mang grpcRouteName := gatewayAPIConfig.GRPCRoute managedRouteMap := make(ManagedRouteMap) if !r.IsTest { - gatewayV1alpha2 := r.GatewayAPIClientset.GatewayV1alpha2() - grpcRouteClient = gatewayV1alpha2.GRPCRoutes(gatewayAPIConfig.Namespace) + gatewayClientv1 := r.GatewayAPIClientset.GatewayV1() + grpcRouteClient = gatewayClientv1.GRPCRoutes(gatewayAPIConfig.Namespace) clientset = r.Clientset.CoreV1().ConfigMaps(gatewayAPIConfig.Namespace) } configMap, err := utils.GetOrCreateConfigMap(gatewayAPIConfig.ConfigMap, utils.CreateConfigMapOptions{ diff --git a/pkg/plugin/httproute.go b/pkg/plugin/httproute.go index 2afa028..53596f6 100644 --- a/pkg/plugin/httproute.go +++ b/pkg/plugin/httproute.go @@ -21,8 +21,8 @@ func (r *RpcPlugin) setHTTPRouteWeight(rollout *v1alpha1.Rollout, desiredWeight ctx := context.TODO() httpRouteClient := r.HTTPRouteClient if !r.IsTest { - gatewayClientv1 := r.GatewayAPIClientset.GatewayV1() - httpRouteClient = gatewayClientv1.HTTPRoutes(gatewayAPIConfig.Namespace) + gatewayClientV1 := r.GatewayAPIClientset.GatewayV1() + httpRouteClient = gatewayClientV1.HTTPRoutes(gatewayAPIConfig.Namespace) } httpRoute, err := httpRouteClient.Get(ctx, gatewayAPIConfig.HTTPRoute, metav1.GetOptions{}) if err != nil { diff --git a/pkg/plugin/plugin_test.go b/pkg/plugin/plugin_test.go index cb979bc..0dd61e2 100644 --- a/pkg/plugin/plugin_test.go +++ b/pkg/plugin/plugin_test.go @@ -34,7 +34,7 @@ func TestRunSuccessfully(t *testing.T) { LogCtx: utils.SetupLog(), IsTest: true, HTTPRouteClient: gwFake.NewSimpleClientset(&mocks.HTTPRouteObj).GatewayV1().HTTPRoutes(mocks.RolloutNamespace), - GRPCRouteClient: gwFake.NewSimpleClientset(&mocks.GRPCRouteObj).GatewayV1alpha2().GRPCRoutes(mocks.RolloutNamespace), + GRPCRouteClient: gwFake.NewSimpleClientset(&mocks.GRPCRouteObj).GatewayV1().GRPCRoutes(mocks.RolloutNamespace), TCPRouteClient: gwFake.NewSimpleClientset(&mocks.TCPPRouteObj).GatewayV1alpha2().TCPRoutes(mocks.RolloutNamespace), TestClientset: fake.NewSimpleClientset(&mocks.ConfigMapObj).CoreV1().ConfigMaps(mocks.RolloutNamespace), } diff --git a/pkg/plugin/tcproute.go b/pkg/plugin/tcproute.go index 996321e..26ada98 100644 --- a/pkg/plugin/tcproute.go +++ b/pkg/plugin/tcproute.go @@ -13,8 +13,8 @@ func (r *RpcPlugin) setTCPRouteWeight(rollout *v1alpha1.Rollout, desiredWeight i ctx := context.TODO() tcpRouteClient := r.TCPRouteClient if !r.IsTest { - gatewayV1alpha2 := r.GatewayAPIClientset.GatewayV1alpha2() - tcpRouteClient = gatewayV1alpha2.TCPRoutes(gatewayAPIConfig.Namespace) + gatewayClientV1alpha2 := r.GatewayAPIClientset.GatewayV1alpha2() + tcpRouteClient = gatewayClientV1alpha2.TCPRoutes(gatewayAPIConfig.Namespace) } tcpRoute, err := tcpRouteClient.Get(ctx, gatewayAPIConfig.TCPRoute, metav1.GetOptions{}) if err != nil { diff --git a/pkg/plugin/types.go b/pkg/plugin/types.go index 6374fb4..73f0407 100644 --- a/pkg/plugin/types.go +++ b/pkg/plugin/types.go @@ -8,7 +8,6 @@ import ( v1 "k8s.io/client-go/kubernetes/typed/core/v1" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" - "sigs.k8s.io/gateway-api/apis/v1beta1" gatewayAPIClientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned" gatewayApiClientv1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1" gatewayApiClientv1alpha2 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1alpha2" @@ -17,13 +16,13 @@ import ( type RpcPlugin struct { HTTPRouteClient gatewayApiClientv1.HTTPRouteInterface TCPRouteClient gatewayApiClientv1alpha2.TCPRouteInterface - GRPCRouteClient gatewayApiClientv1alpha2.GRPCRouteInterface + GRPCRouteClient gatewayApiClientv1.GRPCRouteInterface TestClientset v1.ConfigMapInterface GatewayAPIClientset *gatewayAPIClientset.Clientset Clientset *kubernetes.Clientset UpdatedHTTPRouteMock *gatewayv1.HTTPRoute UpdatedTCPRouteMock *v1alpha2.TCPRoute - UpdatedGRPCRouteMock *v1alpha2.GRPCRoute + UpdatedGRPCRouteMock *gatewayv1.GRPCRoute LogCtx *logrus.Entry IsTest bool } @@ -82,23 +81,23 @@ type GRPCRoute struct { type ManagedRouteMap map[string]map[string]int -type HTTPRouteRule v1beta1.HTTPRouteRule +type HTTPRouteRule gatewayv1.HTTPRouteRule -type GRPCRouteRule v1alpha2.GRPCRouteRule +type GRPCRouteRule gatewayv1.GRPCRouteRule type TCPRouteRule v1alpha2.TCPRouteRule -type HTTPRouteRuleList []v1beta1.HTTPRouteRule +type HTTPRouteRuleList []gatewayv1.HTTPRouteRule -type GRPCRouteRuleList []v1alpha2.GRPCRouteRule +type GRPCRouteRuleList []gatewayv1.GRPCRouteRule type TCPRouteRuleList []v1alpha2.TCPRouteRule -type HTTPBackendRef v1beta1.HTTPBackendRef +type HTTPBackendRef gatewayv1.HTTPBackendRef -type GRPCBackendRef v1alpha2.GRPCBackendRef +type GRPCBackendRef gatewayv1.GRPCBackendRef -type TCPBackendRef v1beta1.BackendRef +type TCPBackendRef gatewayv1.BackendRef type GatewayAPIRoute interface { HTTPRoute | GRPCRoute | TCPRoute diff --git a/test/e2e/constants.go b/test/e2e/constants.go index 5d88852..78cfa6b 100644 --- a/test/e2e/constants.go +++ b/test/e2e/constants.go @@ -4,7 +4,6 @@ import ( "time" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - "sigs.k8s.io/gateway-api/apis/v1alpha2" ) const ( @@ -58,9 +57,9 @@ var ( Value: "test", } - FIRST_HEADER_BASED_GRPC_ROUTE_VALUE v1alpha2.GRPCHeaderMatch + FIRST_HEADER_BASED_GRPC_ROUTE_VALUE gatewayv1.GRPCHeaderMatch headerBasedGRPCRouteValueType = gatewayv1.HeaderMatchExact - LAST_HEADER_BASED_GRPC_ROUTE_VALUE = v1alpha2.GRPCHeaderMatch{ + LAST_HEADER_BASED_GRPC_ROUTE_VALUE = gatewayv1.GRPCHeaderMatch{ Name: "X-Test", Type: &headerBasedGRPCRouteValueType, Value: "test", diff --git a/test/e2e/single_header_based_grpcroute_test.go b/test/e2e/single_header_based_grpcroute_test.go index 9a2989e..26ae881 100644 --- a/test/e2e/single_header_based_grpcroute_test.go +++ b/test/e2e/single_header_based_grpcroute_test.go @@ -18,7 +18,7 @@ import ( "sigs.k8s.io/e2e-framework/klient/wait/conditions" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" - "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ) func TestSingleHeaderBasedGRPCRoute(t *testing.T) { @@ -36,7 +36,7 @@ func TestSingleHeaderBasedGRPCRoute(t *testing.T) { } func setupSingleHeaderBasedGRPCRouteEnv(ctx context.Context, t *testing.T, config *envconf.Config) context.Context { - var grpcRoute v1alpha2.GRPCRoute + var grpcRoute gatewayv1.GRPCRoute var rollout v1alpha1.Rollout clusterResources := config.Client().Resources() resourcesMap := map[string]*unstructured.Unstructured{} @@ -245,9 +245,9 @@ func teardownSingleHeaderBasedGRPCRouteEnv(ctx context.Context, t *testing.T, co return ctx } -func getMatchHeaderBasedGRPCRouteFetcher(t *testing.T, targetWeight int32, targetHeaderBasedRouteValue v1alpha2.GRPCHeaderMatch) func(k8s.Object) bool { +func getMatchHeaderBasedGRPCRouteFetcher(t *testing.T, targetWeight int32, targetHeaderBasedRouteValue gatewayv1.GRPCHeaderMatch) func(k8s.Object) bool { return func(obj k8s.Object) bool { - var grpcRoute v1alpha2.GRPCRoute + var grpcRoute gatewayv1.GRPCRoute unstructuredGRPCRoute, ok := obj.(*unstructured.Unstructured) if !ok { logrus.Error("k8s object type assertion was failed") @@ -267,7 +267,6 @@ func getMatchHeaderBasedGRPCRouteFetcher(t *testing.T, targetWeight int32, targe return len(rules) == LAST_HEADER_BASED_RULES_LENGTH && *rules[ROLLOUT_ROUTE_RULE_INDEX].BackendRefs[CANARY_BACKEND_REF_INDEX].Weight == targetWeight } - // TODO: It needs more checks if len(rules) != FIRST_HEADER_BASED_RULES_LENGTH { return false } @@ -277,6 +276,6 @@ func getMatchHeaderBasedGRPCRouteFetcher(t *testing.T, targetWeight int32, targe } } -func isHeaderBasedGRPCRouteValuesEqual(first, second v1alpha2.GRPCHeaderMatch) bool { +func isHeaderBasedGRPCRouteValuesEqual(first, second gatewayv1.GRPCHeaderMatch) bool { return first.Name == second.Name && *first.Type == *second.Type && first.Value == second.Value } diff --git a/test/e2e/testdata/first-grpcroute.yml b/test/e2e/testdata/first-grpcroute.yml index b680fdf..9d211c7 100644 --- a/test/e2e/testdata/first-grpcroute.yml +++ b/test/e2e/testdata/first-grpcroute.yml @@ -1,4 +1,4 @@ -apiVersion: gateway.networking.k8s.io/v1alpha2 +apiVersion: gateway.networking.k8s.io/v1 kind: GRPCRoute metadata: name: first-grpcroute