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

api: Model OpenTelelemetry Sinks as a BackendRef #3067

Merged
merged 5 commits into from
Apr 2, 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
14 changes: 13 additions & 1 deletion api/v1alpha1/accesslogging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

type ProxyAccessLog struct {
// Disable disables access logging for managed proxies if set to true.
Disable bool `json:"disable,omitempty"`
Expand Down Expand Up @@ -92,16 +94,26 @@ type FileEnvoyProxyAccessLog struct {
Path string `json:"path,omitempty"`
}

// TODO: consider reuse ExtensionService?
// OpenTelemetryEnvoyProxyAccessLog defines the OpenTelemetry access log sink.
//
// +kubebuilder:validation:XValidation:message="BackendRef only support Service Kind.",rule="!has(self.backendRef) || !has(self.backendRef.kind) || self.backendRef.kind == 'Service'"
type OpenTelemetryEnvoyProxyAccessLog struct {
// Host define the extension service hostname.
// Deprecated: Use BackendRef instead.
Host string `json:"host"`
// Port defines the port the extension service is exposed on.
// Deprecated: Use BackendRef instead.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
// BackendRef references a Kubernetes object that represents the
// backend server to which the accesslog will be sent.
// Only service Kind is supported for now.
//
// +optional
BackendRef *gwapiv1.BackendObjectReference `json:"backendRef,omitempty"`
// Resources is a set of labels that describe the source of a log entry, including envoy node info.
// It's recommended to follow [semantic conventions](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/).
// +optional
Expand Down
13 changes: 13 additions & 0 deletions api/v1alpha1/tracing_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package v1alpha1

import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

type ProxyTracing struct {
// SamplingRate controls the rate at which traffic will be
// selected for tracing if no prior sampling decision has been made.
Expand All @@ -28,20 +30,31 @@ const (
TracingProviderTypeOpenTelemetry TracingProviderType = "OpenTelemetry"
)

// TracingProvider defines the tracing provider configuration.
//
// +kubebuilder:validation:XValidation:message="BackendRef only support Service Kind.",rule="!has(self.backendRef) || !has(self.backendRef.kind) || self.backendRef.kind == 'Service'"
type TracingProvider struct {
// Type defines the tracing provider type.
// EG currently only supports OpenTelemetry.
// +kubebuilder:validation:Enum=OpenTelemetry
// +kubebuilder:default=OpenTelemetry
Type TracingProviderType `json:"type"`
// Host define the provider service hostname.
// Deprecated: Use BackendRef instead.
Host string `json:"host"`
// Port defines the port the provider service is exposed on.
// Deprecated: Use BackendRef instead.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
// BackendRef references a Kubernetes object that represents the
// backend server to which the accesslog will be sent.
// Only service Kind is supported for now.
//
// +optional
BackendRef *gwapiv1.BackendObjectReference `json:"backendRef"`
}

zirain marked this conversation as resolved.
Show resolved Hide resolved
type CustomTagType string
Expand Down
12 changes: 11 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -5899,14 +5899,95 @@ spec:
description: OpenTelemetry defines the OpenTelemetry
accesslog sink.
properties:
backendRef:
description: |-
BackendRef references a Kubernetes object that represents the
backend server to which the accesslog will be sent.
Only service Kind is supported for now.
properties:
group:
default: ""
description: |-
Group is the group of the referent. For example, "gateway.networking.k8s.io".
When unspecified or empty string, core API group is inferred.
maxLength: 253
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
default: Service
description: |-
Kind is the Kubernetes resource kind of the referent. For example
"Service".


Defaults to "Service" when not specified.


ExternalName services can refer to CNAME DNS records that may live
outside of the cluster and as such are difficult to reason about in
terms of conformance. They also may not be safe to forward to (see
CVE-2021-25740 for more information). Implementations SHOULD NOT
support ExternalName Services.


Support: Core (Services with a type other than ExternalName)


Support: Implementation-specific (Services with type ExternalName)
maxLength: 63
minLength: 1
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
name:
description: Name is the name of the referent.
maxLength: 253
minLength: 1
type: string
namespace:
description: |-
Namespace is the namespace of the backend. When unspecified, the local
namespace is inferred.


Note that when a namespace different than the local namespace is specified,
a ReferenceGrant object is required in the referent namespace to allow that
namespace's owner to accept the reference. See the ReferenceGrant
documentation for details.


Support: Core
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
port:
description: |-
Port specifies the destination port number to use for this resource.
Port is required when the referent is a Kubernetes Service. In this
case, the port number is the service port number, not the target port.
For other resources, destination port might be derived from the referent
resource or this field.
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- name
type: object
x-kubernetes-validations:
- message: Must have port for Service reference
rule: '(size(self.group) == 0 && self.kind
== ''Service'') ? has(self.port) : true'
host:
description: Host define the extension service
hostname.
description: |-
Host define the extension service hostname.
Deprecated: Use BackendRef instead.
type: string
port:
default: 4317
description: Port defines the port the extension
service is exposed on.
description: |-
Port defines the port the extension service is exposed on.
Deprecated: Use BackendRef instead.
format: int32
minimum: 0
type: integer
Expand All @@ -5920,6 +6001,10 @@ spec:
required:
- host
type: object
x-kubernetes-validations:
- message: BackendRef only support Service Kind.
rule: '!has(self.backendRef) || !has(self.backendRef.kind)
|| self.backendRef.kind == ''Service'''
type:
description: Type defines the type of accesslog
sink.
Expand Down Expand Up @@ -6111,13 +6196,95 @@ spec:
Provider defines the tracing provider.
Only OpenTelemetry is supported currently.
properties:
backendRef:
description: |-
BackendRef references a Kubernetes object that represents the
backend server to which the accesslog will be sent.
Only service Kind is supported for now.
properties:
group:
default: ""
description: |-
Group is the group of the referent. For example, "gateway.networking.k8s.io".
When unspecified or empty string, core API group is inferred.
maxLength: 253
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
default: Service
description: |-
Kind is the Kubernetes resource kind of the referent. For example
"Service".


Defaults to "Service" when not specified.


ExternalName services can refer to CNAME DNS records that may live
outside of the cluster and as such are difficult to reason about in
terms of conformance. They also may not be safe to forward to (see
CVE-2021-25740 for more information). Implementations SHOULD NOT
support ExternalName Services.


Support: Core (Services with a type other than ExternalName)


Support: Implementation-specific (Services with type ExternalName)
maxLength: 63
minLength: 1
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
name:
description: Name is the name of the referent.
maxLength: 253
minLength: 1
type: string
namespace:
description: |-
Namespace is the namespace of the backend. When unspecified, the local
namespace is inferred.


Note that when a namespace different than the local namespace is specified,
a ReferenceGrant object is required in the referent namespace to allow that
namespace's owner to accept the reference. See the ReferenceGrant
documentation for details.


Support: Core
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
port:
description: |-
Port specifies the destination port number to use for this resource.
Port is required when the referent is a Kubernetes Service. In this
case, the port number is the service port number, not the target port.
For other resources, destination port might be derived from the referent
resource or this field.
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- name
type: object
x-kubernetes-validations:
- message: Must have port for Service reference
rule: '(size(self.group) == 0 && self.kind == ''Service'')
? has(self.port) : true'
host:
description: Host define the provider service hostname.
description: |-
Host define the provider service hostname.
Deprecated: Use BackendRef instead.
type: string
port:
default: 4317
description: Port defines the port the provider service
is exposed on.
description: |-
Port defines the port the provider service is exposed on.
Deprecated: Use BackendRef instead.
format: int32
minimum: 0
type: integer
Expand All @@ -6133,6 +6300,10 @@ spec:
- host
- type
type: object
x-kubernetes-validations:
- message: BackendRef only support Service Kind.
rule: '!has(self.backendRef) || !has(self.backendRef.kind)
|| self.backendRef.kind == ''Service'''
samplingRate:
default: 100
description: |-
Expand Down
14 changes: 8 additions & 6 deletions site/content/en/latest/api/extension_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1793,15 +1793,16 @@ _Appears in:_



TODO: consider reuse ExtensionService?
OpenTelemetryEnvoyProxyAccessLog defines the OpenTelemetry access log sink.

_Appears in:_
- [ProxyAccessLogSink](#proxyaccesslogsink)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `host` | _string_ | true | Host define the extension service hostname. |
| `port` | _integer_ | false | Port defines the port the extension service is exposed on. |
| `host` | _string_ | true | Host define the extension service hostname.<br />Deprecated: Use BackendRef instead. |
| `port` | _integer_ | false | Port defines the port the extension service is exposed on.<br />Deprecated: Use BackendRef instead. |
| `backendRef` | _[BackendObjectReference](#backendobjectreference)_ | false | BackendRef references a Kubernetes object that represents the<br />backend server to which the accesslog will be sent.<br />Only service Kind is supported for now. |
| `resources` | _object (keys:string, values:string)_ | false | Resources is a set of labels that describe the source of a log entry, including envoy node info.<br />It's recommended to follow [semantic conventions](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/). |


Expand Down Expand Up @@ -2673,16 +2674,17 @@ _Appears in:_




TracingProvider defines the tracing provider configuration.

_Appears in:_
- [ProxyTracing](#proxytracing)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | _[TracingProviderType](#tracingprovidertype)_ | true | Type defines the tracing provider type.<br />EG currently only supports OpenTelemetry. |
| `host` | _string_ | true | Host define the provider service hostname. |
| `port` | _integer_ | false | Port defines the port the provider service is exposed on. |
| `host` | _string_ | true | Host define the provider service hostname.<br />Deprecated: Use BackendRef instead. |
| `port` | _integer_ | false | Port defines the port the provider service is exposed on.<br />Deprecated: Use BackendRef instead. |
| `backendRef` | _[BackendObjectReference](#backendobjectreference)_ | false | BackendRef references a Kubernetes object that represents the<br />backend server to which the accesslog will be sent.<br />Only service Kind is supported for now. |


#### TracingProviderType
Expand Down
Loading
Loading