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

feat: add log driver settings to DeploymentSettings #1703

Merged
merged 4 commits into from
Dec 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,52 @@ spec:
type: object
type: array
type: object
logging:
description: Settings for connections to log aggregation datastores
properties:
driver:
description: The type of log aggregation solution you wish to
use
type: string
enabled:
type: boolean
victoria:
description: Configures a connection to victoria metrics
properties:
host:
description: Host ...
type: string
password:
description: Password to connect w/ for basic auth
type: string
passwordSecretRef:
description: PasswordSecretRef selects a key of a password
Secret
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
user:
description: User to connect with basic auth
type: string
required:
- host
type: object
type: object
lokiConnection:
description: LokiConnection connection details for a loki instance
to use
Expand Down
32 changes: 32 additions & 0 deletions go/controller/api/v1alpha1/deploymentsettings_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ type DeploymentSettingsSpec struct {
//
// +kubebuilder:validation:Optional
AI *AISettings `json:"ai,omitempty"`

// Settings for connections to log aggregation datastores
//
// +kubebuilder:validation:Optional
Logging *LoggingSettings `json:"logging,omitempty"`
}

type LoggingSettings struct {
// +kubebuilder:validation:Optional
Enabled *bool `json:"enabled,omitempty"`
// The type of log aggregation solution you wish to use
// +kubebuilder:validation:Optional
Driver *console.LogDriver `json:"driver,omitempty"`
// Configures a connection to victoria metrics
// +kubebuilder:validation:Optional
Victoria *HTTPConnection `json:"victoria,omitempty"`
}

type HTTPConnection struct {
Expand Down Expand Up @@ -225,6 +241,22 @@ type AISettings struct {
Vertex *VertexSettings `json:"vertex,omitempty"`
}

func (in *LoggingSettings) Attributes(ctx context.Context, c client.Client, namespace string) (*console.LoggingSettingsAttributes, error) {
attr := &console.LoggingSettingsAttributes{
Enabled: in.Enabled,
Driver: in.Driver,
}
if in.Victoria != nil {
connection, err := in.Victoria.Attributes(ctx, c, namespace)
if err != nil {
return nil, err
}
attr.Victoria = connection
}

return attr, nil
}

func (in *AISettings) Attributes(ctx context.Context, c client.Client, namespace string) (*console.AiSettingsAttributes, error) {
attr := &console.AiSettingsAttributes{
Enabled: in.Enabled,
Expand Down
35 changes: 35 additions & 0 deletions go/controller/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 @@ -400,6 +400,52 @@ spec:
type: object
type: array
type: object
logging:
description: Settings for connections to log aggregation datastores
properties:
driver:
description: The type of log aggregation solution you wish to
use
type: string
enabled:
type: boolean
victoria:
description: Configures a connection to victoria metrics
properties:
host:
description: Host ...
type: string
password:
description: Password to connect w/ for basic auth
type: string
passwordSecretRef:
description: PasswordSecretRef selects a key of a password
Secret
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
user:
description: User to connect with basic auth
type: string
required:
- host
type: object
type: object
lokiConnection:
description: LokiConnection connection details for a loki instance
to use
Expand Down
20 changes: 20 additions & 0 deletions go/controller/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ _Appears in:_
| `prometheusConnection` _[HTTPConnection](#httpconnection)_ | PrometheusConnection connection details for a prometheus instance to use | | Optional: {} <br /> |
| `lokiConnection` _[HTTPConnection](#httpconnection)_ | LokiConnection connection details for a loki instance to use | | Optional: {} <br /> |
| `ai` _[AISettings](#aisettings)_ | AI settings specifies a configuration for LLM provider clients | | Optional: {} <br /> |
| `logging` _[LoggingSettings](#loggingsettings)_ | Settings for connections to log aggregation datastores | | Optional: {} <br /> |



Expand Down Expand Up @@ -948,6 +949,7 @@ _Appears in:_

_Appears in:_
- [DeploymentSettingsSpec](#deploymentsettingsspec)
- [LoggingSettings](#loggingsettings)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
Expand Down Expand Up @@ -1182,6 +1184,24 @@ _Appears in:_
| `resources` _[ContainerResources](#containerresources)_ | Resource specification that overrides implicit container resources when containers are not directly configured. | | Optional: {} <br /> |


#### LoggingSettings







_Appears in:_
- [DeploymentSettingsSpec](#deploymentsettingsspec)

| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `enabled` _boolean_ | | | Optional: {} <br /> |
| `driver` _[LogDriver](#logdriver)_ | The type of log aggregation solution you wish to use | | Optional: {} <br /> |
| `victoria` _[HTTPConnection](#httpconnection)_ | Configures a connection to victoria metrics | | Optional: {} <br /> |


#### ManagedNamespace


Expand Down
11 changes: 11 additions & 0 deletions go/controller/internal/controller/deploymentsettings_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ func (r *DeploymentSettingsReconciler) genDeploymentSettingsAttr(ctx context.Con
}
attr.Ai = ai
}
if settings.Spec.Logging != nil {
logging, err := settings.Spec.Logging.Attributes(ctx, r.Client, settings.Namespace)
if errors.IsNotFound(err) {
return nil, operrors.ErrReferenceNotFound
}

if err != nil {
return nil, err
}
attr.Logging = logging
}
if settings.Spec.Stacks != nil {
var jobSpec *console.GateJobAttributes
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,52 @@ spec:
type: object
type: array
type: object
logging:
description: Settings for connections to log aggregation datastores
properties:
driver:
description: The type of log aggregation solution you wish to
use
type: string
enabled:
type: boolean
victoria:
description: Configures a connection to victoria metrics
properties:
host:
description: Host ...
type: string
password:
description: Password to connect w/ for basic auth
type: string
passwordSecretRef:
description: PasswordSecretRef selects a key of a password
Secret
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
user:
description: User to connect with basic auth
type: string
required:
- host
type: object
type: object
lokiConnection:
description: LokiConnection connection details for a loki instance
to use
Expand Down
Loading