From 23d4864bc7b7213714bc3692a383d2045635e5eb Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sun, 26 May 2024 21:15:30 -0600 Subject: [PATCH] chore!: upgrade to Gateway API v1.1.0 Signed-off-by: Matthew Penner --- README.md | 6 +++--- go.mod | 32 +++++++++++++++--------------- go.sum | 33 +++++++++++++++++++++++++++++++ internal/caddy/caddy.go | 5 +++-- internal/caddy/http.go | 33 ++++++++++++++++--------------- internal/controller/controller.go | 6 +++--- internal/controller/gateway.go | 17 ++++++++-------- internal/controller/route.go | 2 +- internal/controller/route_grpc.go | 4 ++-- internal/gateway.go | 6 +++--- main.go | 8 +++++--- 11 files changed, 95 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index b0604e6..1c00828 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ for any Route resources and is where your requests will be processed. ## Gateway API Support -Requires Gateway API v1.0.0 CRDs to be installed on your cluster (some experimental CRDs are supported but are optional) +Requires Gateway API v1.1.0 CRDs to be installed on your cluster (some experimental CRDs are supported but are optional) ### Resource Support @@ -73,11 +73,11 @@ We recommend installing all Gateway API CRDs, including those that are experimen ```bash # Install Gateway API CRDs (including those that are experimental) -kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/experimental-install.yaml +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/experimental-install.yaml # Install Gateway API CRDs (only stable resources) # NOTE: **Do not use this command if you already ran the `experimental-install`** -kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml +kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/standard-install.yaml ``` ### Installing the Controller and Caddy diff --git a/go.mod b/go.mod index 72467f6..4530b97 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.22.0 require ( github.com/google/go-cmp v0.6.0 github.com/matthewpi/certwatcher v1.0.0 - github.com/onsi/ginkgo/v2 v2.17.3 + github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 - k8s.io/api v0.30.0 - k8s.io/apimachinery v0.30.0 - k8s.io/client-go v0.30.0 - sigs.k8s.io/controller-runtime v0.18.2 - sigs.k8s.io/gateway-api v1.0.0 + k8s.io/api v0.30.1 + k8s.io/apimachinery v0.30.1 + k8s.io/client-go v0.30.1 + sigs.k8s.io/controller-runtime v0.18.3 + sigs.k8s.io/gateway-api v1.1.0 ) require ( @@ -21,7 +21,7 @@ require ( github.com/emicklei/go-restful/v3 v3.12.0 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect @@ -33,7 +33,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240508145209-1db217f89380 // indirect + github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect github.com/google/uuid v1.6.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -44,18 +44,18 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.19.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.53.0 // indirect - github.com/prometheus/procfs v0.14.0 // indirect + github.com/prometheus/procfs v0.15.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.opentelemetry.io/otel v1.26.0 // indirect - go.opentelemetry.io/otel/metric v1.26.0 // indirect - go.opentelemetry.io/otel/trace v1.26.0 // indirect + go.opentelemetry.io/otel v1.27.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect + go.opentelemetry.io/otel/trace v1.27.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.23.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sys v0.20.0 // indirect @@ -68,9 +68,9 @@ 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/apiextensions-apiserver v0.30.0 // indirect + k8s.io/apiextensions-apiserver v0.30.1 // indirect k8s.io/klog/v2 v2.120.1 // indirect - k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect + k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/go.sum b/go.sum index b7a5433..06d57f7 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 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/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= @@ -27,6 +29,7 @@ github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -45,6 +48,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20240508145209-1db217f89380 h1:DVHL33OE5pGk/5NzcooTFrgFC73NXLf+vApFzs3Vj0E= github.com/google/pprof v0.0.0-20240508145209-1db217f89380/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= @@ -74,6 +79,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.17.3 h1:oJcvKpIb7/8uLpDDtnQuf18xVnwKp8DTD7DQ6gTd/MU= github.com/onsi/ginkgo/v2 v2.17.3/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= +github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= +github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -83,12 +90,16 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= +github.com/prometheus/procfs v0.15.0 h1:A82kmvXJq2jTu5YUhSGNlYoxh85zLnKgPz4bMZgI5Ek= +github.com/prometheus/procfs v0.15.0/go.mod h1:Y0RJ/Y5g5wJpkTisOtqwDSo4HwhGmLB4VQSw2sQJLHk= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -101,10 +112,16 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= +go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= +go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= +go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik= +go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak= go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= +go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw= +go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -118,6 +135,8 @@ golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d h1:N0hmiNbwsSNwHBAvR3QB5w25pUwH4tK0Y/RltD1j1h4= +golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= 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= @@ -170,22 +189,36 @@ 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/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs= k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= +k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= +k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +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/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM= k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f/go.mod h1:S9tOR0FxgyusSNR+MboCuiDpVWkAifZvaYI1Q2ubgro= +k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a h1:zD1uj3Jf+mD4zmA7W+goE5TxDkI7OGJjBNBzq5fJtLA= +k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc= k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak= k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q= sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= +sigs.k8s.io/controller-runtime v0.18.3 h1:B5Wmmo8WMWK7izei+2LlXLVDGzMwAHBNLX68lwtlSR4= +sigs.k8s.io/controller-runtime v0.18.3/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= 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/internal/caddy/caddy.go b/internal/caddy/caddy.go index 47d5d92..7af5e3f 100644 --- a/internal/caddy/caddy.go +++ b/internal/caddy/caddy.go @@ -13,6 +13,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gateway "github.com/caddyserver/gateway/internal" @@ -43,13 +44,13 @@ type Input struct { GatewayClass *gatewayv1.GatewayClass HTTPRoutes []gatewayv1.HTTPRoute - GRPCRoutes []gatewayv1alpha2.GRPCRoute + GRPCRoutes []gatewayv1.GRPCRoute TCPRoutes []gatewayv1alpha2.TCPRoute TLSRoutes []gatewayv1alpha2.TLSRoute UDPRoutes []gatewayv1alpha2.UDPRoute Grants []gatewayv1beta1.ReferenceGrant - BackendTLSPolicies []gatewayv1alpha2.BackendTLSPolicy + BackendTLSPolicies []gatewayv1alpha3.BackendTLSPolicy Services []corev1.Service diff --git a/internal/caddy/http.go b/internal/caddy/http.go index f7cec04..aaf3f0b 100644 --- a/internal/caddy/http.go +++ b/internal/caddy/http.go @@ -16,7 +16,7 @@ import ( corev1 "k8s.io/api/core/v1" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gateway "github.com/caddyserver/gateway/internal" caddy "github.com/caddyserver/gateway/internal/caddyv2" @@ -301,7 +301,7 @@ func (i *Input) getHTTPServer(s *caddyhttp.Server, l gatewayv1.Listener) (*caddy ruleHandlers = append(ruleHandlers, handler) } - if rule.BackendRefs != nil && len(rule.BackendRefs) > 0 { + if len(rule.BackendRefs) > 0 { for _, bf := range rule.BackendRefs { bor := bf.BackendObjectReference if !gateway.IsService(bor) { @@ -336,19 +336,20 @@ func (i *Input) getHTTPServer(s *caddyhttp.Server, l gatewayv1.Listener) (*caddy continue } - var bTLSPolicy gatewayv1alpha2.BackendTLSPolicy + var bTLSPolicy gatewayv1alpha3.BackendTLSPolicy for _, btp := range i.BackendTLSPolicies { - if !gateway.IsPolicyTargetService(btp.Spec.TargetRef.PolicyTargetReference) { - continue - } - - // We are ignoring the namespace target reference and - // only supporting TLS policies in the namespace of the - // service itself. - if btp.Namespace != service.Namespace { - continue + match := false + for _, tf := range btp.Spec.TargetRefs { + if !gateway.IsLocalPolicyTargetService(tf.LocalPolicyTargetReference) { + continue + } + if string(tf.Name) != service.Name { + continue + } + match = true + break } - if string(btp.Spec.TargetRef.Name) != service.Name { + if !match { continue } @@ -363,15 +364,15 @@ func (i *Input) getHTTPServer(s *caddyhttp.Server, l gatewayv1.Listener) (*caddy // if a BackendTLSPolicy with System trust is used. if bTLSPolicy.Name != "" { tls := &reverseproxy.TLSConfig{} - policy := bTLSPolicy.Spec.TLS + policy := bTLSPolicy.Spec.Validation if hostname := string(policy.Hostname); hostname != "" { tls.ServerName = hostname } // Check for any custom CAs to load. - if policy.CACertRefs != nil && len(policy.CACertRefs) > 0 { + if len(policy.CACertificateRefs) > 0 { // Array of base64-encoded DER-encoded CA certificates. var certs []string - for _, ref := range policy.CACertRefs { + for _, ref := range policy.CACertificateRefs { pemCerts, err := i.getCAPool(context.Background(), ref) if err != nil { // TODO: log error and continue? diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 43475f7..c46b227 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -89,9 +89,9 @@ func onlyStatusChanged() predicate.Predicate { return false } return !cmp.Equal(o.Status, n.Status, option) - case *gatewayv1alpha2.GRPCRoute: - o, _ := e.ObjectOld.(*gatewayv1alpha2.GRPCRoute) - n, ok := e.ObjectNew.(*gatewayv1alpha2.GRPCRoute) + case *gatewayv1.GRPCRoute: + o, _ := e.ObjectOld.(*gatewayv1.GRPCRoute) + n, ok := e.ObjectNew.(*gatewayv1.GRPCRoute) if !ok { return false } diff --git a/internal/controller/gateway.go b/internal/controller/gateway.go index 27a7826..f883668 100644 --- a/internal/controller/gateway.go +++ b/internal/controller/gateway.go @@ -35,6 +35,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" gateway "github.com/caddyserver/gateway/internal" @@ -99,7 +100,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { ctrlPredicate, ). Watches( - &gatewayv1alpha2.GRPCRoute{}, + &gatewayv1.GRPCRoute{}, r.enqueueRequestForOwningGRPCRoute(), ). Watches( @@ -122,7 +123,7 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { r.enqueueRequestForOwningUDPRoute(), builder.WithPredicates(onlyStatusChanged()), ). - Watches(&gatewayv1alpha2.BackendTLSPolicy{}, r.enqueueRequestForTLSPolicy()). + Watches(&gatewayv1alpha3.BackendTLSPolicy{}, r.enqueueRequestForTLSPolicy()). Watches( &corev1.Secret{}, r.enqueueRequestForTLSSecret(), @@ -220,7 +221,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct return r.handleReconcileErrorWithStatus(ctx, err, original, gw) } - grpcRouteList := &gatewayv1alpha2.GRPCRouteList{} + grpcRouteList := &gatewayv1.GRPCRouteList{} if err := r.Client.List(ctx, grpcRouteList); err != nil { log.Error(err, "Unable to list GRPCRoutes") return r.handleReconcileErrorWithStatus(ctx, err, original, gw) @@ -250,7 +251,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct return r.handleReconcileErrorWithStatus(ctx, err, original, gw) } - backendTLSPolicyList := &gatewayv1alpha2.BackendTLSPolicyList{} + backendTLSPolicyList := &gatewayv1alpha3.BackendTLSPolicyList{} if err := r.Client.List(ctx, backendTLSPolicyList); err != nil { log.Error(err, "Unable to list BackendTLSPolicies") return r.handleReconcileErrorWithStatus(ctx, err, original, gw) @@ -526,7 +527,7 @@ func (r *GatewayReconciler) enqueueRequestForOwningHTTPRoute() handler.EventHand // belonging to the given Gateway func (r *GatewayReconciler) enqueueRequestForOwningGRPCRoute() handler.EventHandler { return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request { - route, ok := o.(*gatewayv1alpha2.GRPCRoute) + route, ok := o.(*gatewayv1.GRPCRoute) if !ok { return nil } @@ -620,7 +621,7 @@ func getReconcileRequestsForRoute(ctx context.Context, c client.Client, object m // TODO: document func (r *GatewayReconciler) enqueueRequestForTLSPolicy() handler.EventHandler { return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, o client.Object) []reconcile.Request { - _, ok := o.(*gatewayv1alpha2.BackendTLSPolicy) + _, ok := o.(*gatewayv1alpha3.BackendTLSPolicy) if !ok { return nil } @@ -722,8 +723,8 @@ func (r *GatewayReconciler) filterHTTPRoutesByGateway(ctx context.Context, gw *g // filterGRPCRoutesByGateway . // TODO -func (r *GatewayReconciler) filterGRPCRoutesByGateway(ctx context.Context, gw *gatewayv1.Gateway, routes []gatewayv1alpha2.GRPCRoute) []gatewayv1alpha2.GRPCRoute { - var filtered []gatewayv1alpha2.GRPCRoute +func (r *GatewayReconciler) filterGRPCRoutesByGateway(ctx context.Context, gw *gatewayv1.Gateway, routes []gatewayv1.GRPCRoute) []gatewayv1.GRPCRoute { + var filtered []gatewayv1.GRPCRoute for _, route := range routes { if isAttachable(ctx, gw, &route, route.Status.Parents) && isAllowed(ctx, r.Client, gw, &route) && len(computeHosts(gw, route.Spec.Hostnames)) > 0 { filtered = append(filtered, route) diff --git a/internal/controller/route.go b/internal/controller/route.go index 699668e..c038583 100644 --- a/internal/controller/route.go +++ b/internal/controller/route.go @@ -128,7 +128,7 @@ func getGatewayKindForObject(obj metav1.Object) gatewayv1.Kind { switch obj.(type) { case *gatewayv1.HTTPRoute: return "HTTPRoute" - case *gatewayv1alpha2.GRPCRoute: + case *gatewayv1.GRPCRoute: return "GRPCRoute" case *gatewayv1alpha2.TCPRoute: return "TCPRoute" diff --git a/internal/controller/route_grpc.go b/internal/controller/route_grpc.go index 04f2742..1a33f51 100644 --- a/internal/controller/route_grpc.go +++ b/internal/controller/route_grpc.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" - gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ) // +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=grpcroutes,verbs=get;list;watch @@ -30,7 +30,7 @@ var _ reconcile.Reconciler = (*GRPCRouteReconciler)(nil) // SetupWithManager sets up the controller with the Manager. func (r *GRPCRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&gatewayv1alpha2.GRPCRoute{}). + For(&gatewayv1.GRPCRoute{}). Complete(r) } diff --git a/internal/gateway.go b/internal/gateway.go index 05a8b8a..c7a8ea0 100644 --- a/internal/gateway.go +++ b/internal/gateway.go @@ -46,17 +46,17 @@ func IsService(be gatewayv1.BackendObjectReference) bool { } // IsPolicyTargetService checks if the given PolicyTargetReference references a Service resource. -func IsPolicyTargetService(be gatewayv1alpha2.PolicyTargetReference) bool { +func IsLocalPolicyTargetService(be gatewayv1alpha2.LocalPolicyTargetReference) bool { return be.Group == corev1.GroupName && be.Kind == "Service" } // IsLocalConfigMap checks if the given LocalObjectReference references a ConfigMap resource. -func IsLocalConfigMap(be gatewayv1beta1.LocalObjectReference) bool { +func IsLocalConfigMap(be gatewayv1.LocalObjectReference) bool { return be.Group == corev1.GroupName && be.Kind == "ConfigMap" } // IsLocalSecret checks if the given LocalObjectReference references a Secret resource. -func IsLocalSecret(be gatewayv1beta1.LocalObjectReference) bool { +func IsLocalSecret(be gatewayv1.LocalObjectReference) bool { return be.Group == corev1.GroupName && be.Kind == "Secret" } diff --git a/main.go b/main.go index 3d10e8e..bfb7234 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" + gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "k8s.io/apimachinery/pkg/runtime" @@ -37,9 +38,10 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(gatewayv1.AddToScheme(scheme)) - utilruntime.Must(gatewayv1alpha2.AddToScheme(scheme)) - utilruntime.Must(gatewayv1beta1.AddToScheme(scheme)) + utilruntime.Must(gatewayv1.Install(scheme)) + utilruntime.Must(gatewayv1alpha2.Install(scheme)) + utilruntime.Must(gatewayv1alpha3.Install(scheme)) + utilruntime.Must(gatewayv1beta1.Install(scheme)) //+kubebuilder:scaffold:scheme }