Skip to content

Commit

Permalink
Make Loki Compute resources configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Sanmukhani committed May 21, 2021
1 parent 78fff4b commit 5b90971
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 32 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/observatorium_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ type LokiSpec struct {
Version string `json:"version,omitempty"`
// VolumeClaimTemplate
VolumeClaimTemplate VolumeClaimTemplate `json:"volumeClaimTemplate"`
// Compute Resources required by each component containers.
// +optional
Resources map[string]v1.ResourceRequirements `json:"resources,omitempty"`
}

// ObservatoriumStatus defines the observed state of Observatorium
Expand Down
7 changes: 7 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.

5 changes: 3 additions & 2 deletions example/main.jsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local obs = (import 'github.com/observatorium/deployments/components/observatorium.libsonnet');
local obs = (import 'github.com/4n4nd/observatorium/configuration/components/observatorium.libsonnet');

local dex = (import 'github.com/observatorium/deployments/components/dex.libsonnet')({
local dex = (import 'github.com/4n4nd/observatorium/configuration/components/dex.libsonnet')({
local cfg = self,
name: 'dex',
namespace: 'dex',
Expand Down 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: 200m
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
distributor:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
ingester:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
querier:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
query_frontend:
limits:
cpu: 200m
memory: 200Mi
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
4 changes: 2 additions & 2 deletions jsonnet/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
{
"source": {
"git": {
"remote": "https://github.com/observatorium/observatorium.git",
"remote": "https://github.com/4n4nd/observatorium.git",
"subdir": "configuration"
}
},
"version": "main"
"version": "update-loki-resources"
}
],
"legacyImports": true
Expand Down
18 changes: 9 additions & 9 deletions jsonnet/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
{
"source": {
"git": {
"remote": "https://github.com/observatorium/api.git",
"subdir": "jsonnet/lib"
"remote": "https://github.com/4n4nd/observatorium.git",
"subdir": "configuration"
}
},
"version": "cbff1da9ba9371516a6254db359ae33545aefdf7",
"sum": "Z86CgnoTybhpdQKWc2ptURmps1d9Qxhec0/IK6v71kY=",
"name": "observatorium-api"
"version": "20e7404ce136862ea587b7e1799619a7ba7333be",
"sum": "DWWnTMgW80vFSB//tJRqux0tHfthyBfRFi1DA1glU4k="
},
{
"source": {
"git": {
"remote": "https://github.com/observatorium/observatorium.git",
"subdir": "configuration"
"remote": "https://github.com/observatorium/api.git",
"subdir": "jsonnet/lib"
}
},
"version": "8f5144ea1f8d86bce5e0b5ab7186f2b882f544dd",
"sum": "JJw7XVf0i3iBxjHrs/AgMQCVdNQgT6RlETcgVdSYUuk="
"version": "cbff1da9ba9371516a6254db359ae33545aefdf7",
"sum": "Z86CgnoTybhpdQKWc2ptURmps1d9Qxhec0/IK6v71kY=",
"name": "observatorium-api"
},
{
"source": {
Expand Down
7 changes: 4 additions & 3 deletions jsonnet/obs-operator.jsonnet
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
local cr = import 'generic-operator/config';
local thanos = (import 'github.com/observatorium/observatorium/configuration/components/thanos.libsonnet');
local loki = (import 'github.com/observatorium/observatorium/configuration/components/loki.libsonnet');
local thanos = (import 'github.com/4n4nd/observatorium/configuration/components/thanos.libsonnet');
local loki = (import 'github.com/4n4nd/observatorium/configuration/components/loki.libsonnet');
local api = (import 'github.com/observatorium/api/jsonnet/lib/observatorium-api.libsonnet');
local obs = (import 'github.com/observatorium/observatorium/configuration/components/observatorium.libsonnet');
local obs = (import 'github.com/4n4nd/observatorium/configuration/components/observatorium.libsonnet');

local operatorObs = obs {

Expand Down Expand Up @@ -68,6 +68,7 @@ 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 cr.spec.loki.resources else obs.loki.config.resources,
objectStorageConfig: if cr.spec.objectStorageConfig.loki != null then cr.spec.objectStorageConfig.loki else obs.loki.config.objectStorageConfig,
}) else {},

Expand Down
25 changes: 25 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,31 @@ spec:
type: integer
description: Loki replicas per component
type: object
resources:
additionalProperties:
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
description: Compute Resources required by each component containers.
type: object
version:
description: Version of Loki image to be deployed
type: string
Expand Down

0 comments on commit 5b90971

Please sign in to comment.