Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NginxProxy at the Gateway level #3058

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&NginxGateway{},
&NginxGatewayList{},
&NginxProxy{},
&NginxProxyList{},
&ObservabilityPolicy{},
&ObservabilityPolicyList{},
&ClientSettingsPolicy{},
Expand Down
218 changes: 0 additions & 218 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions apis/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Package v1alpha2 contains API Schema definitions for the
// gateway.nginx.org API group.
//
// +kubebuilder:object:generate=true
// +groupName=gateway.nginx.org
package v1alpha2
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package v1alpha1
package v1alpha2

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1"
)

// +genclient
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:resource:categories=nginx-gateway-fabric,scope=Cluster
// +kubebuilder:resource:categories=nginx-gateway-fabric,scope=Namespaced
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

// NginxProxy is a configuration object that is attached to a GatewayClass parametersRef. It provides a way
// to configure global settings for all Gateways defined from the GatewayClass.
// NginxProxy is a configuration object that can be referenced from a GatewayClass parametersRef
// or a Gateway infrastructure.parametersRef. It provides a way to configure data plane settings.
// If referenced from a GatewayClass, the settings apply to all Gateways attached to the GatewayClass.
// If referenced from a Gateway, the settings apply to that Gateway alone. If both a Gateway and its GatewayClass
// reference an NginxProxy, the settings are merged. Settings specified on the Gateway NginxProxy override those
// set on the GatewayClass NginxProxy.
type NginxProxy struct { //nolint:govet // standard field alignment, don't change it
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -50,14 +58,18 @@ type NginxProxySpec struct {
// +optional
Logging *NginxLogging `json:"logging,omitempty"`
// DisableHTTP2 defines if http2 should be disabled for all servers.
// Default is false, meaning http2 will be enabled for all servers.
// If not specified, or set to false, http2 will be enabled for all servers.
//
// +optional
DisableHTTP2 bool `json:"disableHTTP2,omitempty"`
DisableHTTP2 *bool `json:"disableHTTP2,omitempty"`
}

// Telemetry specifies the OpenTelemetry configuration.
type Telemetry struct {
// DisabledFeatures specifies OpenTelemetry features to be disabled.
//
// +optional
DisabledFeatures []DisableTelemetryFeature `json:"disabledFeatures,omitempty"`
// Exporter specifies OpenTelemetry export parameters.
//
// +optional
Expand All @@ -78,7 +90,7 @@ type Telemetry struct {
// +listType=map
// +listMapKey=key
// +kubebuilder:validation:MaxItems=64
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
SpanAttributes []v1alpha1.SpanAttribute `json:"spanAttributes,omitempty"`
}

// TelemetryExporter specifies OpenTelemetry export parameters.
Expand All @@ -87,7 +99,7 @@ type TelemetryExporter struct {
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
//
// +optional
Interval *Duration `json:"interval,omitempty"`
Interval *v1alpha1.Duration `json:"interval,omitempty"`

// BatchSize is the maximum number of spans to be sent in one batch per worker.
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
Expand All @@ -107,8 +119,9 @@ type TelemetryExporter struct {
// Format: alphanumeric hostname with optional http scheme and optional port.
//
//nolint:lll
// +optional
// +kubebuilder:validation:Pattern=`^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$`
Endpoint string `json:"endpoint"`
Endpoint *string `json:"endpoint,omitempty"`
}

// RewriteClientIP specifies the configuration for rewriting the client's IP address.
Expand Down Expand Up @@ -249,3 +262,13 @@ const (
// NginxLogLevelEmerg is the emerg level for NGINX error logs.
NginxLogLevelEmerg NginxErrorLogLevel = "emerg"
)

// DisableTelemetryFeature is a telemetry feature that can be disabled.
//
// +kubebuilder:validation:Enum=DisableTracing
type DisableTelemetryFeature string

const (
// DisableTracing disables the OpenTelemetry tracing feature.
DisableTracing DisableTelemetryFeature = "DisableTracing"
)
41 changes: 41 additions & 0 deletions apis/v1alpha2/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupName specifies the group name used to register the objects.
const GroupName = "gateway.nginx.org"

// SchemeGroupVersion is group version used to register these objects.
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}

// Resource takes an unqualified resource and returns a Group qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
// SchemeBuilder collects functions that add things to a scheme. It's to allow
// code to compile without explicitly referencing generated types. You should
// declare one in each package that will have generated deep copy or conversion
// functions.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme applies all the stored functions to the scheme. A non-nil error
// indicates that one function failed and the attempt was abandoned.
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&NginxProxy{},
&NginxProxyList{},
)
// AddToGroupVersion allows the serialization of client types like ListOptions.
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
Loading
Loading