Skip to content

Commit eeaa3f2

Browse files
authored
Add NginxProxy CRD (#1815)
Problem: Users want to be able to configure global Gateway settings, such as the Otel tracing exporter, for all Gateways in a Class. Solution: Add the NginxProxy CRD, which provides a way to configure these settings. Note: this PR contains the CRD only. A subsequent PR will add the implementation.
1 parent e79f137 commit eeaa3f2

File tree

6 files changed

+398
-7
lines changed

6 files changed

+398
-7
lines changed

apis/v1alpha1/clientsettingspolicy_types.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,6 @@ type ClientKeepAliveTimeout struct {
114114
Header *Duration `json:"header,omitempty"`
115115
}
116116

117-
// Duration is a string value representing a duration in time.
118-
// Duration can be specified in milliseconds (ms) or seconds (s) A value without a suffix is seconds.
119-
// Examples: 120s, 50ms.
120-
//
121-
// +kubebuilder:validation:Pattern=`^\d{1,4}(ms|s)?$`
122-
type Duration string
123-
124117
// Size is a string value representing a size. Size can be specified in bytes, kilobytes (k), megabytes (m),
125118
// or gigabytes (g).
126119
// Examples: 1024, 8k, 1m.

apis/v1alpha1/nginxproxy_types.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package v1alpha1
2+
3+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
5+
// +kubebuilder:object:root=true
6+
// +kubebuilder:storageversion
7+
// +kubebuilder:resource:categories=nginx-gateway-fabric,scope=Cluster
8+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
9+
10+
// NginxProxy is a configuration object that is attached to a GatewayClass parametersRef. It provides a way
11+
// to configure global settings for all Gateways defined from the GatewayClass.
12+
type NginxProxy struct { //nolint:govet // standard field alignment, don't change it
13+
metav1.TypeMeta `json:",inline"`
14+
metav1.ObjectMeta `json:"metadata,omitempty"`
15+
16+
// Spec defines the desired state of the NginxProxy.
17+
Spec NginxProxySpec `json:"spec"`
18+
}
19+
20+
// +kubebuilder:object:root=true
21+
22+
// NginxProxyList contains a list of NginxProxies.
23+
type NginxProxyList struct {
24+
metav1.TypeMeta `json:",inline"`
25+
metav1.ListMeta `json:"metadata,omitempty"`
26+
Items []NginxProxy `json:"items"`
27+
}
28+
29+
// NginxProxySpec defines the desired state of the NginxProxy.
30+
type NginxProxySpec struct {
31+
// Telemetry specifies the OpenTelemetry configuration.
32+
//
33+
// +optional
34+
Telemetry *Telemetry `json:"telemetry,omitempty"`
35+
}
36+
37+
// Telemetry specifies the OpenTelemetry configuration.
38+
type Telemetry struct {
39+
// Exporter specifies OpenTelemetry export parameters.
40+
//
41+
// +optional
42+
Exporter *TelemetryExporter `json:"exporter,omitempty"`
43+
44+
// ServiceName is the "service.name" attribute of the OpenTelemetry resource.
45+
// Default is 'ngf:<gateway-namespace>:<gateway-name>'. If a value is provided by the user,
46+
// then the default becomes a prefix to that value.
47+
//
48+
// +optional
49+
// +kubebuilder:validation:MaxLength=127
50+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
51+
ServiceName *string `json:"serviceName,omitempty"`
52+
53+
// SpanAttributes are custom key/value attributes that are added to each span.
54+
//
55+
// +optional
56+
// +listType=map
57+
// +listMapKey=key
58+
// +kubebuilder:validation:MaxItems=64
59+
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
60+
}
61+
62+
// TelemetryExporter specifies OpenTelemetry export parameters.
63+
type TelemetryExporter struct {
64+
// Interval is the maximum interval between two exports.
65+
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
66+
//
67+
// +optional
68+
Interval *Duration `json:"interval,omitempty"`
69+
70+
// BatchSize is the maximum number of spans to be sent in one batch per worker.
71+
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
72+
//
73+
// +optional
74+
// +kubebuilder:validation:Minimum=0
75+
BatchSize *int32 `json:"batchSize,omitempty"`
76+
77+
// BatchCount is the number of pending batches per worker, spans exceeding the limit are dropped.
78+
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
79+
//
80+
// +optional
81+
// +kubebuilder:validation:Minimum=0
82+
BatchCount *int32 `json:"batchCount,omitempty"`
83+
84+
// Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
85+
// Format: alphanumeric hostname with optional http scheme and optional port.
86+
//
87+
//nolint:lll
88+
// +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})?$`
89+
Endpoint string `json:"endpoint"`
90+
}
91+
92+
// SpanAttribute is a key value pair to be added to a tracing span.
93+
type SpanAttribute struct {
94+
// Key is the key for a span attribute.
95+
//
96+
// +kubebuilder:validation:MinLength=1
97+
// +kubebuilder:validation:MaxLength=255
98+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
99+
Key string `json:"key"`
100+
101+
// Value is the value for a span attribute.
102+
//
103+
// +kubebuilder:validation:MinLength=1
104+
// +kubebuilder:validation:MaxLength=255
105+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
106+
Value string `json:"value"`
107+
}

apis/v1alpha1/register.go

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

apis/v1alpha1/shared_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package v1alpha1
2+
3+
// Duration is a string value representing a duration in time.
4+
// Duration can be specified in milliseconds (ms) or seconds (s) A value without a suffix is seconds.
5+
// Examples: 120s, 50ms.
6+
//
7+
// +kubebuilder:validation:Pattern=`^\d{1,4}(ms|s)?$`
8+
type Duration string

apis/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)