Skip to content

Commit

Permalink
feat: implment BackendRefs in EnvoyProxy (#3080)
Browse files Browse the repository at this point in the history
* implment BackendRef in EnvoyProxy

Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain authored and zhaohuabing committed Apr 11, 2024
1 parent 0cb3299 commit adaa4c8
Show file tree
Hide file tree
Showing 33 changed files with 1,351 additions and 961 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/envoyextensionypolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ type EnvoyExtensionPolicySpec struct {
// TargetRef
TargetRef gwapiv1a2.PolicyTargetReferenceWithSectionName `json:"targetRef"`

// WASM is a list of Wasm extensions to be loaded by the Gateway.
// Wasm is a list of Wasm extensions to be loaded by the Gateway.
// Order matters, as the extensions will be loaded in the order they are
// defined in this list.
//
// +optional
WASM []Wasm `json:"wasm,omitempty"`
Wasm []Wasm `json:"wasm,omitempty"`

// ExtProc is an ordered list of external processing filters
// that should added to the envoy filter chain
Expand Down
31 changes: 0 additions & 31 deletions api/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,6 @@ type RateLimit struct {
type RateLimitTelemetry struct {
// Metrics defines metrics configuration for RateLimit.
Metrics *RateLimitMetrics `json:"metrics,omitempty"`

// Tracing defines traces configuration for RateLimit.
Tracing *RateLimitTracing `json:"tracing,omitempty"`
}

type RateLimitMetrics struct {
Expand All @@ -369,34 +366,6 @@ type RateLimitMetricsPrometheusProvider struct {
Disable bool `json:"disable,omitempty"`
}

type RateLimitTracing struct {
// SamplingRate controls the rate at which traffic will be
// selected for tracing if no prior sampling decision has been made.
// Defaults to 100, valid values [0-100]. 100 indicates 100% sampling.
// +optional
SamplingRate *uint32 `json:"samplingRate,omitempty"`

// Provider defines the rateLimit tracing provider.
// Only OpenTelemetry is supported currently.
Provider *RateLimitTracingProvider `json:"provider,omitempty"`
}

type RateLimitTracingProviderType string

const (
RateLimitTracingProviderTypeOpenTelemetry TracingProviderType = "OpenTelemetry"
)

// RateLimitTracingProvider defines the tracing provider configuration of RateLimit
type RateLimitTracingProvider struct {
// Type defines the tracing provider type.
// Since to RateLimit Exporter currently using OpenTelemetry, only OpenTelemetry is supported
Type *RateLimitTracingProviderType `json:"type,omitempty"`

// URL is the endpoint of the trace collector that supports the OTLP protocol
URL string `json:"url"`
}

// RateLimitDatabaseBackend defines the configuration associated with
// the database backend used by the rate limit service.
// +union
Expand Down
8 changes: 6 additions & 2 deletions api/v1alpha1/wasm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ type WasmCodeSource struct {
Image *ImageWasmCodeSource `json:"image,omitempty"`

// SHA256 checksum that will be used to verify the wasm code.
// +optional
// SHA256 *string `json:"sha256,omitempty"`
//
// kubebuilder:validation:Pattern=`^[a-f0-9]{64}$`
SHA256 string `json:"sha256"`
}

// WasmCodeSourceType specifies the types of sources for the wasm code.
Expand All @@ -92,6 +93,9 @@ const (

// ImageWasmCodeSourceType allows the user to specify the wasm code in an OCI image.
ImageWasmCodeSourceType WasmCodeSourceType = "Image"

// ConfigMapCodeSourceType allows the user to specify the wasm code in a ConfigMap.
ConfigMapWasmCodeSourceType WasmCodeSourceType = "ConfigMap"
)

// HTTPWasmCodeSource defines the HTTP URL containing the wasm code.
Expand Down
54 changes: 2 additions & 52 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ spec:
rule: '!has(self.sectionName)'
wasm:
description: |-
WASM is a list of Wasm extensions to be loaded by the Gateway.
Wasm is a list of Wasm extensions to be loaded by the Gateway.
Order matters, as the extensions will be loaded in the order they are
defined in this list.
items:
Expand Down Expand Up @@ -301,6 +301,13 @@ spec:
- pullSecret
- url
type: object
sha256:
description: |-
SHA256 checksum that will be used to verify the wasm code.
kubebuilder:validation:Pattern=`^[a-f0-9]{64}$`
type: string
type:
allOf:
- enum:
Expand All @@ -314,6 +321,7 @@ spec:
Valid WasmCodeSourceType values are "HTTP" or "Image".
type: string
required:
- sha256
- type
type: object
config:
Expand Down
10 changes: 3 additions & 7 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func translateGatewayAPIToIR(resources *gatewayapi.Resources) (*gatewayapi.Trans
}

t := &gatewayapi.Translator{
GatewayControllerName: string(resources.GatewayClass.Spec.ControllerName),
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
Expand All @@ -303,7 +303,7 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap

// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: string(resources.GatewayClass.Spec.ControllerName),
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
Expand Down Expand Up @@ -335,7 +335,7 @@ func translateGatewayAPIToXds(dnsDomain string, resourceType string, resources *

// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: string(resources.GatewayClass.Spec.ControllerName),
GatewayControllerName: egv1a1.GatewayControllerName,
GatewayClassName: gwapiv1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
Expand Down Expand Up @@ -688,10 +688,6 @@ func kubernetesYAMLToResources(str string, addMissingResources bool) (*gatewayap
},
Spec: typedSpec.(gwapiv1.GatewayClassSpec),
}
// fill controller name by default controller name when gatewayclass controller name empty.
if gatewayClass.Spec.ControllerName == "" {
gatewayClass.Spec.ControllerName = egv1a1.GatewayControllerName
}
resources.GatewayClass = gatewayClass
case gatewayapi.KindGateway:
typedSpec := spec.Interface()
Expand Down
Loading

0 comments on commit adaa4c8

Please sign in to comment.