Skip to content

Commit 9ace30c

Browse files
committed
Merge branch 'main' into fix-6752
2 parents 27ed400 + 5ebc004 commit 9ace30c

File tree

487 files changed

+2423
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

487 files changed

+2423
-280
lines changed

api/v1alpha1/envoyproxy_helpers.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
// DefaultEnvoyProxyProvider returns a new EnvoyProxyProvider with default settings.
2020
func DefaultEnvoyProxyProvider() *EnvoyProxyProvider {
2121
return &EnvoyProxyProvider{
22-
Type: ProviderTypeKubernetes,
22+
Type: EnvoyProxyProviderTypeKubernetes,
2323
}
2424
}
2525

@@ -42,6 +42,7 @@ func DefaultEnvoyProxyKubeProvider() *EnvoyProxyKubernetesProvider {
4242
}
4343
}
4444

45+
// DefaultEnvoyProxyHpaMetrics returns a default HPA metrics spec for EnvoyProxy.
4546
func DefaultEnvoyProxyHpaMetrics() []autoscalingv2.MetricSpec {
4647
return []autoscalingv2.MetricSpec{
4748
{
@@ -74,11 +75,21 @@ func (e *EnvoyProxy) NeedToSwitchPorts() bool {
7475
return !*e.Spec.Provider.Kubernetes.UseListenerPortAsContainerPort
7576
}
7677

78+
// GetEnvoyProxyHostProvider returns the EnvoyProxyHostProvider of EnvoyProxyProvider or
79+
// a nil EnvoyProxyHostProvider if unspecified. If EnvoyProxyProvider is not of
80+
// type "Host", a nil EnvoyProxyHostProvider is returned.
81+
func (r *EnvoyProxyProvider) GetEnvoyProxyHostProvider() *EnvoyProxyHostProvider {
82+
if r.Type != EnvoyProxyProviderTypeHost {
83+
return nil
84+
}
85+
return r.Host
86+
}
87+
7788
// GetEnvoyProxyKubeProvider returns the EnvoyProxyKubernetesProvider of EnvoyProxyProvider or
7889
// a default EnvoyProxyKubernetesProvider if unspecified. If EnvoyProxyProvider is not of
7990
// type "Kubernetes", a nil EnvoyProxyKubernetesProvider is returned.
8091
func (r *EnvoyProxyProvider) GetEnvoyProxyKubeProvider() *EnvoyProxyKubernetesProvider {
81-
if r.Type != ProviderTypeKubernetes {
92+
if r.Type != EnvoyProxyProviderTypeKubernetes {
8293
return nil
8394
}
8495

@@ -117,6 +128,15 @@ func (r *EnvoyProxyProvider) GetEnvoyProxyKubeProvider() *EnvoyProxyKubernetesPr
117128
return r.Kubernetes
118129
}
119130

131+
// GetEnvoyVersion returns the version of Envoy to use.
132+
// This method gracefully handles nil pointers.
133+
func (e *EnvoyProxyHostProvider) GetEnvoyVersion() string {
134+
if e == nil || e.EnvoyVersion == nil {
135+
return ""
136+
}
137+
return *e.EnvoyVersion
138+
}
139+
120140
// DefaultEnvoyProxyLoggingLevel returns envoy proxy v1alpha1.LogComponentGatewayDefault log level.
121141
// If unspecified, defaults to "warn". When specified, all other logging components are ignored.
122142
func (logging *ProxyLogging) DefaultEnvoyProxyLoggingLevel() LogLevel {

api/v1alpha1/envoyproxy_types.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,42 @@ type ProxyTelemetry struct {
329329
Metrics *ProxyMetrics `json:"metrics,omitempty"`
330330
}
331331

332+
// EnvoyProxyProviderType defines the types of providers supported by Envoy Proxy.
333+
//
334+
// +kubebuilder:validation:Enum=Kubernetes;Host
335+
type EnvoyProxyProviderType string
336+
337+
const (
338+
// EnvoyProxyProviderTypeKubernetes defines the "Kubernetes" provider.
339+
EnvoyProxyProviderTypeKubernetes EnvoyProxyProviderType = "Kubernetes"
340+
341+
// EnvoyProxyProviderTypeHost defines the "Host" provider.
342+
EnvoyProxyProviderTypeHost EnvoyProxyProviderType = "Host"
343+
)
344+
332345
// EnvoyProxyProvider defines the desired state of a resource provider.
333346
// +union
334347
type EnvoyProxyProvider struct {
335348
// Type is the type of resource provider to use. A resource provider provides
336349
// infrastructure resources for running the data plane, e.g. Envoy proxy, and
337-
// optional auxiliary control planes. Supported types are "Kubernetes".
350+
// optional auxiliary control planes. Supported types are "Kubernetes"and "Host".
338351
//
339352
// +unionDiscriminator
340-
Type ProviderType `json:"type"`
353+
Type EnvoyProxyProviderType `json:"type"`
341354
// Kubernetes defines the desired state of the Kubernetes resource provider.
342355
// Kubernetes provides infrastructure resources for running the data plane,
343356
// e.g. Envoy proxy. If unspecified and type is "Kubernetes", default settings
344357
// for managed Kubernetes resources are applied.
345358
//
346359
// +optional
347360
Kubernetes *EnvoyProxyKubernetesProvider `json:"kubernetes,omitempty"`
361+
// Host provides runtime deployment of the data plane as a child process on the
362+
// host environment.
363+
// If unspecified and type is "Host", default settings for the custom provider
364+
// are applied.
365+
//
366+
// +optional
367+
Host *EnvoyProxyHostProvider `json:"host,omitempty"`
348368
}
349369

350370
// ShutdownConfig defines configuration for graceful envoy shutdown process.
@@ -407,6 +427,15 @@ type EnvoyProxyKubernetesProvider struct {
407427
EnvoyServiceAccount *KubernetesServiceAccountSpec `json:"envoyServiceAccount,omitempty"`
408428
}
409429

430+
// EnvoyProxyHostProvider defines configuration for the "Host" resource provider.
431+
type EnvoyProxyHostProvider struct {
432+
// EnvoyVersion is the version of Envoy to use. If unspecified, the version
433+
// against which Envoy Gateway is built will be used.
434+
//
435+
// +optional
436+
EnvoyVersion *string `json:"envoyVersion,omitempty"`
437+
}
438+
410439
type KubernetesServiceAccountSpec struct {
411440
// Name of the Service Account.
412441
// When unset, this defaults to an autogenerated name.

api/v1alpha1/validation/envoygateway_validate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func validateEnvoyGatewayCustomInfrastructureProvider(infra *egv1a1.EnvoyGateway
129129
return fmt.Errorf("field 'host' should be specified when infrastructure type is 'Host'")
130130
}
131131
default:
132-
return fmt.Errorf("unsupported infrastructure provdier: %s", infra.Type)
132+
return fmt.Errorf("unsupported infrastructure provider: %s", infra.Type)
133133
}
134134
return nil
135135
}

api/v1alpha1/validation/envoyproxy_validate.go

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,31 @@ func validateEnvoyProxySpec(spec *egv1a1.EnvoyProxySpec) error {
6767
func validateProvider(spec *egv1a1.EnvoyProxySpec) []error {
6868
var errs []error
6969
if spec != nil && spec.Provider != nil {
70-
if spec.Provider.Type != egv1a1.ProviderTypeKubernetes {
70+
switch spec.Provider.Type {
71+
case egv1a1.EnvoyProxyProviderTypeKubernetes:
72+
validateDeploymentErrs := validateDeployment(spec)
73+
if len(validateDeploymentErrs) != 0 {
74+
errs = append(errs, validateDeploymentErrs...)
75+
}
76+
validateHpaErrors := validateHpa(spec)
77+
if len(validateHpaErrors) != 0 {
78+
errs = append(errs, validateHpaErrors...)
79+
}
80+
validatePdbErrors := validatePdb(spec)
81+
if len(validatePdbErrors) != 0 {
82+
errs = append(errs, validatePdbErrors...)
83+
}
84+
validateServiceErrs := validateService(spec)
85+
if len(validateServiceErrs) != 0 {
86+
errs = append(errs, validateServiceErrs...)
87+
}
88+
case egv1a1.EnvoyProxyProviderTypeHost:
89+
if spec.Provider.Host == nil {
90+
errs = append(errs, fmt.Errorf("field 'host' should be specified when provider type is 'Host'"))
91+
}
92+
default:
7193
errs = append(errs, fmt.Errorf("unsupported provider type %v", spec.Provider.Type))
7294
}
73-
validateDeploymentErrs := validateDeployment(spec)
74-
if len(validateDeploymentErrs) != 0 {
75-
errs = append(errs, validateDeploymentErrs...)
76-
}
77-
validateHpaErrors := validateHpa(spec)
78-
if len(validateHpaErrors) != 0 {
79-
errs = append(errs, validateHpaErrors...)
80-
}
81-
validatePdbErrors := validatePdb(spec)
82-
if len(validatePdbErrors) != 0 {
83-
errs = append(errs, validatePdbErrors...)
84-
}
85-
validateServiceErrs := validateService(spec)
86-
if len(validateServiceErrs) != 0 {
87-
errs = append(errs, validateServiceErrs...)
88-
}
8995
}
9096
return errs
9197
}

0 commit comments

Comments
 (0)