Skip to content

Commit 0c6d8f4

Browse files
committed
Add NginxProxy CRD
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 f29eddb commit 0c6d8f4

6 files changed

+333
-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: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
ServiceName *string `json:"serviceName,omitempty"`
51+
52+
// SpanAttributes are custom key/value attributes that are added to each span.
53+
//
54+
// +optional
55+
// +kubebuilder:validation:MaxProperties=64
56+
SpanAttributes map[string]string `json:"spanAttributes,omitempty"`
57+
}
58+
59+
// TelemetryExporter specifies OpenTelemetry export parameters.
60+
type TelemetryExporter struct {
61+
// Interval is the maximum interval between two exports, by default is 5 seconds.
62+
//
63+
// +optional
64+
Interval *Duration `json:"interval,omitempty"`
65+
66+
// BatchSize is the maximum number of spans to be sent in one batch per worker, by default is 512.
67+
//
68+
// +optional
69+
// +kubebuilder:validation:Minimum=0
70+
BatchSize *int32 `json:"batchSize,omitempty"`
71+
72+
// BatchCount is the number of pending batches per worker, spans exceeding the limit are dropped,
73+
// by default is 4.
74+
//
75+
// +optional
76+
// +kubebuilder:validation:Minimum=0
77+
BatchCount *int32 `json:"batchCount,omitempty"`
78+
79+
// Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
80+
Endpoint string `json:"endpoint"`
81+
}

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: 140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.14.0
7+
name: nginxproxies.gateway.nginx.org
8+
spec:
9+
group: gateway.nginx.org
10+
names:
11+
categories:
12+
- nginx-gateway-fabric
13+
kind: NginxProxy
14+
listKind: NginxProxyList
15+
plural: nginxproxies
16+
singular: nginxproxy
17+
scope: Cluster
18+
versions:
19+
- additionalPrinterColumns:
20+
- jsonPath: .metadata.creationTimestamp
21+
name: Age
22+
type: date
23+
name: v1alpha1
24+
schema:
25+
openAPIV3Schema:
26+
description: |-
27+
NginxProxy is a configuration object that is attached to a GatewayClass parametersRef. It provides a way
28+
to configure global settings for all Gateways defined from the GatewayClass.
29+
properties:
30+
apiVersion:
31+
description: |-
32+
APIVersion defines the versioned schema of this representation of an object.
33+
Servers should convert recognized schemas to the latest internal value, and
34+
may reject unrecognized values.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
36+
type: string
37+
kind:
38+
description: |-
39+
Kind is a string value representing the REST resource this object represents.
40+
Servers may infer this from the endpoint the client submits requests to.
41+
Cannot be updated.
42+
In CamelCase.
43+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
44+
type: string
45+
metadata:
46+
type: object
47+
spec:
48+
description: Spec defines the desired state of the NginxProxy.
49+
properties:
50+
telemetry:
51+
description: Telemetry specifies the OpenTelemetry configuration.
52+
properties:
53+
exporter:
54+
description: Exporter specifies OpenTelemetry export parameters.
55+
properties:
56+
batchCount:
57+
description: |-
58+
BatchCount is the number of pending batches per worker, spans exceeding the limit are dropped,
59+
by default is 4.
60+
format: int32
61+
minimum: 0
62+
type: integer
63+
batchSize:
64+
description: BatchSize is the maximum number of spans to be
65+
sent in one batch per worker, by default is 512.
66+
format: int32
67+
minimum: 0
68+
type: integer
69+
endpoint:
70+
description: Endpoint is the address of OTLP/gRPC endpoint
71+
that will accept telemetry data.
72+
type: string
73+
interval:
74+
description: Interval is the maximum interval between two
75+
exports, by default is 5 seconds.
76+
pattern: ^\d{1,4}(ms|s)?$
77+
type: string
78+
required:
79+
- endpoint
80+
type: object
81+
serviceName:
82+
description: |-
83+
ServiceName is the "service.name" attribute of the OpenTelemetry resource.
84+
Default is 'ngf:<gateway-namespace>:<gateway-name>'. If a value is provided by the user,
85+
then the default becomes a prefix to that value.
86+
maxLength: 127
87+
type: string
88+
spanAttributes:
89+
additionalProperties:
90+
type: string
91+
description: SpanAttributes are custom key/value attributes that
92+
are added to each span.
93+
maxProperties: 64
94+
type: object
95+
type: object
96+
type: object
97+
required:
98+
- spec
99+
type: object
100+
served: true
101+
storage: true
102+
subresources: {}

0 commit comments

Comments
 (0)