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

[WIP] Make Loki Compute resources configurable #72

Closed
Closed
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
11 changes: 11 additions & 0 deletions api/v1alpha1/observatorium_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ type LokiSpec struct {
Version string `json:"version,omitempty"`
// VolumeClaimTemplate
VolumeClaimTemplate VolumeClaimTemplate `json:"volumeClaimTemplate"`
// Compute Resources required by each component containers.
// +optional
Resources *LokiResourcesSpec `json:"resources,omitempty"`
}

type LokiResourcesSpec struct {
Compactor *v1.ResourceRequirements `json:"compactor,omitempty"`
Distributor *v1.ResourceRequirements `json:"distributor,omitempty"`
Ingester *v1.ResourceRequirements `json:"ingester,omitempty"`
Querier *v1.ResourceRequirements `json:"querier,omitempty"`
QueryFrontend *v1.ResourceRequirements `json:"query_frontend,omitempty"`
Comment on lines +383 to +391

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on the observatorium/observatorium#411 PR, this needs to slightly change to:

type LokiSpec struct {
    Components *LokiComponentsSpec
}

type LokiComponentsSpec struct {
    Compactor *LokiComponentSpec
    ...
}
type LokiComponentSpec {
   Resources *v1.ResourceRequirements `json:"resources,omitempty"`
}

}

// ObservatoriumStatus defines the observed state of Observatorium
Expand Down
45 changes: 45 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions example/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ local dex = (import 'github.com/observatorium/deployments/components/dex.libsonn
loki: {
image: obs.loki.config.image,
replicas: obs.loki.config.replicas,
resources: obs.loki.config.resources,
version: obs.loki.config.version,
volumeClaimTemplate: obs.loki.config.volumeClaimTemplate,
},
Expand Down
68 changes: 52 additions & 16 deletions example/manifests/observatorium.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ spec:
secretName: observatorium-xyz-tls
version: master-2020-11-02-v0.1.1-192-ge324057
apiQuery:
image: quay.io/thanos/thanos:v0.17.1
version: v0.17.1
image: quay.io/thanos/thanos:v0.20.1
version: v0.20.1
compact:
enableDownsampling: false
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
replicas: 1
retentionResolution1h: 1s
retentionResolution5m: 1s
retentionResolutionRaw: 14d
version: v0.17.1
version: v0.20.1
volumeClaimTemplate:
spec:
accessModes:
Expand All @@ -68,14 +68,50 @@ spec:
- hashring: default
tenants: []
loki:
image: docker.io/grafana/loki:2.1.0
image: docker.io/grafana/loki:2.2.0
replicas:
compactor: 1
distributor: 1
ingester: 1
querier: 1
query_frontend: 1
version: 2.1.0
resources:
compactor:
limits:
cpu: 2000m
memory: 2000Mi
requests:
cpu: 100m
memory: 100Mi
distributor:
limits:
cpu: 2000m
memory: 2000Mi
requests:
cpu: 100m
memory: 100Mi
ingester:
limits:
cpu: 2000m
memory: 2000Mi
requests:
cpu: 100m
memory: 100Mi
querier:
limits:
cpu: 2000m
memory: 2000Mi
requests:
cpu: 100m
memory: 100Mi
query_frontend:
limits:
cpu: 2000m
memory: 2000Mi
requests:
cpu: 100m
memory: 100Mi
version: 2.2.0
volumeClaimTemplate:
spec:
accessModes:
Expand All @@ -95,17 +131,17 @@ spec:
key: thanos.yaml
name: thanos-objectstorage
query:
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
replicas: 1
version: v0.17.1
version: v0.20.1
queryFrontend:
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
replicas: 1
version: v0.17.1
version: v0.20.1
receivers:
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
replicas: 1
version: v0.17.1
version: v0.20.1
volumeClaimTemplate:
spec:
accessModes:
Expand All @@ -114,9 +150,9 @@ spec:
requests:
storage: 50Gi
rule:
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
replicas: 1
version: v0.17.1
version: v0.20.1
volumeClaimTemplate:
spec:
accessModes:
Expand All @@ -135,9 +171,9 @@ spec:
memoryLimitMb: 1024
replicas: 1
version: 1.6.3-alpine
image: quay.io/thanos/thanos:v0.17.1
image: quay.io/thanos/thanos:v0.20.1
shards: 1
version: v0.17.1
version: v0.20.1
volumeClaimTemplate:
spec:
accessModes:
Expand Down
7 changes: 7 additions & 0 deletions jsonnet/obs-operator.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ local operatorObs = obs {
image: if std.objectHas(cr.spec.loki, 'image') then cr.spec.loki.image else obs.loki.config.image,
replicas: if std.objectHas(cr.spec.loki, 'replicas') then cr.spec.loki.replicas else obs.loki.config.replicas,
version: if std.objectHas(cr.spec.loki, 'version') then cr.spec.loki.version else obs.loki.config.version,
resources: if std.objectHas(cr.spec.loki, 'resources') then {
compactor: if std.objectHas(cr.spec.loki.resources, 'compactor') then cr.spec.loki.resources.compactor else obs.loki.config.resources.compactor,
distributor: if std.objectHas(cr.spec.loki.resources, 'distributor') then cr.spec.loki.resources.distributor else obs.loki.config.resources.distributor,
ingester: if std.objectHas(cr.spec.loki.resources, 'ingester') then cr.spec.loki.resources.ingester else obs.loki.config.resources.ingester,
querier: if std.objectHas(cr.spec.loki.resources, 'querier') then cr.spec.loki.resources.querier else obs.loki.config.resources.querier,
query_frontend: if std.objectHas(cr.spec.loki.resources, 'query_frontend') then cr.spec.loki.resources.query_frontend else obs.loki.config.resources.query_frontend,
} else {},
objectStorageConfig: if cr.spec.objectStorageConfig.loki != null then cr.spec.objectStorageConfig.loki else obs.loki.config.objectStorageConfig,
}) else {},

Expand Down
114 changes: 114 additions & 0 deletions manifests/crds/core.observatorium.io_observatoria.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,120 @@ spec:
type: integer
description: Loki replicas per component
type: object
resources:
description: Compute Resources required by each component containers.
properties:
compactor:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
distributor:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
ingester:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
querier:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
query_frontend:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
type: object
version:
description: Version of Loki image to be deployed
type: string
Expand Down