diff --git a/api/v1alpha1/observatorium_types.go b/api/v1alpha1/observatorium_types.go index e4847b69..b1f5f6bb 100644 --- a/api/v1alpha1/observatorium_types.go +++ b/api/v1alpha1/observatorium_types.go @@ -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"` } // ObservatoriumStatus defines the observed state of Observatorium diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 1c6c71d9..1676ed88 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -166,6 +166,46 @@ func (in *LokiObjectStorageConfigSpec) DeepCopy() *LokiObjectStorageConfigSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LokiResourcesSpec) DeepCopyInto(out *LokiResourcesSpec) { + *out = *in + if in.Compactor != nil { + in, out := &in.Compactor, &out.Compactor + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Distributor != nil { + in, out := &in.Distributor, &out.Distributor + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Ingester != nil { + in, out := &in.Ingester, &out.Ingester + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Querier != nil { + in, out := &in.Querier, &out.Querier + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.QueryFrontend != nil { + in, out := &in.QueryFrontend, &out.QueryFrontend + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LokiResourcesSpec. +func (in *LokiResourcesSpec) DeepCopy() *LokiResourcesSpec { + if in == nil { + return nil + } + out := new(LokiResourcesSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LokiSpec) DeepCopyInto(out *LokiSpec) { *out = *in @@ -177,6 +217,11 @@ func (in *LokiSpec) DeepCopyInto(out *LokiSpec) { } } in.VolumeClaimTemplate.DeepCopyInto(&out.VolumeClaimTemplate) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(LokiResourcesSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LokiSpec. diff --git a/example/main.jsonnet b/example/main.jsonnet index 1d7fb671..cdb97004 100644 --- a/example/main.jsonnet +++ b/example/main.jsonnet @@ -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, }, diff --git a/example/manifests/observatorium.yaml b/example/manifests/observatorium.yaml index bc7b9c5e..247d695e 100644 --- a/example/manifests/observatorium.yaml +++ b/example/manifests/observatorium.yaml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/jsonnet/obs-operator.jsonnet b/jsonnet/obs-operator.jsonnet index b9ae7150..1b605ded 100644 --- a/jsonnet/obs-operator.jsonnet +++ b/jsonnet/obs-operator.jsonnet @@ -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 {}, diff --git a/manifests/crds/core.observatorium.io_observatoria.yaml b/manifests/crds/core.observatorium.io_observatoria.yaml index c1736d82..bfd538cd 100644 --- a/manifests/crds/core.observatorium.io_observatoria.yaml +++ b/manifests/crds/core.observatorium.io_observatoria.yaml @@ -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