Skip to content

Commit

Permalink
Merge branch 'main' into consistent-hash-table-size-api
Browse files Browse the repository at this point in the history
Signed-off-by: Dingkang Li <dingkang1743@gmail.com>
  • Loading branch information
aoledk committed May 9, 2024
2 parents 78f31d0 + 7c9dfc5 commit 621e1c4
Showing 218 changed files with 674 additions and 420 deletions.
1 change: 0 additions & 1 deletion api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
@@ -116,7 +116,6 @@ type EnvoyProxySpec struct {
// - envoy.filters.http.router
//
// +optional
// +notImplementedHide
FilterOrder []FilterPosition `json:"filterOrder,omitempty"`
// BackendTLS is the TLS configuration for the Envoy proxy to use when connecting to backends.
// These settings are applied on backends for which TLS policies are specified.
27 changes: 24 additions & 3 deletions api/v1alpha1/loadbalancer_types.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ type LoadBalancer struct {
// "ConsistentHash",
// "LeastRequest",
// "Random",
// "RoundRobin",
// "RoundRobin".
//
// +unionDiscriminator
Type LoadBalancerType `json:"type"`
@@ -52,10 +52,22 @@ const (
)

// ConsistentHash defines the configuration related to the consistent hash
// load balancer policy
// load balancer policy.
// +union
//
// +kubebuilder:validation:XValidation:rule="self.type == 'Header' ? has(self.header) : !has(self.header)",message="If consistent hash type is header, the header field must be set."
type ConsistentHash struct {
// Valid Type values are "SourceIP".
//
// +unionDiscriminator
Type ConsistentHashType `json:"type"`

// Header configures the header hash policy when the consistent hash type is set to Header.
//
// +optional
// +notImplementedHide
Header *Header `json:"header,omitempty"`

// The table size for consistent hashing, must be prime number limited to 5000011.
//
// +kubebuilder:validation:Minimum=2
@@ -65,13 +77,22 @@ type ConsistentHash struct {
TableSize *uint64 `json:"tableSize,omitempty"`
}

// Header defines the header hashing configuration for consistent hash based
// load balancing.
type Header struct {
// Name of the header to hash.
Name string `json:"name"`
}

// ConsistentHashType defines the type of input to hash on.
// +kubebuilder:validation:Enum=SourceIP
// +kubebuilder:validation:Enum=SourceIP;Header
type ConsistentHashType string

const (
// SourceIPConsistentHashType hashes based on the source IP address.
SourceIPConsistentHashType ConsistentHashType = "SourceIP"
// HeaderConsistentHashType hashes based on a request header.
HeaderConsistentHashType ConsistentHashType = "Header"
)

// SlowStart defines the configuration related to the slow start load balancer policy.
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

20 changes: 10 additions & 10 deletions charts/gateway-helm/crds/gatewayapi-crds.yaml
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: backendlbpolicies.gateway.networking.k8s.io
@@ -581,7 +581,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
labels:
@@ -1185,7 +1185,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: gatewayclasses.gateway.networking.k8s.io
@@ -1737,7 +1737,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: gateways.gateway.networking.k8s.io
@@ -4223,7 +4223,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: grpcroutes.gateway.networking.k8s.io
@@ -8909,7 +8909,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: httproutes.gateway.networking.k8s.io
@@ -15389,7 +15389,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: referencegrants.gateway.networking.k8s.io
@@ -15776,7 +15776,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: tcproutes.gateway.networking.k8s.io
@@ -16601,7 +16601,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: tlsroutes.gateway.networking.k8s.io
@@ -17499,7 +17499,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/2997
gateway.networking.k8s.io/bundle-version: v1.1.0-rc2
gateway.networking.k8s.io/bundle-version: v1.1.0
gateway.networking.k8s.io/channel: experimental
creationTimestamp: null
name: udproutes.gateway.networking.k8s.io
Original file line number Diff line number Diff line change
@@ -412,6 +412,16 @@ spec:
ConsistentHash defines the configuration when the load balancer type is
set to ConsistentHash
properties:
header:
description: Header configures the header hash policy when
the consistent hash type is set to Header.
properties:
name:
description: Name of the header to hash.
type: string
required:
- name
type: object
tableSize:
default: 65537
description: The table size for consistent hashing, must be
@@ -421,14 +431,18 @@ spec:
minimum: 2
type: integer
type:
description: ConsistentHashType defines the type of input
to hash on.
description: Valid Type values are "SourceIP".
enum:
- SourceIP
- Header
type: string
required:
- type
type: object
x-kubernetes-validations:
- message: If consistent hash type is header, the header field
must be set.
rule: 'self.type == ''Header'' ? has(self.header) : !has(self.header)'
slowStart:
description: |-
SlowStart defines the configuration related to the slow start load balancer policy.
@@ -452,7 +466,7 @@ spec:
"ConsistentHash",
"LeastRequest",
"Random",
"RoundRobin",
"RoundRobin".
enum:
- ConsistentHash
- LeastRequest
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ require (
k8s.io/kubectl v0.30.0
k8s.io/utils v0.0.0-20240423183400-0849a56e8f22
sigs.k8s.io/controller-runtime v0.18.1
sigs.k8s.io/gateway-api v1.1.0-rc2
sigs.k8s.io/gateway-api v1.1.0
sigs.k8s.io/mcs-api v0.1.0
sigs.k8s.io/yaml v1.4.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -980,8 +980,8 @@ sigs.k8s.io/controller-runtime v0.6.1/go.mod h1:XRYBPdbf5XJu9kpS84VJiZ7h/u1hF3gE
sigs.k8s.io/controller-runtime v0.18.1 h1:RpWbigmuiylbxOCLy0tGnq1cU1qWPwNIQzoJk+QeJx4=
sigs.k8s.io/controller-runtime v0.18.1/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw=
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
sigs.k8s.io/gateway-api v1.1.0-rc2 h1:uMHSylqzNHYD4kgp6OCDZv9o7ukzgtjuI6G6/e+TSUo=
sigs.k8s.io/gateway-api v1.1.0-rc2/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
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/kind v0.8.1/go.mod h1:oNKTxUVPYkV9lWzY6CVMNluVq8cBsyq+UgPJdvA3uu4=
Original file line number Diff line number Diff line change
@@ -322,7 +322,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
@@ -362,7 +361,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Original file line number Diff line number Diff line change
@@ -70,7 +70,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Original file line number Diff line number Diff line change
@@ -115,8 +115,7 @@
"port": 3000,
"weight": 1
}
],
"sessionPersistence": null
]
}
]
},
Original file line number Diff line number Diff line change
@@ -202,7 +202,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
@@ -242,7 +241,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Original file line number Diff line number Diff line change
@@ -56,7 +56,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Original file line number Diff line number Diff line change
@@ -63,7 +63,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Original file line number Diff line number Diff line change
@@ -195,7 +195,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
@@ -235,7 +234,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
31 changes: 2 additions & 29 deletions internal/cmd/egctl/utils.go
Original file line number Diff line number Diff line change
@@ -10,14 +10,10 @@ import (

adminv3 "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
"google.golang.org/protobuf/reflect/protoreflect"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gwv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/envoyproxy/gateway/internal/envoygateway"
)

type envoyConfigType string
@@ -73,31 +69,8 @@ func findXDSResourceFromConfigDump(resourceType envoyConfigType, globalConfigs *
return nil, fmt.Errorf("unknown resourceType %s", resourceType)
}

// newGatewayScheme creates scheme for K8s Gateway API and Envoy Gateway.
func newGatewayScheme() (*runtime.Scheme, error) {
scheme := runtime.NewScheme()

if err := gwv1.AddToScheme(scheme); err != nil {
return nil, err
}
if err := gwv1b1.AddToScheme(scheme); err != nil {
return nil, err
}
if err := gwv1a2.AddToScheme(scheme); err != nil {
return nil, err
}
if err := egv1a1.AddToScheme(scheme); err != nil {
return nil, err
}

return scheme, nil
}

func newK8sClient() (client.Client, error) {
scheme, err := newGatewayScheme()
if err != nil {
return nil, fmt.Errorf("failed to load gateway shceme: %w", err)
}
scheme := envoygateway.GetScheme()

cli, err := client.New(config.GetConfigOrDie(), client.Options{Scheme: scheme})
if err != nil {
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ httpRoutes:
- path:
type: Exact
value: /exact
sessionPersistence: null
status:
parents:
- conditions:
Loading

0 comments on commit 621e1c4

Please sign in to comment.