Skip to content

Commit 146b258

Browse files
author
Kate Osborn
committed
Support NginxProxy at the Gateway level
1 parent f8bbcbe commit 146b258

40 files changed

+3535
-1970
lines changed

apis/v1alpha1/register.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3434
scheme.AddKnownTypes(SchemeGroupVersion,
3535
&NginxGateway{},
3636
&NginxGatewayList{},
37-
&NginxProxy{},
38-
&NginxProxyList{},
3937
&ObservabilityPolicy{},
4038
&ObservabilityPolicyList{},
4139
&ClientSettingsPolicy{},

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 218 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha2/doc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Package v1alpha2 contains API Schema definitions for the
2+
// gateway.nginx.org API group.
3+
//
4+
// +kubebuilder:object:generate=true
5+
// +groupName=gateway.nginx.org
6+
package v1alpha2

apis/v1alpha1/nginxproxy_types.go renamed to apis/v1alpha2/nginxproxy_types.go

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
package v1alpha1
1+
package v1alpha2
22

3-
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
6+
"github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1"
7+
)
48

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

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

5967
// Telemetry specifies the OpenTelemetry configuration.
6068
type Telemetry struct {
69+
// DisabledFeatures specifies OpenTelemetry features to be disabled.
70+
//
71+
// +optional
72+
DisabledFeatures []DisableTelemetryFeature `json:"disabledFeatures,omitempty"`
6173
// Exporter specifies OpenTelemetry export parameters.
6274
//
6375
// +optional
@@ -78,7 +90,7 @@ type Telemetry struct {
7890
// +listType=map
7991
// +listMapKey=key
8092
// +kubebuilder:validation:MaxItems=64
81-
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
93+
SpanAttributes []v1alpha1.SpanAttribute `json:"spanAttributes,omitempty"`
8294
}
8395

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

92104
// BatchSize is the maximum number of spans to be sent in one batch per worker.
93105
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
@@ -107,8 +119,9 @@ type TelemetryExporter struct {
107119
// Format: alphanumeric hostname with optional http scheme and optional port.
108120
//
109121
//nolint:lll
122+
// +optional
110123
// +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})?$`
111-
Endpoint string `json:"endpoint"`
124+
Endpoint *string `json:"endpoint,omitempty"`
112125
}
113126

114127
// RewriteClientIP specifies the configuration for rewriting the client's IP address.
@@ -249,3 +262,13 @@ const (
249262
// NginxLogLevelEmerg is the emerg level for NGINX error logs.
250263
NginxLogLevelEmerg NginxErrorLogLevel = "emerg"
251264
)
265+
266+
// DisableTelemetryFeature is a telemetry feature that can be disabled.
267+
//
268+
// +kubebuilder:validation:Enum=DisableTracing
269+
type DisableTelemetryFeature string
270+
271+
const (
272+
// DisableTracing disables the OpenTelemetry tracing feature.
273+
DisableTracing DisableTelemetryFeature = "DisableTracing"
274+
)

apis/v1alpha2/register.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package v1alpha2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
)
8+
9+
// GroupName specifies the group name used to register the objects.
10+
const GroupName = "gateway.nginx.org"
11+
12+
// SchemeGroupVersion is group version used to register these objects.
13+
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"}
14+
15+
// Resource takes an unqualified resource and returns a Group qualified GroupResource.
16+
func Resource(resource string) schema.GroupResource {
17+
return SchemeGroupVersion.WithResource(resource).GroupResource()
18+
}
19+
20+
var (
21+
// SchemeBuilder collects functions that add things to a scheme. It's to allow
22+
// code to compile without explicitly referencing generated types. You should
23+
// declare one in each package that will have generated deep copy or conversion
24+
// functions.
25+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
26+
27+
// AddToScheme applies all the stored functions to the scheme. A non-nil error
28+
// indicates that one function failed and the attempt was abandoned.
29+
AddToScheme = SchemeBuilder.AddToScheme
30+
)
31+
32+
// Adds the list of known types to Scheme.
33+
func addKnownTypes(scheme *runtime.Scheme) error {
34+
scheme.AddKnownTypes(SchemeGroupVersion,
35+
&NginxProxy{},
36+
&NginxProxyList{},
37+
)
38+
// AddToGroupVersion allows the serialization of client types like ListOptions.
39+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
40+
return nil
41+
}

0 commit comments

Comments
 (0)