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

Add NginxProxy CRD #1815

Merged
merged 7 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions apis/v1alpha1/clientsettingspolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ type ClientKeepAliveTimeout struct {
Header *Duration `json:"header,omitempty"`
}

// Duration is a string value representing a duration in time.
// Duration can be specified in milliseconds (ms) or seconds (s) A value without a suffix is seconds.
// Examples: 120s, 50ms.
//
// +kubebuilder:validation:Pattern=`^\d{1,4}(ms|s)?$`
type Duration string

// Size is a string value representing a size. Size can be specified in bytes, kilobytes (k), megabytes (m),
// or gigabytes (g).
// Examples: 1024, 8k, 1m.
Expand Down
107 changes: 107 additions & 0 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package v1alpha1

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

// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:resource:categories=nginx-gateway-fabric,scope=Cluster
// +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.
type NginxProxy struct { //nolint:govet // standard field alignment, don't change it
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the desired state of the NginxProxy.
Spec NginxProxySpec `json:"spec"`
}

// +kubebuilder:object:root=true

// NginxProxyList contains a list of NginxProxies.
type NginxProxyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NginxProxy `json:"items"`
}

// NginxProxySpec defines the desired state of the NginxProxy.
type NginxProxySpec struct {
// Telemetry specifies the OpenTelemetry configuration.
//
// +optional
Telemetry *Telemetry `json:"telemetry,omitempty"`
}

// Telemetry specifies the OpenTelemetry configuration.
type Telemetry struct {
// Exporter specifies OpenTelemetry export parameters.
//
// +optional
Exporter *TelemetryExporter `json:"exporter,omitempty"`

// ServiceName is the "service.name" attribute of the OpenTelemetry resource.
// Default is 'ngf:<gateway-namespace>:<gateway-name>'. If a value is provided by the user,
// then the default becomes a prefix to that value.
//
// +optional
// +kubebuilder:validation:MaxLength=127
sjberman marked this conversation as resolved.
Show resolved Hide resolved
sjberman marked this conversation as resolved.
Show resolved Hide resolved
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
ServiceName *string `json:"serviceName,omitempty"`

// SpanAttributes are custom key/value attributes that are added to each span.
//
// +optional
// +listType=map
// +listMapKey=key
// +kubebuilder:validation:MaxItems=64
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
}

// TelemetryExporter specifies OpenTelemetry export parameters.
type TelemetryExporter struct {
// Interval is the maximum interval between two exports.
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
//
// +optional
Interval *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
//
// +optional
// +kubebuilder:validation:Minimum=0
BatchSize *int32 `json:"batchSize,omitempty"`

// BatchCount is the number of pending batches per worker, spans exceeding the limit are dropped.
// Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
//
// +optional
// +kubebuilder:validation:Minimum=0
BatchCount *int32 `json:"batchCount,omitempty"`

// Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
// Format: alphanumeric hostname with optional http scheme and optional port.
//
//nolint:lll
// +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})?$`
sjberman marked this conversation as resolved.
Show resolved Hide resolved
Endpoint string `json:"endpoint"`
kate-osborn marked this conversation as resolved.
Show resolved Hide resolved
}

// SpanAttribute is a key value pair to be added to a tracing span.
type SpanAttribute struct {
// Key is the key for a span attribute.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
Key string `json:"key"`

// Value is the value for a span attribute.
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=255
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
Value string `json:"value"`
}
2 changes: 2 additions & 0 deletions apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&NginxGateway{},
&NginxGatewayList{},
&NginxProxy{},
&NginxProxyList{},
&ClientSettingsPolicy{},
&ClientSettingsPolicyList{},
)
Expand Down
8 changes: 8 additions & 0 deletions apis/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package v1alpha1

// Duration is a string value representing a duration in time.
// Duration can be specified in milliseconds (ms) or seconds (s) A value without a suffix is seconds.
// Examples: 120s, 50ms.
//
// +kubebuilder:validation:Pattern=`^\d{1,4}(ms|s)?$`
type Duration string
153 changes: 153 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

Loading
Loading