Skip to content

Commit

Permalink
Merge branch 'main' into tcp-idle-timeout-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 1d977e0 + bab79b0 commit b3eaaf4
Show file tree
Hide file tree
Showing 217 changed files with 674 additions and 420 deletions.
27 changes: 24 additions & 3 deletions api/v1alpha1/loadbalancer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type LoadBalancer struct {
// "ConsistentHash",
// "LeastRequest",
// "Random",
// "RoundRobin",
// "RoundRobin".
//
// +unionDiscriminator
Type LoadBalancerType `json:"type"`
Expand Down Expand Up @@ -52,18 +52,39 @@ 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"`
}

// 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.
Expand Down
22 changes: 21 additions & 1 deletion 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
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,29 @@ 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
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.
Expand All @@ -444,7 +458,7 @@ spec:
"ConsistentHash",
"LeastRequest",
"Random",
"RoundRobin",
"RoundRobin".
enum:
- ConsistentHash
- LeastRequest
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
Expand Down Expand Up @@ -362,7 +361,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
"port": 3000,
"weight": 1
}
],
"sessionPersistence": null
]
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
Expand Down Expand Up @@ -242,7 +241,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ grpcRoutes:
- method:
method: DoThing
service: com.example.Things
sessionPersistence: null
status:
parents:
- conditions:
Expand Down Expand Up @@ -235,7 +234,6 @@ httpRoutes:
- path:
type: PathPrefix
value: /
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
31 changes: 2 additions & 29 deletions internal/cmd/egctl/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ httpRoutes:
- path:
type: Exact
value: /exact
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ httpRoutes:
- path:
type: Exact
value: /exact
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ httpRoutes:
- path:
type: Exact
value: /exact
sessionPersistence: null
status:
parents:
- conditions:
Expand Down
Loading

0 comments on commit b3eaaf4

Please sign in to comment.