Skip to content

Commit

Permalink
Support configure replicas for each component
Browse files Browse the repository at this point in the history
  • Loading branch information
clyang82 committed Sep 15, 2020
1 parent 2d9cb6e commit e9d7ea7
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
10 changes: 10 additions & 0 deletions api/v1alpha1/observatorium_types.go
Expand Up @@ -94,6 +94,8 @@ type ThanosReceiveControllerSpec struct {
type ReceiversSpec struct {
// Thanos image
Image string `json:"image,omitempty"`
// Number of Receiver replicas.
Replicas *int32 `json:"replicas,omitempty"`
// Version of Thanos image to be deployed.
Version string `json:"version,omitempty"`
// VolumeClaimTemplate
Expand Down Expand Up @@ -230,6 +232,8 @@ type TLS struct {
type APISpec struct {
// API image
Image string `json:"image,omitempty"`
// Number of API replicas.
Replicas *int32 `json:"replicas,omitempty"`
// Version describes the version of API to use.
Version string `json:"version,omitempty"`
// TLS configuration for the Observatorium API.
Expand All @@ -250,13 +254,17 @@ type APIQuerySpec struct {
type QuerySpec struct {
// Thanos image
Image string `json:"image,omitempty"`
// Number of Query replicas.
Replicas *int32 `json:"replicas,omitempty"`
// Version of Thanos image to be deployed.
Version string `json:"version,omitempty"`
}

type RuleSpec struct {
// Thanos image
Image string `json:"image,omitempty"`
// Number of Rule replicas.
Replicas *int32 `json:"replicas,omitempty"`
// Version of Thanos image to be deployed.
Version string `json:"version,omitempty"`
// VolumeClaimTemplate
Expand All @@ -266,6 +274,8 @@ type RuleSpec struct {
type CompactSpec struct {
// Thanos image
Image string `json:"image,omitempty"`
// Number of Compact replicas.
Replicas *int32 `json:"replicas,omitempty"`
// Version of Thanos image to be deployed.
Version string `json:"version,omitempty"`
// VolumeClaimTemplate
Expand Down
27 changes: 26 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions example/main.jsonnet
Expand Up @@ -53,6 +53,7 @@ local obs = (import 'github.com/observatorium/deployments/environments/base/obse
queryFrontend: {
image: obs.config.thanosImage,
version: obs.config.thanosVersion,
replicas: obs.config.queryFrontend.replicas,
},
store: {
image: obs.config.thanosImage,
Expand All @@ -76,23 +77,27 @@ local obs = (import 'github.com/observatorium/deployments/environments/base/obse
retentionResolution5m: obs.config.compact.retentionResolution5m,
retentionResolution1h: obs.config.compact.retentionResolution1h,
enableDownsampling: obs.config.compact.enableDownsampling,
replicas: obs.config.compact.replicas,
},
rule: {
image: obs.config.thanosImage,
version: obs.config.thanosVersion,
volumeClaimTemplate: obs.config.rule.volumeClaimTemplate,
replicas: obs.config.rule.replicas,
},
receivers: {
image: obs.config.thanosImage,
version: obs.config.thanosVersion,
volumeClaimTemplate: obs.config.receivers.volumeClaimTemplate,
replicas: obs.config.receivers.replicas,
},
thanosReceiveController: {
image: obs.config.thanosReceiveController.image,
version: obs.config.thanosReceiveController.version,
},
api: {
image: obs.config.api.image,
replicas: obs.config.api.replicas,
version: obs.config.api.version,
rbac: {
roles: [
Expand Down Expand Up @@ -161,6 +166,7 @@ local obs = (import 'github.com/observatorium/deployments/environments/base/obse
query: {
image: obs.config.thanosImage,
version: obs.config.thanosVersion,
replicas: obs.config.query.replicas,
},
loki: {
image: obs.config.loki.image,
Expand Down
6 changes: 6 additions & 0 deletions example/manifests/observatorium.yaml
Expand Up @@ -27,6 +27,7 @@ spec:
- metrics
tenants:
- test
replicas: 1
tenants:
- id: 1610b0c3-c509-4592-a256-a1871353dbfa
name: test
Expand All @@ -49,6 +50,7 @@ spec:
compact:
enableDownsampling: false
image: quay.io/thanos/thanos:master-2020-08-12-70f89d83
replicas: 1
retentionResolution1h: 1s
retentionResolution5m: 1s
retentionResolutionRaw: 14d
Expand Down Expand Up @@ -92,12 +94,15 @@ spec:
name: thanos-objectstorage
query:
image: quay.io/thanos/thanos:master-2020-08-12-70f89d83
replicas: 1
version: master-2020-08-12-70f89d83
queryFrontend:
image: quay.io/thanos/thanos:master-2020-08-12-70f89d83
replicas: 1
version: master-2020-08-12-70f89d83
receivers:
image: quay.io/thanos/thanos:master-2020-08-12-70f89d83
replicas: 1
version: master-2020-08-12-70f89d83
volumeClaimTemplate:
spec:
Expand All @@ -108,6 +113,7 @@ spec:
storage: 50Gi
rule:
image: quay.io/thanos/thanos:master-2020-08-12-70f89d83
replicas: 1
version: master-2020-08-12-70f89d83
volumeClaimTemplate:
spec:
Expand Down
8 changes: 7 additions & 1 deletion jsonnet/operator-config.libsonnet
@@ -1,4 +1,4 @@
local default = import 'default-config.libsonnet';
local default = import 'github.com/observatorium/environments/base/default-config.libsonnet';
local cr = import 'generic-operator/config';
local objectStorageConfig = cr.spec.objectStorageConfig;
local thanosObjectStorageConfig = objectStorageConfig.thanos;
Expand All @@ -15,6 +15,7 @@ cr.spec {
version: if std.objectHas(cr.spec.compact, 'version') then cr.spec.compact.version else default.compact.version,
objectStorageConfig: thanosObjectStorageConfig,
logLevel: 'info',
replicas: if std.objectHas(cr.spec.compact, 'replicas') then cr.spec.compact.replicas else default.compact.replicas,
},
thanosReceiveController+:: {
image: if std.objectHas(cr.spec, 'thanosReceiveController') && std.objectHas(cr.spec.thanosReceiveController, 'image') then cr.spec.thanosReceiveController.image else default.thanosReceiveController.image,
Expand All @@ -26,12 +27,14 @@ cr.spec {
version: if std.objectHas(cr.spec.receivers, 'version') then cr.spec.receivers.version else default.receivers.version,
hashrings: hashrings,
objectStorageConfig: thanosObjectStorageConfig,
replicas: if std.objectHas(cr.spec.receivers, 'replicas') then cr.spec.receivers.replicas else default.receivers.replicas,
logLevel: 'info',
debug: '',
},
rule+:: {
image: if std.objectHas(cr.spec.rule, 'image') then cr.spec.rule.image else default.rule.image,
version: if std.objectHas(cr.spec.rule, 'version') then cr.spec.rule.version else default.rule.version,
replicas: if std.objectHas(cr.spec.rule, 'replicas') then cr.spec.rule.replicas else default.rule.replicas,
objectStorageConfig: thanosObjectStorageConfig,
},
store+:: {
Expand All @@ -51,10 +54,12 @@ cr.spec {
query+:: {
image: if std.objectHas(cr.spec, 'query') && std.objectHas(cr.spec.query, 'image') then cr.spec.query.image else default.query.image,
version: if std.objectHas(cr.spec, 'query') && std.objectHas(cr.spec.query, 'version') then cr.spec.query.version else default.query.version,
replicas: if std.objectHas(cr.spec, 'query') && std.objectHas(cr.spec.query, 'replicas') then cr.spec.query.replicas else default.query.replicas,
},
queryFrontend+:: {
image: if std.objectHas(cr.spec, 'queryFrontend') && std.objectHas(cr.spec.queryFrontend, 'image') then cr.spec.queryFrontend.image else default.queryFrontend.image,
version: if std.objectHas(cr.spec, 'queryFrontend') && std.objectHas(cr.spec.queryFrontend, 'version') then cr.spec.queryFrontend.version else default.queryFrontend.version,
replicas: if std.objectHas(cr.spec, 'queryFrontend') && std.objectHas(cr.spec.queryFrontend, 'replicas') then cr.spec.queryFrontend.replicas else default.queryFrontend.replicas,
},
apiQuery+:: {
image: if std.objectHas(cr.spec, 'apiQuery') && std.objectHas(cr.spec.apiQuery, 'image') then cr.spec.apiQuery.image else default.apiQuery.image,
Expand All @@ -66,6 +71,7 @@ cr.spec {
rbac: if std.objectHas(cr.spec, 'api') && std.objectHas(cr.spec.api, 'rbac') then cr.spec.api.rbac else default.api.rbac,
tenants: if std.objectHas(cr.spec, 'api') && std.objectHas(cr.spec.api, 'tenants') then { tenants: cr.spec.api.tenants } else default.api.tenants,
tls: if std.objectHas(cr.spec, 'api') && std.objectHas(cr.spec.api, 'tls') then cr.spec.api.tls else {},
replicas: if std.objectHas(cr.spec, 'api') && std.objectHas(cr.spec.api, 'replicas') then cr.spec.api.replicas else default.api.replicas,
},
loki+:: if std.objectHas(cr.spec, 'loki') then {
image: if std.objectHas(cr.spec.loki, 'image') then cr.spec.loki.image else default.loki.image,
Expand Down
20 changes: 20 additions & 0 deletions manifests/crds/core.observatorium.io_observatoria.yaml
Expand Up @@ -124,6 +124,10 @@ spec:
- roleBindings
- roles
type: object
replicas:
description: Number of API replicas.
format: int32
type: integer
tenants:
description: Tenants is a slice of tenants for the Observatorium
API.
Expand Down Expand Up @@ -219,6 +223,10 @@ spec:
image:
description: Thanos image
type: string
replicas:
description: Number of Compact replicas.
format: int32
type: integer
retentionResolution1h:
description: RetentionResolutionRaw
type: string
Expand Down Expand Up @@ -595,6 +603,10 @@ spec:
image:
description: Thanos image
type: string
replicas:
description: Number of Query replicas.
format: int32
type: integer
version:
description: Version of Thanos image to be deployed.
type: string
Expand All @@ -619,6 +631,10 @@ spec:
image:
description: Thanos image
type: string
replicas:
description: Number of Receiver replicas.
format: int32
type: integer
version:
description: Version of Thanos image to be deployed.
type: string
Expand Down Expand Up @@ -768,6 +784,10 @@ spec:
image:
description: Thanos image
type: string
replicas:
description: Number of Rule replicas.
format: int32
type: integer
version:
description: Version of Thanos image to be deployed.
type: string
Expand Down

0 comments on commit e9d7ea7

Please sign in to comment.