Skip to content

Commit 080359b

Browse files
Merge pull request #837 from jlarriba/add-loki-retention-days
Add lokiRetentionDays configuration for CloudKitty LokiStack
2 parents 56f8498 + dd2368e commit 080359b

10 files changed

Lines changed: 48 additions & 0 deletions

api/bases/telemetry.openstack.org_cloudkitties.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ spec:
528528
Right now required by the maridb-operator to get the credentials from the instance to create the DB
529529
Might not be required in future
530530
type: string
531+
lokiRetentionDays:
532+
default: 95
533+
description: |-
534+
LokiRetentionDays defines the number of days logs are kept in Loki storage.
535+
Set to 0 to disable retention limits.
536+
type: integer
531537
lokiStackSize:
532538
default: 1x.demo
533539
description: Size of the LokiStack. Supported are "1x.demo" (default),

api/bases/telemetry.openstack.org_telemetries.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,12 @@ spec:
10961096
description: Enabled - Whether OpenStack CloudKitty service should
10971097
be deployed and managed
10981098
type: boolean
1099+
lokiRetentionDays:
1100+
default: 95
1101+
description: |-
1102+
LokiRetentionDays defines the number of days logs are kept in Loki storage.
1103+
Set to 0 to disable retention limits.
1104+
type: integer
10991105
lokiStackSize:
11001106
default: 1x.demo
11011107
description: Size of the LokiStack. Supported are "1x.demo" (default),

api/v1beta1/cloudkitty_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ type CloudKittySpecBase struct {
205205
// +kubebuilder:validation:Enum="";"1x.demo";"1x.pico";"1x.extra-small";"1x.small";"1x.medium"
206206
// +kubebuilder:default="1x.demo"
207207
LokiStackSize string `json:"lokiStackSize"`
208+
209+
// LokiRetentionDays defines the number of days logs are kept in Loki storage.
210+
// Set to 0 to disable retention limits.
211+
// +kubebuilder:validation:Optional
212+
// +kubebuilder:default=95
213+
LokiRetentionDays uint `json:"lokiRetentionDays"`
208214
}
209215

210216
// CloudKittySpecCore the same as CloudKittySpec without ContainerImage references

config/crd/bases/telemetry.openstack.org_cloudkitties.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ spec:
528528
Right now required by the maridb-operator to get the credentials from the instance to create the DB
529529
Might not be required in future
530530
type: string
531+
lokiRetentionDays:
532+
default: 95
533+
description: |-
534+
LokiRetentionDays defines the number of days logs are kept in Loki storage.
535+
Set to 0 to disable retention limits.
536+
type: integer
531537
lokiStackSize:
532538
default: 1x.demo
533539
description: Size of the LokiStack. Supported are "1x.demo" (default),

config/crd/bases/telemetry.openstack.org_telemetries.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,12 @@ spec:
10961096
description: Enabled - Whether OpenStack CloudKitty service should
10971097
be deployed and managed
10981098
type: boolean
1099+
lokiRetentionDays:
1100+
default: 95
1101+
description: |-
1102+
LokiRetentionDays defines the number of days logs are kept in Loki storage.
1103+
Set to 0 to disable retention limits.
1104+
type: integer
10991105
lokiStackSize:
11001106
default: 1x.demo
11011107
description: Size of the LokiStack. Supported are "1x.demo" (default),

internal/cloudkitty/lokistack.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ func LokiStack(
123123
if instance.Spec.LokiStackSize != "" {
124124
size = instance.Spec.LokiStackSize
125125
}
126+
127+
// Build limits spec only if retention is enabled (lokiRetentionDays > 0)
128+
var limitsSpec *lokistackv1.LimitsSpec
129+
if instance.Spec.LokiRetentionDays > 0 {
130+
limitsSpec = &lokistackv1.LimitsSpec{
131+
Global: &lokistackv1.LimitsTemplateSpec{
132+
Retention: &lokistackv1.RetentionLimitSpec{
133+
Days: instance.Spec.LokiRetentionDays,
134+
},
135+
},
136+
}
137+
}
138+
126139
lokiStack := &lokistackv1.LokiStack{
127140
ObjectMeta: metav1.ObjectMeta{
128141
Name: fmt.Sprintf("%s-lokistack", instance.Name),
@@ -135,6 +148,7 @@ func LokiStack(
135148
Size: lokistackv1.LokiStackSizeType(size),
136149
Storage: getLokiStackObjectStorageSpec(instance.Spec.S3StorageConfig),
137150
StorageClassName: instance.Spec.StorageClass,
151+
Limits: limitsSpec,
138152
Tenants: &lokistackv1.TenantsSpec{
139153
Mode: lokistackv1.Static,
140154
Authentication: []lokistackv1.AuthenticationSpec{

test/kuttl/tests/cloudkitty/02-deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ spec:
4949
secret: osp-secret
5050
serviceUser: cloudkitty
5151
storageClass: local-storage
52+
lokiRetentionDays: 0

test/kuttl/tests/cloudkitty/03-custom-config-secret.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ spec:
6161
secret: osp-secret
6262
serviceUser: cloudkitty
6363
storageClass: local-storage
64+
lokiRetentionDays: 0

test/kuttl/tests/default/01-deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ spec:
3535
name: logging-loki-s3
3636
type: s3
3737
storageClass: local-storage
38+
lokiRetentionDays: 0
3839
logging:
3940
enabled: false
4041
port: 10514

test/kuttl/tests/tls/02-deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ metadata:
5555
name: telemetry-kuttl-cloudkitty
5656
spec:
5757
enabled: true
58+
lokiRetentionDays: 0
5859
s3StorageConfig:
5960
schemas:
6061
- effectiveDate: "2024-11-18"

0 commit comments

Comments
 (0)