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 2 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
91 changes: 91 additions & 0 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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
ServiceName *string `json:"serviceName,omitempty"`

// SpanAttributes are custom key/value attributes that are added to each span.
//
// +optional
// +kubebuilder:validation:MaxProperties=64
sjberman marked this conversation as resolved.
Show resolved Hide resolved
SpanAttributes map[string]AttributeValue `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.
//
//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
}

// AttributeValue is a value paired with a key and attached to a tracing span.
//
// +kubebuilder:validation:MaxLength=255
type AttributeValue string
sjberman marked this conversation as resolved.
Show resolved Hide resolved
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
140 changes: 140 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.

108 changes: 108 additions & 0 deletions config/crd/bases/gateway.nginx.org_nginxproxies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: nginxproxies.gateway.nginx.org
spec:
group: gateway.nginx.org
names:
categories:
- nginx-gateway-fabric
kind: NginxProxy
listKind: NginxProxyList
plural: nginxproxies
singular: nginxproxy
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
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.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of the NginxProxy.
properties:
telemetry:
description: Telemetry specifies the OpenTelemetry configuration.
properties:
exporter:
description: Exporter specifies OpenTelemetry export parameters.
properties:
batchCount:
description: |-
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
format: int32
minimum: 0
type: integer
batchSize:
description: |-
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
format: int32
minimum: 0
type: integer
endpoint:
description: Endpoint is the address of OTLP/gRPC endpoint
that will accept telemetry data.
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})?$
type: string
interval:
description: |-
Interval is the maximum interval between two exports.
Default: https://nginx.org/en/docs/ngx_otel_module.html#otel_exporter
pattern: ^\d{1,4}(ms|s)?$
type: string
required:
- endpoint
type: object
serviceName:
description: |-
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.
maxLength: 127
type: string
spanAttributes:
additionalProperties:
description: AttributeValue is a value paired with a key and
attached to a tracing span.
maxLength: 255
type: string
description: SpanAttributes are custom key/value attributes that
are added to each span.
maxProperties: 64
type: object
type: object
type: object
required:
- spec
type: object
served: true
storage: true
subresources: {}
Loading