Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions api/config/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ type EnvoyGatewaySpec struct {
// +optional
RateLimit *RateLimit `json:"rateLimit,omitempty"`

// Extension defines an extension to register for the Envoy Gateway Control Plane.
// ExtensionManager defines an extension manager to register for the Envoy Gateway Control Plane.
//
// +optional
Extension *Extension `json:"extension,omitempty"`
ExtensionManager *ExtensionManager `json:"extensionManager,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm even though this is a breaking change for Envoy Gateway extensions. If possible we should draw extra attention to this in the release notes with a ⚠️ emoji or something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do, adding the release notes label to ensure we handle ^


// ExtensionAPIs defines the settings related to specific Gateway API Extensions
// implemented by Envoy Gateway
//
// +optional
ExtensionAPIs *ExtensionAPISettings `json:"extensionApis,omitempty"`
}

// EnvoyGatewayLogging defines logging for Envoy Gateway.
Expand Down Expand Up @@ -122,6 +128,13 @@ type Gateway struct {
ControllerName string `json:"controllerName,omitempty"`
}

// ExtensionAPISettings defines the settings specific to Gateway API Extensions.
type ExtensionAPISettings struct {
// EnableEnvoyPatchPolicy enables Envoy Gateway to
// reconcile and implement the EnvoyPatchPolicy resources.
EnableEnvoyPatchPolicy bool `json:"enableEnvoyPatchPolicy"`
}

// EnvoyGatewayProvider defines the desired configuration of a provider.
// +union
type EnvoyGatewayProvider struct {
Expand Down Expand Up @@ -304,9 +317,9 @@ type RateLimitRedisSettings struct {
TLS *RedisTLSSettings `json:"tls,omitempty"`
}

// Extension defines the configuration for registering an extension to
// ExtensionManager defines the configuration for registering an extension manager to
// the Envoy Gateway control plane.
type Extension struct {
type ExtensionManager struct {
// Resources defines the set of K8s resources the extension will handle.
//
// +optional
Expand Down
64 changes: 42 additions & 22 deletions api/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 27 additions & 10 deletions docs/latest/api/config_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ EnvoyGateway is the schema for the envoygateways API.
| `logging` _[EnvoyGatewayLogging](#envoygatewaylogging)_ | Logging defines logging parameters for Envoy Gateway. |
| `admin` _[EnvoyGatewayAdmin](#envoygatewayadmin)_ | Admin defines the desired admin related abilities. If unspecified, the Admin is used with default configuration parameters. |
| `rateLimit` _[RateLimit](#ratelimit)_ | RateLimit defines the configuration associated with the Rate Limit service deployed by Envoy Gateway required to implement the Global Rate limiting functionality. The specific rate limit service used here is the reference implementation in Envoy. For more details visit https://github.com/envoyproxy/ratelimit. This configuration is unneeded for "Local" rate limiting. |
| `extension` _[Extension](#extension)_ | Extension defines an extension to register for the Envoy Gateway Control Plane. |
| `extensionManager` _[ExtensionManager](#extensionmanager)_ | ExtensionManager defines an extension manager to register for the Envoy Gateway Control Plane. |
| `extensionApis` _[ExtensionAPISettings](#extensionapisettings)_ | ExtensionAPIs defines the settings related to specific Gateway API Extensions implemented by Envoy Gateway |


## EnvoyGatewayAdmin
Expand Down Expand Up @@ -255,7 +256,8 @@ _Appears in:_
| `logging` _[EnvoyGatewayLogging](#envoygatewaylogging)_ | Logging defines logging parameters for Envoy Gateway. |
| `admin` _[EnvoyGatewayAdmin](#envoygatewayadmin)_ | Admin defines the desired admin related abilities. If unspecified, the Admin is used with default configuration parameters. |
| `rateLimit` _[RateLimit](#ratelimit)_ | RateLimit defines the configuration associated with the Rate Limit service deployed by Envoy Gateway required to implement the Global Rate limiting functionality. The specific rate limit service used here is the reference implementation in Envoy. For more details visit https://github.com/envoyproxy/ratelimit. This configuration is unneeded for "Local" rate limiting. |
| `extension` _[Extension](#extension)_ | Extension defines an extension to register for the Envoy Gateway Control Plane. |
| `extensionManager` _[ExtensionManager](#extensionmanager)_ | ExtensionManager defines an extension manager to register for the Envoy Gateway Control Plane. |
| `extensionApis` _[ExtensionAPISettings](#extensionapisettings)_ | ExtensionAPIs defines the settings related to specific Gateway API Extensions implemented by Envoy Gateway |


## EnvoyProxy
Expand Down Expand Up @@ -323,21 +325,19 @@ _Appears in:_



## Extension
## ExtensionAPISettings



Extension defines the configuration for registering an extension to the Envoy Gateway control plane.
ExtensionAPISettings defines the settings specific to Gateway API Extensions.

_Appears in:_
- [EnvoyGateway](#envoygateway)
- [EnvoyGatewaySpec](#envoygatewayspec)

| Field | Description |
| --- | --- |
| `resources` _[GroupVersionKind](#groupversionkind) array_ | Resources defines the set of K8s resources the extension will handle. |
| `hooks` _[ExtensionHooks](#extensionhooks)_ | Hooks defines the set of hooks the extension supports |
| `service` _[ExtensionService](#extensionservice)_ | Service defines the configuration of the extension service that the Envoy Gateway Control Plane will call through extension hooks. |
| `enableEnvoyPatchPolicy` _boolean_ | EnableEnvoyPatchPolicy enables Envoy Gateway to reconcile and implement the EnvoyPatchPolicy resources. |


## ExtensionHooks
Expand All @@ -347,21 +347,38 @@ _Appears in:_
ExtensionHooks defines extension hooks across all supported runners

_Appears in:_
- [Extension](#extension)
- [ExtensionManager](#extensionmanager)

| Field | Description |
| --- | --- |
| `xdsTranslator` _[XDSTranslatorHooks](#xdstranslatorhooks)_ | XDSTranslator defines all the supported extension hooks for the xds-translator runner |


## ExtensionManager



ExtensionManager defines the configuration for registering an extension manager to the Envoy Gateway control plane.

_Appears in:_
- [EnvoyGateway](#envoygateway)
- [EnvoyGatewaySpec](#envoygatewayspec)

| Field | Description |
| --- | --- |
| `resources` _[GroupVersionKind](#groupversionkind) array_ | Resources defines the set of K8s resources the extension will handle. |
| `hooks` _[ExtensionHooks](#extensionhooks)_ | Hooks defines the set of hooks the extension supports |
| `service` _[ExtensionService](#extensionservice)_ | Service defines the configuration of the extension service that the Envoy Gateway Control Plane will call through extension hooks. |


## ExtensionService



ExtensionService defines the configuration for connecting to a registered extension service.

_Appears in:_
- [Extension](#extension)
- [ExtensionManager](#extensionmanager)

| Field | Description |
| --- | --- |
Expand Down Expand Up @@ -421,7 +438,7 @@ _Appears in:_
GroupVersionKind unambiguously identifies a Kind. It can be converted to k8s.io/apimachinery/pkg/runtime/schema.GroupVersionKind

_Appears in:_
- [Extension](#extension)
- [ExtensionManager](#extensionmanager)

| Field | Description |
| --- | --- |
Expand Down
12 changes: 6 additions & 6 deletions internal/envoygateway/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,21 @@ func (s *Server) Validate() error {
if _, err := url.Parse(s.EnvoyGateway.RateLimit.Backend.Redis.URL); err != nil {
return fmt.Errorf("unknown ratelimit redis url format: %w", err)
}
case s.EnvoyGateway.Extension != nil:
if s.EnvoyGateway.Extension.Hooks == nil || s.EnvoyGateway.Extension.Hooks.XDSTranslator == nil {
case s.EnvoyGateway.ExtensionManager != nil:
if s.EnvoyGateway.ExtensionManager.Hooks == nil || s.EnvoyGateway.ExtensionManager.Hooks.XDSTranslator == nil {
return fmt.Errorf("registered extension has no hooks specified")
}

if len(s.EnvoyGateway.Extension.Hooks.XDSTranslator.Pre) == 0 && len(s.EnvoyGateway.Extension.Hooks.XDSTranslator.Post) == 0 {
if len(s.EnvoyGateway.ExtensionManager.Hooks.XDSTranslator.Pre) == 0 && len(s.EnvoyGateway.ExtensionManager.Hooks.XDSTranslator.Post) == 0 {
return fmt.Errorf("registered extension has no hooks specified")
}

if s.EnvoyGateway.Extension.Service == nil {
if s.EnvoyGateway.ExtensionManager.Service == nil {
return fmt.Errorf("extension service config is empty")
}

if s.EnvoyGateway.Extension.Service.TLS != nil {
certificateRefKind := s.EnvoyGateway.Extension.Service.TLS.CertificateRef.Kind
if s.EnvoyGateway.ExtensionManager.Service.TLS != nil {
certificateRefKind := s.EnvoyGateway.ExtensionManager.Service.TLS.CertificateRef.Kind

if certificateRefKind == nil {
return fmt.Errorf("certificateRef empty in extension service server TLS settings")
Expand Down
12 changes: 6 additions & 6 deletions internal/envoygateway/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Resources: []v1alpha1.GroupVersionKind{
{
Group: "foo.example.io",
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Resources: []v1alpha1.GroupVersionKind{
{
Group: "foo.example.io",
Expand Down Expand Up @@ -267,7 +267,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Hooks: &v1alpha1.ExtensionHooks{
XDSTranslator: &v1alpha1.XDSTranslatorHooks{
Pre: []v1alpha1.XDSTranslatorHook{},
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Resources: []v1alpha1.GroupVersionKind{
{
Group: "foo.example.io",
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Resources: []v1alpha1.GroupVersionKind{
{
Group: "foo.example.io",
Expand Down Expand Up @@ -379,7 +379,7 @@ func TestValidate(t *testing.T) {
EnvoyGatewaySpec: v1alpha1.EnvoyGatewaySpec{
Gateway: v1alpha1.DefaultGateway(),
Provider: v1alpha1.DefaultEnvoyGatewayProvider(),
Extension: &v1alpha1.Extension{
ExtensionManager: &v1alpha1.ExtensionManager{
Resources: []v1alpha1.GroupVersionKind{
{
Group: "foo.example.io",
Expand Down
10 changes: 5 additions & 5 deletions internal/extension/registry/extension_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ extTypes.Manager = (*Manager)(nil)
type Manager struct {
k8sClient k8scli.Client
namespace string
extension v1alpha1.Extension
extension v1alpha1.ExtensionManager
extensionConnCache *grpc.ClientConn
}

Expand All @@ -57,14 +57,14 @@ func NewManager(cfg *config.Server) (extTypes.Manager, error) {
return nil, err
}

var extension *v1alpha1.Extension
var extension *v1alpha1.ExtensionManager
if cfg.EnvoyGateway != nil {
extension = cfg.EnvoyGateway.Extension
extension = cfg.EnvoyGateway.ExtensionManager
}

// Setup an empty default in the case that no config was provided
if extension == nil {
extension = &v1alpha1.Extension{}
extension = &v1alpha1.ExtensionManager{}
}

return &Manager{
Expand Down Expand Up @@ -203,7 +203,7 @@ func parseCA(caSecret *corev1.Secret) (*x509.CertPool, error) {
return cp, nil
}

func setupGRPCOpts(ctx context.Context, client k8scli.Client, ext *v1alpha1.Extension, namespace string) ([]grpc.DialOption, error) {
func setupGRPCOpts(ctx context.Context, client k8scli.Client, ext *v1alpha1.ExtensionManager, namespace string) ([]grpc.DialOption, error) {
// These two errors shouldn't happen since we check these conditions when loading the extension
if ext == nil {
return nil, errors.New("the registered extension's config is nil")
Expand Down
4 changes: 2 additions & 2 deletions internal/extension/testutils/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
var _ extType.Manager = (*Manager)(nil)

type Manager struct {
extension v1alpha1.Extension
extension v1alpha1.ExtensionManager
}

func NewManager(ext v1alpha1.Extension) extType.Manager {
func NewManager(ext v1alpha1.ExtensionManager) extType.Manager {
return &Manager{
extension: ext,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/gatewayapi/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) {
}

// If an extension is loaded, pass its supported groups/kinds to the translator
if r.EnvoyGateway.Extension != nil {
if r.EnvoyGateway.ExtensionManager != nil {
var extGKs []schema.GroupKind
for _, gvk := range r.EnvoyGateway.Extension.Resources {
for _, gvk := range r.EnvoyGateway.ExtensionManager.Resources {
extGKs = append(extGKs, schema.GroupKind{Group: gvk.Group, Kind: gvk.Kind})
}
t.ExtensionGroupKinds = extGKs
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestRunner(t *testing.T) {
ProviderResources: pResources,
XdsIR: xdsIR,
InfraIR: infraIR,
ExtensionManager: testutils.NewManager(egv1a1cfg.Extension{}),
ExtensionManager: testutils.NewManager(egv1a1cfg.ExtensionManager{}),
})
ctx := context.Background()
// Start
Expand Down
Loading