Skip to content

Commit

Permalink
Support configure annotations (observatorium#70)
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 authored Mar 7, 2022
1 parent 4093e6d commit f9eb849
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/v1alpha1/observatorium_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ type ReceiversSpec struct {
// How long to retain raw samples on local storage
// +optional
Retention string `json:"retention,omitempty"`
// Annotations is an unstructured key value map stored with a service account
// +optional
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
}

type StoreSpec struct {
Expand All @@ -166,6 +169,9 @@ type StoreSpec struct {
// ServiceMonitor enables servicemonitor.
// +optional
ServiceMonitor bool `json:"serviceMonitor,omitempty"`
// Annotations is an unstructured key value map stored with a service account
// +optional
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
}

// MemCacheSpec describes configuration for Store Memcached
Expand Down Expand Up @@ -353,6 +359,9 @@ type QuerySpec struct {
// The maximum lookback duration for retrieving metrics during expression evaluations.
// +optional
LookbackDelta string `json:"lookbackDelta,omitempty"`
// Annotations is an unstructured key value map stored with a service account
// +optional
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
}

type RuleConfig struct {
Expand Down Expand Up @@ -428,6 +437,9 @@ type RuleSpec struct {
// Evaluation interval
// +optional
EvalInterval string `json:"evalInterval,omitempty"`
// Annotations is an unstructured key value map stored with a service account
// +optional
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
}

type CompactSpec struct {
Expand All @@ -452,6 +464,8 @@ type CompactSpec struct {
// Time before a block marked for deletion is deleted from bucket
// +optional
DeleteDelay string `json:"deleteDelay,omitempty"`
// Annotations is an unstructured key value map stored with a service account
ServiceAccountAnnotations map[string]string `json:"serviceAccountAnnotations,omitempty"`
}

type VolumeClaimTemplate struct {
Expand Down
35 changes: 35 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.

20 changes: 20 additions & 0 deletions jsonnet/obs-operator.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ local operatorObs = obs {
if (v.kind == 'StatefulSet' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-query-frontend-memcached')) then {
name: 'observability-thanos-query-frontend-memcached',
} else {}
) + (
if (std.objectHas(cr.spec.thanos.compact, 'serviceAccountAnnotations') && v.kind == 'ServiceAccount' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-compact')) then {
annotations+: cr.spec.thanos.compact.serviceAccountAnnotations,
} else {}
) + (
if (std.objectHas(cr.spec.thanos.query, 'serviceAccountAnnotations') && v.kind == 'ServiceAccount' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-query')) then {
annotations+: cr.spec.thanos.query.serviceAccountAnnotations,
} else {}
) + (
if (std.objectHas(cr.spec.thanos.store, 'serviceAccountAnnotations') && v.kind == 'ServiceAccount' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-store-shard')) then {
annotations+: cr.spec.thanos.store.serviceAccountAnnotations,
} else {}
) + (
if (std.objectHas(cr.spec.thanos.receivers, 'serviceAccountAnnotations') && v.kind == 'ServiceAccount' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-receive')) then {
annotations+: cr.spec.thanos.store.serviceAccountAnnotations,
} else {}
) + (
if (std.objectHas(cr.spec.thanos.rule, 'serviceAccountAnnotations') && v.kind == 'ServiceAccount' && std.startsWith(v.metadata.name, cr.metadata.name + '-thanos-rule')) then {
annotations+: cr.spec.thanos.store.serviceAccountAnnotations,
} else {}
),
spec+: (
if (std.objectHas(cr.spec, 'nodeSelector') && (v.kind == 'StatefulSet' || v.kind == 'Deployment')) then {
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 @@ -901,6 +901,11 @@ spec:
retentionResolutionRaw:
description: RetentionResolutionRaw
type: string
serviceAccountAnnotations:
additionalProperties:
type: string
description: Annotations is an unstructured key value map stored with a service account
type: object
serviceMonitor:
description: ServiceMonitor enables servicemonitor.
type: boolean
Expand Down Expand Up @@ -1040,6 +1045,11 @@ spec:
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
serviceAccountAnnotations:
additionalProperties:
type: string
description: Annotations is an unstructured key value map stored with a service account
type: object
serviceMonitor:
description: ServiceMonitor enables servicemonitor.
type: boolean
Expand Down Expand Up @@ -1235,6 +1245,11 @@ spec:
retention:
description: How long to retain raw samples on local storage
type: string
serviceAccountAnnotations:
additionalProperties:
type: string
description: Annotations is an unstructured key value map stored with a service account
type: object
serviceMonitor:
description: ServiceMonitor enables servicemonitor.
type: boolean
Expand Down Expand Up @@ -1455,6 +1470,11 @@ spec:
- name
type: object
type: array
serviceAccountAnnotations:
additionalProperties:
type: string
description: Annotations is an unstructured key value map stored with a service account
type: object
serviceMonitor:
description: ServiceMonitor enables servicemonitor.
type: boolean
Expand Down Expand Up @@ -1662,6 +1682,11 @@ spec:
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
serviceAccountAnnotations:
additionalProperties:
type: string
description: Annotations is an unstructured key value map stored with a service account
type: object
serviceMonitor:
description: ServiceMonitor enables servicemonitor.
type: boolean
Expand Down

0 comments on commit f9eb849

Please sign in to comment.