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

operator: Add automatic stream sharding support #11091

Merged
merged 22 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c937d89
Add field desiredRate to LimitsTemplateSpec
periklis Oct 31, 2023
17908d8
Add validation for desiredRate field
periklis Oct 31, 2023
4098203
Replace defaults per-stream-rate limits with desired rate
periklis Oct 31, 2023
e8d74df
Add config rendering for desiredRate
periklis Oct 31, 2023
2a24330
Update API docs
periklis Oct 31, 2023
096c6d2
Add changelog entry
periklis Oct 31, 2023
092bd15
Apply suggestions from code review
periklis Oct 31, 2023
56c39f6
Address code review suggestions
periklis Oct 31, 2023
d4e2b23
Address code review suggestions
periklis Oct 31, 2023
55a0376
Address code review suggestions
periklis Oct 31, 2023
dc013a1
Simplify validation
periklis Nov 2, 2023
f2b5666
Merge remote-tracking branch 'upstream/main' into operator-auto-strea…
periklis Nov 20, 2023
e022a27
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 20, 2023
0cce214
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 20, 2023
30dd998
Apply code review suggenstions
periklis Nov 21, 2023
9130cc7
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 21, 2023
b853b43
Regenerate manifests
periklis Nov 21, 2023
8cf9c35
Remove validation and default per-stream-rate-limit to 5MB
periklis Nov 21, 2023
c317919
Apply code review suggestions
periklis Nov 22, 2023
bfdd6cd
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 22, 2023
bb1eb7a
Merge branch 'main' into operator-auto-stream-sharding
periklis Nov 23, 2023
d1c2a82
Apply code review suggestions
periklis Nov 23, 2023
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
6 changes: 5 additions & 1 deletion operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Main

- [11091](https://github.com/grafana/loki/pull/11091) **periklis**: Add automatic stream sharding support

- [11022](https://github.com/grafana/loki/pull/11022) **JoaoBraveCoding**: Remove outdated BoltDB dashboards
- [10932](https://github.com/grafana/loki/pull/10932) **JoaoBraveCoding**: Adds new value v13 to schema
- [11232](https://github.com/grafana/loki/pull/11232) **periklis**: Update dependencies and dev tools
- [11129](https://github.com/grafana/loki/pull/11129) **periklis**: Update deps to secure webhooks for CVE-2023-44487
-
## 0.5.0 (2023-10-24)

- [10924](https://github.com/grafana/loki/pull/10924) **periklis**: Update Loki operand to v2.9.2
Expand Down
4 changes: 2 additions & 2 deletions operator/apis/loki/v1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,11 @@ type QueryLimitSpec struct {
// IngestionLimitSpec defines the limits applied at the ingestion path.
type IngestionLimitSpec struct {
// DesiredRate defines the desired ingestion rate per second that LokiStack should
// target applyfing automatic stream sharding. Units Bytes.
// target applying automatic stream sharding. Unit MB.
periklis marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:number",displayName="Desired Ingestion Rate (in Bytes)"
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:number",displayName="Desired Ingestion Rate (in MB)"
DesiredRate int32 `json:"desiredRate,omitempty"`
xperimental marked this conversation as resolved.
Show resolved Hide resolved
periklis marked this conversation as resolved.
Show resolved Hide resolved

// IngestionRate defines the sample size per second. Units MB.
Expand Down
2 changes: 1 addition & 1 deletion operator/apis/loki/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var (
ErrReplicationSpecConflict = errors.New("replicationSpec and replicationFactor (deprecated) cannot be used at the same time")
// ErrIPv6InstanceAddrTypeNotAllowed when the default InstanceAddrType is used with enableIPv6.
ErrIPv6InstanceAddrTypeNotAllowed = errors.New(`instanceAddrType "default" cannot be used with enableIPv6 at the same time`)
// ErrDesiredRateAndPerStreamRateNotAllowed when both fields are set.
// ErrDesiredRateAndPerStreamRateNotAllowed when there's a conflict in the rate limiting configuration because both desiredRate and perStreamRateLimit are set.
ErrDesiredRateAndPerStreamRateNotAllowed = errors.New("fields desiredRate and perStreamRateLimit cannot be used together")
DylanGuedes marked this conversation as resolved.
Show resolved Hide resolved
periklis marked this conversation as resolved.
Show resolved Hide resolved

// ErrRuleMustMatchNamespace indicates that an expression used in an alerting or recording rule is missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.5.0
createdAt: "2023-10-31T08:47:51Z"
createdAt: "2023-11-03T11:44:16Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
operators.operatorframework.io/builder: operator-sdk-unknown
Expand Down Expand Up @@ -295,8 +295,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -385,8 +385,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down Expand Up @@ -231,8 +231,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: docker.io/grafana/loki-operator:0.5.0
createdAt: "2023-10-31T08:47:49Z"
createdAt: "2023-11-03T11:44:14Z"
description: The Community Loki Operator provides Kubernetes native deployment
and management of Loki and related logging components.
operators.operatorframework.io/builder: operator-sdk-unknown
Expand Down Expand Up @@ -295,8 +295,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -385,8 +385,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down Expand Up @@ -231,8 +231,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ metadata:
categories: OpenShift Optional, Logging & Tracing
certified: "false"
containerImage: quay.io/openshift-logging/loki-operator:0.1.0
createdAt: "2023-10-31T08:47:54Z"
createdAt: "2023-11-03T11:44:18Z"
description: |
The Loki Operator for OCP provides a means for configuring and managing a Loki stack for cluster logging.
## Prerequisites and Requirements
Expand Down Expand Up @@ -308,8 +308,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -398,8 +398,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down Expand Up @@ -231,8 +231,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down
8 changes: 4 additions & 4 deletions operator/config/crd/bases/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down Expand Up @@ -213,8 +213,8 @@ spec:
properties:
desiredRate:
description: DesiredRate defines the desired ingestion
rate per second that LokiStack should target applyfing
automatic stream sharding. Units Bytes.
rate per second that LokiStack should target applying
automatic stream sharding. Unit MB.
format: int32
type: integer
ingestionBurstSize:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -298,8 +298,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -298,8 +298,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ spec:
displayName: Global Limits
path: limits.global
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.global.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down Expand Up @@ -310,8 +310,8 @@ spec:
displayName: Limits per Tenant
path: limits.tenants
- description: DesiredRate defines the desired ingestion rate per second that
LokiStack should target applyfing automatic stream sharding. Units Bytes.
displayName: Desired Ingestion Rate (in Bytes)
LokiStack should target applying automatic stream sharding. Unit MB.
displayName: Desired Ingestion Rate (in MB)
path: limits.tenants.ingestion.desiredRate
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
Expand Down
2 changes: 1 addition & 1 deletion operator/docs/operator/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ int32
<td>
<em>(Optional)</em>
<p>DesiredRate defines the desired ingestion rate per second that LokiStack should
target applyfing automatic stream sharding. Units Bytes.</p>
target applying automatic stream sharding. Unit MB.</p>
</td>
</tr>
<tr>
Expand Down
8 changes: 7 additions & 1 deletion operator/internal/manifests/internal/config/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ var (
//go:embed loki-runtime-config.yaml
lokiRuntimeConfigYAMLTmplFile embed.FS

lokiConfigYAMLTmpl = template.Must(template.ParseFS(lokiConfigYAMLTmplFile, "loki-config.yaml"))
lokiConfigYAMLTmpl = template.Must(template.New("loki-config.yaml").Funcs(template.FuncMap{
"toBytes": toBytes,
}).ParseFS(lokiConfigYAMLTmplFile, "loki-config.yaml"))

lokiRuntimeConfigYAMLTmpl = template.Must(template.ParseFS(lokiRuntimeConfigYAMLTmplFile, "loki-runtime-config.yaml"))
)
Expand Down Expand Up @@ -54,3 +56,7 @@ func Build(opts Options) ([]byte, []byte, error) {
}
return cfg, rcfg, nil
}

func toBytes(s int32) int32 {
return int32(float32(s) * (1 << 20))
periklis marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading