Skip to content

Commit

Permalink
feat: add controllers and webhooks
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Yang <[email protected]>
  • Loading branch information
reaver-flomesh committed Jan 13, 2025
1 parent 9228f2e commit 1501bd8
Show file tree
Hide file tree
Showing 29 changed files with 868 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ spec:
throttleHost:
description: ThrottleHosts is the list of hosts to be throttled
items:
description: HostPort is a host name with optional port number
maxLength: 253
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[0-9]{1,5})?$
type: string
maxItems: 32
minItems: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ spec:
is POST
enum:
- GET
- HEAD
- POST
- PUT
- DELETE
- PATCH
- HEAD
- CONNECT
- OPTIONS
- TRACE
- PATCH
type: string
target:
description: Target is the URL of the HTTPLog service
Expand Down
44 changes: 44 additions & 0 deletions pkg/announcements/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,50 @@ const (

// GatewayProxyTagUpdated is the type of announcement emitted when we observe an update to proxytags.extension.gateway.flomesh.io
GatewayProxyTagUpdated Kind = "gatewayproxytag-updated"

// ---

// GatewayIPRestrictionAdded is the type of announcement emitted when we observe an addition of iprestrictions.extension.gateway.flomesh.io
GatewayIPRestrictionAdded Kind = "gatewayiprestriction-added"

// GatewayIPRestrictionDeleted the type of announcement emitted when we observe a deletion of iprestrictions.extension.gateway.flomesh.io
GatewayIPRestrictionDeleted Kind = "gatewayiprestriction-deleted"

// GatewayIPRestrictionUpdated is the type of announcement emitted when we observe an update to iprestrictions.extension.gateway.flomesh.io
GatewayIPRestrictionUpdated Kind = "gatewayiprestriction-updated"

// ---

// GatewayConcurrencyLimitAdded is the type of announcement emitted when we observe an addition of concurrencylimits.extension.gateway.flomesh.io
GatewayConcurrencyLimitAdded Kind = "gatewayconcurrencylimit-added"

// GatewayConcurrencyLimitDeleted the type of announcement emitted when we observe a deletion of concurrencylimits.extension.gateway.flomesh.io
GatewayConcurrencyLimitDeleted Kind = "gatewayconcurrencylimit-deleted"

// GatewayConcurrencyLimitUpdated is the type of announcement emitted when we observe an update to concurrencylimits.extension.gateway.flomesh.io
GatewayConcurrencyLimitUpdated Kind = "gatewayconcurrencylimit-updated"

// ---

// GatewayExternalRateLimitAdded is the type of announcement emitted when we observe an addition of externalratelimits.extension.gateway.flomesh.io
GatewayExternalRateLimitAdded Kind = "gatewayexternalratelimit-added"

// GatewayExternalRateLimitDeleted the type of announcement emitted when we observe a deletion of externalratelimits.extension.gateway.flomesh.io
GatewayExternalRateLimitDeleted Kind = "gatewayexternalratelimit-deleted"

// GatewayExternalRateLimitUpdated is the type of announcement emitted when we observe an update to externalratelimits.extension.gateway.flomesh.io
GatewayExternalRateLimitUpdated Kind = "gatewayexternalratelimit-updated"

// ---

// GatewayRequestTerminationAdded is the type of announcement emitted when we observe an addition of requestterminations.extension.gateway.flomesh.io
GatewayRequestTerminationAdded Kind = "gatewayrequesttermination-added"

// GatewayRequestTerminationDeleted the type of announcement emitted when we observe a deletion of requestterminations.extension.gateway.flomesh.io
GatewayRequestTerminationDeleted Kind = "gatewayrequesttermination-deleted"

// GatewayRequestTerminationUpdated is the type of announcement emitted when we observe an update to requestterminations.extension.gateway.flomesh.io
GatewayRequestTerminationUpdated Kind = "gatewayrequesttermination-updated"
)

// Announcement is a struct for messages between various components of FSM signaling a need for a change in Sidecar proxy configuration
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/extension/v1alpha1/circuitbreaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// CircuitBreakerSpec defines the desired state of CircuitBreaker
Expand Down Expand Up @@ -63,7 +64,7 @@ type CircuitBreakerResponse struct {

// +optional
// Headers is the HTTP headers of response
Headers map[string]string `json:"headers,omitempty"`
Headers map[gwv1.HeaderName]string `json:"headers,omitempty"`

// +optional
// +kubebuilder:default="Circuit breaker triggered"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/extension/v1alpha1/externalratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ExternalRateLimitSpec struct {
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=32
// ThrottleHosts is the list of hosts to be throttled
ThrottleHosts []string `json:"throttleHost,omitempty"`
ThrottleHosts []HostPort `json:"throttleHost,omitempty"`

// +optional
// +listType=set
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/extension/v1alpha1/faultinjection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// FaultInjectionSpec defines the desired state of FaultInjection
Expand Down Expand Up @@ -61,7 +62,7 @@ type FaultInjectionResponse struct {

// +optional
// Headers is the HTTP headers of response
Headers map[string]string `json:"headers,omitempty"`
Headers map[gwv1.HeaderName]string `json:"headers,omitempty"`

// +optional
// +kubebuilder:default="Fault injection triggered"
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/extension/v1alpha1/httplog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// HTTPLogSpec defines the desired state of HTTPLog
Expand All @@ -12,13 +13,12 @@ type HTTPLogSpec struct {

// +optional
// +kubebuilder:default="POST"
// +kubebuilder:validation:Enum=GET;POST;PUT;DELETE;PATCH;HEAD;OPTIONS
// Method is the HTTP method of the HTTPLog service, default is POST
Method *string `json:"method,omitempty"`
Method *gwv1.HTTPMethod `json:"method,omitempty"`

// +optional
// Headers is the HTTP headers of the log request
Headers map[string]string `json:"headers,omitempty"`
Headers map[gwv1.HeaderName]string `json:"headers,omitempty"`

// +optional
// +kubebuilder:default=1048576
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/extension/v1alpha1/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// RateLimitSpec defines the desired state of RateLimit
Expand Down Expand Up @@ -53,7 +54,7 @@ type RateLimitResponse struct {

// +optional
// Headers is the HTTP headers of response
Headers map[string]string `json:"headers,omitempty"`
Headers map[gwv1.HeaderName]string `json:"headers,omitempty"`

// +optional
// +kubebuilder:default="Rate limit reached"
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/extension/v1alpha1/requesttermination.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
)

// RequestTerminationSpec defines the desired state of RequestTermination
Expand All @@ -19,7 +20,7 @@ type RequestTerminationResponse struct {

// +optional
// Headers is the HTTP headers of response
Headers map[string]string `json:"headers,omitempty"`
Headers map[gwv1.HeaderName]string `json:"headers,omitempty"`

// +optional
// +kubebuilder:default="Request termination triggered"
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/extension/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ const (
// FilterAspectRoute is the aspect of filter for route
FilterAspectRoute FilterAspect = "Route"
)

// HostPort is a host name with optional port number
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*(:[0-9]{1,5})?$`
type HostPort string
Loading

0 comments on commit 1501bd8

Please sign in to comment.