|
| 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 | +} |
0 commit comments