Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade gateway api to v1.0.0 #1129

Merged
merged 5 commits into from Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/04.Cloud-Native/4.2.Gateway-API.md
Expand Up @@ -239,12 +239,12 @@ spec:

### Deploy Gateway API Objects

Please refer https://gateway-api.sigs.k8s.io/ for the detailed information
Please refer [Kubernetes Gateway API](https://gateway-api.sigs.k8s.io/) for the detailed information
of Gateway Class, Gateway and HTTPRoute configuration. Up to now, the Easegress
GatewayController only support HTTP & HTTPS listeners.

```yaml
apiVersion: gateway.networking.k8s.io/v1beta1
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: example-gateway-class
Expand All @@ -253,7 +253,7 @@ spec:

---

apiVersion: gateway.networking.k8s.io/v1beta1
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: example-gateway
Expand All @@ -266,7 +266,7 @@ spec:

---

apiVersion: gateway.networking.k8s.io/v1beta1
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-route
Expand All @@ -285,7 +285,7 @@ spec:

---

apiVersion: gateway.networking.k8s.io/v1beta1
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: example-route-2
Expand Down
291 changes: 148 additions & 143 deletions go.mod

Large diffs are not rendered by default.

677 changes: 331 additions & 346 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pkg/cluster/config.go
Expand Up @@ -84,10 +84,10 @@ func CreateStaticClusterEtcdConfig(opt *option.Options) (*embed.Config, error) {
ec.WalDir = opt.AbsWALDir
ec.InitialClusterToken = opt.ClusterName
ec.EnableV2 = false
ec.LCUrls = clientURLs
ec.ACUrls = clientAdURLs
ec.LPUrls = peerURLs
ec.APUrls = peerAdURLs
ec.ListenClientUrls = clientURLs
ec.AdvertiseClientUrls = clientAdURLs
ec.ListenPeerUrls = peerURLs
ec.AdvertisePeerUrls = peerAdURLs
ec.AutoCompactionMode = autoCompactionMode
ec.AutoCompactionRetention = autoCompactionRetention
ec.QuotaBackendBytes = quotaBackendBytes
Expand All @@ -108,7 +108,7 @@ func CreateStaticClusterEtcdConfig(opt *option.Options) (*embed.Config, error) {
ec.InitialCluster = opt.InitialClusterToString()

logger.Infof("etcd config: advertise-client-urls: %+v advertise-peer-urls: %+v init-cluster: %s cluster-state: %s force-new-cluster: %v",
ec.ACUrls, ec.APUrls,
ec.AdvertiseClientUrls, ec.AdvertisePeerUrls,
ec.InitialCluster, ec.ClusterState, ec.ForceNewCluster)

return ec, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/filters/redirectorv2/redirectorv2.go
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/megaease/easegress/v2/pkg/filters"
"github.com/megaease/easegress/v2/pkg/protocols/httpprot"

gwapis "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapis "sigs.k8s.io/gateway-api/apis/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/filters/redirectorv2/redirectorv2_test.go
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/megaease/easegress/v2/pkg/protocols/httpprot"
"github.com/stretchr/testify/assert"

gwapis "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapis "sigs.k8s.io/gateway-api/apis/v1"
)

func TestSpecValidate(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions pkg/object/gatewaycontroller/k8s.go
Expand Up @@ -38,10 +38,10 @@ import (
kinformers "k8s.io/client-go/informers"
kclientset "k8s.io/client-go/kubernetes"

gwapis "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapis "sigs.k8s.io/gateway-api/apis/v1"
gwclientset "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"
gwinformers "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions"
gwinformerapis "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1beta1"
gwinformerapis "sigs.k8s.io/gateway-api/pkg/client/informers/externalversions/apis/v1"
)

const (
Expand Down Expand Up @@ -289,7 +289,7 @@ func (c *k8sClient) watch(namespaces []string) (chan struct{}, error) {
func (c *k8sClient) GetHTTPRoutes() []*gwapis.HTTPRoute {
var results []*gwapis.HTTPRoute

lister := c.gwFactory.Gateway().V1beta1().HTTPRoutes().Lister()
lister := c.gwFactory.Gateway().V1().HTTPRoutes().Lister()
for _, ns := range c.namespaces {
if !c.isNamespaceWatched(ns) {
logger.Warnf("failed to get HTTPRoutes: %q is not within watched namespaces", ns)
Expand All @@ -316,7 +316,7 @@ func (c *k8sClient) GetHTTPRoutes() []*gwapis.HTTPRoute {
func (c *k8sClient) GetGateways() []*gwapis.Gateway {
var result []*gwapis.Gateway

lister := c.gwFactory.Gateway().V1beta1().Gateways().Lister()
lister := c.gwFactory.Gateway().V1().Gateways().Lister()
for _, ns := range c.namespaces {
gateways, err := lister.Gateways(ns).List(labels.Everything())
if err != nil {
Expand All @@ -331,7 +331,7 @@ func (c *k8sClient) GetGateways() []*gwapis.Gateway {
}

func (c *k8sClient) GetGatewayClasses(controllerName string) []*gwapis.GatewayClass {
classes, err := c.gwFactory.Gateway().V1beta1().GatewayClasses().Lister().List(labels.Everything())
classes, err := c.gwFactory.Gateway().V1().GatewayClasses().Lister().List(labels.Everything())
if err != nil {
logger.Errorf("Failed to list GatewayClasses: %v", err)
return nil
Expand Down Expand Up @@ -370,7 +370,7 @@ func (c *k8sClient) UpdateGatewayClassStatus(gatewayClass *gwapis.GatewayClass,
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

_, err := c.gwcs.GatewayV1beta1().GatewayClasses().UpdateStatus(ctx, gc, metav1.UpdateOptions{})
_, err := c.gwcs.GatewayV1().GatewayClasses().UpdateStatus(ctx, gc, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("failed to update GatewayClass %q status: %w", gatewayClass.Name, err)
}
Expand Down Expand Up @@ -446,7 +446,7 @@ func (c *k8sClient) UpdateGatewayStatus(gateway *gwapis.Gateway, status gwapis.G
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

_, err := c.gwcs.GatewayV1beta1().Gateways(gateway.Namespace).UpdateStatus(ctx, g, metav1.UpdateOptions{})
_, err := c.gwcs.GatewayV1().Gateways(gateway.Namespace).UpdateStatus(ctx, g, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("failed to update Gateway %q status: %w", gateway.Name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/object/gatewaycontroller/translator.go
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/megaease/easegress/v2/pkg/util/pathadaptor"
"golang.org/x/exp/slices"
apicorev1 "k8s.io/api/core/v1"
gwapis "sigs.k8s.io/gateway-api/apis/v1beta1"
gwapis "sigs.k8s.io/gateway-api/apis/v1"
)

// specTranslator translates k8s gateway related specs to Easegress
Expand Down
10 changes: 5 additions & 5 deletions pkg/object/nacosserviceregistry/nacosserviceregistry.go
Expand Up @@ -31,11 +31,11 @@ import (
"github.com/megaease/easegress/v2/pkg/supervisor"
"github.com/megaease/easegress/v2/pkg/v"

"github.com/nacos-group/nacos-sdk-go/clients"
"github.com/nacos-group/nacos-sdk-go/clients/naming_client"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/model"
"github.com/nacos-group/nacos-sdk-go/vo"
"github.com/nacos-group/nacos-sdk-go/v2/clients"
"github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client"
"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
"github.com/nacos-group/nacos-sdk-go/v2/model"
"github.com/nacos-group/nacos-sdk-go/v2/vo"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/tracing/tracing.go
Expand Up @@ -36,7 +36,7 @@ import (
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
"go.opentelemetry.io/otel/trace"
)

Expand Down