1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 11:48:53 +00:00

thanos: remove deprecated features and require v0.4.0+

This commit is contained in:
Andy Bursavich 2019-06-05 11:43:01 -07:00
parent 4995f63cc4
commit 901346bd55
14 changed files with 131 additions and 650 deletions

View file

@ -41,8 +41,6 @@ This Document documents the types introduced by the Prometheus Operator to be co
* [ServiceMonitorSpec](#servicemonitorspec)
* [StorageSpec](#storagespec)
* [TLSConfig](#tlsconfig)
* [ThanosGCSSpec](#thanosgcsspec)
* [ThanosS3Spec](#thanoss3spec)
* [ThanosSpec](#thanosspec)
## APIServerConfig
@ -522,50 +520,18 @@ TLSConfig specifies TLS configuration parameters.
[Back to TOC](#table-of-contents)
## ThanosGCSSpec
Deprecated: ThanosGCSSpec should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosGCSSpec will be removed.
| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| bucket | Google Cloud Storage bucket name for stored blocks. If empty it won't store any block inside Google Cloud Storage. | *string | false |
| credentials | Secret to access our Bucket. | *[v1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#secretkeyselector-v1-core) | false |
[Back to TOC](#table-of-contents)
## ThanosS3Spec
Deprecated: ThanosS3Spec should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosS3Spec will be removed.
| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| bucket | S3-Compatible API bucket name for stored blocks. | *string | false |
| endpoint | S3-Compatible API endpoint for stored blocks. | *string | false |
| accessKey | AccessKey for an S3-Compatible API. | *[v1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#secretkeyselector-v1-core) | false |
| secretKey | SecretKey for an S3-Compatible API. | *[v1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#secretkeyselector-v1-core) | false |
| insecure | Whether to use an insecure connection with an S3-Compatible API. | *bool | false |
| signatureVersion2 | Whether to use S3 Signature Version 2; otherwise Signature Version 4 will be used. | *bool | false |
| encryptsse | Whether to use Server Side Encryption | *bool | false |
[Back to TOC](#table-of-contents)
## ThanosSpec
ThanosSpec defines parameters for a Prometheus server within a Thanos deployment.
| Field | Description | Scheme | Required |
| ----- | ----------- | ------ | -------- |
| peers | Peers is a DNS name for Thanos to discover peers through. | *string | false |
| image | Image if specified has precedence over baseImage, tag and sha combinations. Specifying the version is still necessary to ensure the Prometheus Operator knows what version of Thanos is being configured. | *string | false |
| version | Version describes the version of Thanos to use. | *string | false |
| tag | Tag of Thanos sidecar container image to be deployed. Defaults to the value of `version`. Version is ignored if Tag is set. | *string | false |
| sha | SHA of Thanos container image to be deployed. Defaults to the value of `version`. Similar to a tag, but the SHA explicitly deploys an immutable container image. Version and Tag are ignored if SHA is set. | *string | false |
| baseImage | Thanos base image if other than default. | *string | false |
| resources | Resources defines the resource requirements for the Thanos sidecar. If not provided, no requests/limits will be set | [v1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#resourcerequirements-v1-core) | false |
| gcs | Deprecated: GCS should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. This field will be removed. | *[ThanosGCSSpec](#thanosgcsspec) | false |
| s3 | Deprecated: S3 should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. This field will be removed. | *[ThanosS3Spec](#thanoss3spec) | false |
| objectStorageConfig | ObjectStorageConfig configures object storage in Thanos. | *[v1.SecretKeySelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#secretkeyselector-v1-core) | false |
| grpcAdvertiseAddress | Explicit (external) host:port address to advertise for gRPC StoreAPI in gossip cluster. If empty, 'grpc-address' will be used. | *string | false |
| clusterAdvertiseAddress | Explicit (external) ip:port address to advertise for gossip in gossip cluster. Used internally for membership only. | *string | false |
[Back to TOC](#table-of-contents)

View file

@ -3219,42 +3219,6 @@ spec:
baseImage:
description: Thanos base image if other than default.
type: string
clusterAdvertiseAddress:
description: Explicit (external) ip:port address to advertise for
gossip in gossip cluster. Used internally for membership only.
type: string
gcs:
description: 'Deprecated: ThanosGCSSpec should be configured with
an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosGCSSpec
will be removed.'
properties:
bucket:
description: Google Cloud Storage bucket name for stored blocks.
If empty it won't store any block inside Google Cloud Storage.
type: string
credentials:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
optional:
description: Specify whether the Secret or it's key must
be defined
type: boolean
required:
- key
type: object
type: object
grpcAdvertiseAddress:
description: Explicit (external) host:port address to advertise
for gRPC StoreAPI in gossip cluster. If empty, 'grpc-address'
will be used.
type: string
image:
description: Image if specified has precedence over baseImage, tag
and sha combinations. Specifying the version is still necessary
@ -3278,9 +3242,6 @@ spec:
required:
- key
type: object
peers:
description: Peers is a DNS name for Thanos to discover peers through.
type: string
resources:
description: ResourceRequirements describes the compute resource
requirements.
@ -3296,63 +3257,6 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
s3:
description: 'Deprecated: ThanosS3Spec should be configured with
an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosS3Spec
will be removed.'
properties:
accessKey:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
optional:
description: Specify whether the Secret or it's key must
be defined
type: boolean
required:
- key
type: object
bucket:
description: S3-Compatible API bucket name for stored blocks.
type: string
encryptsse:
description: Whether to use Server Side Encryption
type: boolean
endpoint:
description: S3-Compatible API endpoint for stored blocks.
type: string
insecure:
description: Whether to use an insecure connection with an S3-Compatible
API.
type: boolean
secretKey:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
optional:
description: Specify whether the Secret or it's key must
be defined
type: boolean
required:
- key
type: object
signatureVersion2:
description: Whether to use S3 Signature Version 2; otherwise
Signature Version 4 will be used.
type: boolean
type: object
sha:
description: SHA of Thanos container image to be deployed. Defaults
to the value of `version`. Similar to a tag, but the SHA explicitly

View file

@ -5,9 +5,6 @@ metadata:
labels:
prometheus: self
spec:
podMetadata:
labels:
thanos-peer: 'true'
replicas: 2
serviceMonitorSelector:
matchLabels:
@ -17,4 +14,4 @@ spec:
role: prometheus-rulefiles
prometheus: k8s
thanos:
peers: thanos-peers.default.svc:10900
version: v0.4.0

View file

@ -4,31 +4,26 @@ metadata:
name: thanos-query
labels:
app: thanos-query
thanos-peer: "true"
spec:
replicas: 1
selector:
matchLabels:
app: thanos-query
thanos-peer: "true"
template:
metadata:
labels:
app: thanos-query
thanos-peer: "true"
spec:
containers:
- name: thanos-query
image: improbable/thanos:v0.1.0
image: improbable/thanos:v0.4.0
args:
- "query"
- "--log.level=debug"
- "--query.replica-label=prometheus_replica"
- "--cluster.peers=thanos-peers.default.svc:10900"
- query
- --log.level=debug
- --query.replica-label=prometheus_replica
- --store=dnssrv+_grpc._tcp.thanos-sidecar.default.svc.cluster.local
ports:
- name: http
containerPort: 10902
- name: grpc
containerPort: 10901
- name: cluster
containerPort: 10900

View file

@ -1,14 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: thanos-query
labels:
app: thanos-query
name: thanos-query
spec:
selector:
app: thanos-query
ports:
- port: 9090
protocol: TCP
- name: http
port: 9090
targetPort: http
name: http-query

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: thanos-sidecar
labels:
app: thanos-sidecar
spec:
clusterIP: None
selector:
prometheus: self
ports:
- name: grpc
port: 10901
targetPort: grpc

View file

@ -1,13 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: thanos-peers
spec:
type: ClusterIP
clusterIP: None
ports:
- name: cluster
port: 10900
targetPort: cluster
selector:
thanos-peer: "true"

File diff suppressed because one or more lines are too long

View file

@ -59,8 +59,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ServiceMonitorSpec": schema_pkg_apis_monitoring_v1_ServiceMonitorSpec(ref),
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.StorageSpec": schema_pkg_apis_monitoring_v1_StorageSpec(ref),
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.TLSConfig": schema_pkg_apis_monitoring_v1_TLSConfig(ref),
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosGCSSpec": schema_pkg_apis_monitoring_v1_ThanosGCSSpec(ref),
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosS3Spec": schema_pkg_apis_monitoring_v1_ThanosS3Spec(ref),
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosSpec": schema_pkg_apis_monitoring_v1_ThanosSpec(ref),
"k8s.io/api/core/v1.AWSElasticBlockStoreVolumeSource": schema_k8sio_api_core_v1_AWSElasticBlockStoreVolumeSource(ref),
"k8s.io/api/core/v1.Affinity": schema_k8sio_api_core_v1_Affinity(ref),
@ -2424,96 +2422,6 @@ func schema_pkg_apis_monitoring_v1_TLSConfig(ref common.ReferenceCallback) commo
}
}
func schema_pkg_apis_monitoring_v1_ThanosGCSSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Deprecated: ThanosGCSSpec should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosGCSSpec will be removed.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"bucket": {
SchemaProps: spec.SchemaProps{
Description: "Google Cloud Storage bucket name for stored blocks. If empty it won't store any block inside Google Cloud Storage.",
Type: []string{"string"},
Format: "",
},
},
"credentials": {
SchemaProps: spec.SchemaProps{
Description: "Secret to access our Bucket.",
Ref: ref("k8s.io/api/core/v1.SecretKeySelector"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/core/v1.SecretKeySelector"},
}
}
func schema_pkg_apis_monitoring_v1_ThanosS3Spec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Deprecated: ThanosS3Spec should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. ThanosS3Spec will be removed.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"bucket": {
SchemaProps: spec.SchemaProps{
Description: "S3-Compatible API bucket name for stored blocks.",
Type: []string{"string"},
Format: "",
},
},
"endpoint": {
SchemaProps: spec.SchemaProps{
Description: "S3-Compatible API endpoint for stored blocks.",
Type: []string{"string"},
Format: "",
},
},
"accessKey": {
SchemaProps: spec.SchemaProps{
Description: "AccessKey for an S3-Compatible API.",
Ref: ref("k8s.io/api/core/v1.SecretKeySelector"),
},
},
"secretKey": {
SchemaProps: spec.SchemaProps{
Description: "SecretKey for an S3-Compatible API.",
Ref: ref("k8s.io/api/core/v1.SecretKeySelector"),
},
},
"insecure": {
SchemaProps: spec.SchemaProps{
Description: "Whether to use an insecure connection with an S3-Compatible API.",
Type: []string{"boolean"},
Format: "",
},
},
"signatureVersion2": {
SchemaProps: spec.SchemaProps{
Description: "Whether to use S3 Signature Version 2; otherwise Signature Version 4 will be used.",
Type: []string{"boolean"},
Format: "",
},
},
"encryptsse": {
SchemaProps: spec.SchemaProps{
Description: "Whether to use Server Side Encryption",
Type: []string{"boolean"},
Format: "",
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/core/v1.SecretKeySelector"},
}
}
func schema_pkg_apis_monitoring_v1_ThanosSpec(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@ -2521,13 +2429,6 @@ func schema_pkg_apis_monitoring_v1_ThanosSpec(ref common.ReferenceCallback) comm
Description: "ThanosSpec defines parameters for a Prometheus server within a Thanos deployment.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"peers": {
SchemaProps: spec.SchemaProps{
Description: "Peers is a DNS name for Thanos to discover peers through.",
Type: []string{"string"},
Format: "",
},
},
"image": {
SchemaProps: spec.SchemaProps{
Description: "Image if specified has precedence over baseImage, tag and sha combinations. Specifying the version is still necessary to ensure the Prometheus Operator knows what version of Thanos is being configured.",
@ -2569,43 +2470,17 @@ func schema_pkg_apis_monitoring_v1_ThanosSpec(ref common.ReferenceCallback) comm
Ref: ref("k8s.io/api/core/v1.ResourceRequirements"),
},
},
"gcs": {
SchemaProps: spec.SchemaProps{
Description: "Deprecated: GCS should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. This field will be removed.",
Ref: ref("github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosGCSSpec"),
},
},
"s3": {
SchemaProps: spec.SchemaProps{
Description: "Deprecated: S3 should be configured with an ObjectStorageConfig secret starting with Thanos v0.2.0. This field will be removed.",
Ref: ref("github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosS3Spec"),
},
},
"objectStorageConfig": {
SchemaProps: spec.SchemaProps{
Description: "ObjectStorageConfig configures object storage in Thanos.",
Ref: ref("k8s.io/api/core/v1.SecretKeySelector"),
},
},
"grpcAdvertiseAddress": {
SchemaProps: spec.SchemaProps{
Description: "Explicit (external) host:port address to advertise for gRPC StoreAPI in gossip cluster. If empty, 'grpc-address' will be used.",
Type: []string{"string"},
Format: "",
},
},
"clusterAdvertiseAddress": {
SchemaProps: spec.SchemaProps{
Description: "Explicit (external) ip:port address to advertise for gossip in gossip cluster. Used internally for membership only.",
Type: []string{"string"},
Format: "",
},
},
},
},
},
Dependencies: []string{
"github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosGCSSpec", "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1.ThanosS3Spec", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecretKeySelector"},
"k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.SecretKeySelector"},
}
}

View file

@ -314,8 +314,6 @@ type QuerySpec struct {
// ThanosSpec defines parameters for a Prometheus server within a Thanos deployment.
// +k8s:openapi-gen=true
type ThanosSpec struct {
// Peers is a DNS name for Thanos to discover peers through.
Peers *string `json:"peers,omitempty"`
// Image if specified has precedence over baseImage, tag and sha
// combinations. Specifying the version is still necessary to ensure the
// Prometheus Operator knows what version of Thanos is being
@ -335,53 +333,8 @@ type ThanosSpec struct {
// Resources defines the resource requirements for the Thanos sidecar.
// If not provided, no requests/limits will be set
Resources v1.ResourceRequirements `json:"resources,omitempty"`
// Deprecated: GCS should be configured with an ObjectStorageConfig secret
// starting with Thanos v0.2.0. This field will be removed.
GCS *ThanosGCSSpec `json:"gcs,omitempty"`
// Deprecated: S3 should be configured with an ObjectStorageConfig secret
// starting with Thanos v0.2.0. This field will be removed.
S3 *ThanosS3Spec `json:"s3,omitempty"`
// ObjectStorageConfig configures object storage in Thanos.
ObjectStorageConfig *v1.SecretKeySelector `json:"objectStorageConfig,omitempty"`
// Explicit (external) host:port address to advertise for gRPC StoreAPI in gossip cluster.
// If empty, 'grpc-address' will be used.
GrpcAdvertiseAddress *string `json:"grpcAdvertiseAddress,omitempty"`
// Explicit (external) ip:port address to advertise for gossip in gossip cluster.
// Used internally for membership only.
ClusterAdvertiseAddress *string `json:"clusterAdvertiseAddress,omitempty"`
}
// Deprecated: ThanosGCSSpec should be configured with an ObjectStorageConfig
// secret starting with Thanos v0.2.0. ThanosGCSSpec will be removed.
//
// +k8s:openapi-gen=true
type ThanosGCSSpec struct {
// Google Cloud Storage bucket name for stored blocks. If empty it won't
// store any block inside Google Cloud Storage.
Bucket *string `json:"bucket,omitempty"`
// Secret to access our Bucket.
SecretKey *v1.SecretKeySelector `json:"credentials,omitempty"`
}
// Deprecated: ThanosS3Spec should be configured with an ObjectStorageConfig
// secret starting with Thanos v0.2.0. ThanosS3Spec will be removed.
//
// +k8s:openapi-gen=true
type ThanosS3Spec struct {
// S3-Compatible API bucket name for stored blocks.
Bucket *string `json:"bucket,omitempty"`
// S3-Compatible API endpoint for stored blocks.
Endpoint *string `json:"endpoint,omitempty"`
// AccessKey for an S3-Compatible API.
AccessKey *v1.SecretKeySelector `json:"accessKey,omitempty"`
// SecretKey for an S3-Compatible API.
SecretKey *v1.SecretKeySelector `json:"secretKey,omitempty"`
// Whether to use an insecure connection with an S3-Compatible API.
Insecure *bool `json:"insecure,omitempty"`
// Whether to use S3 Signature Version 2; otherwise Signature Version 4 will be used.
SignatureVersion2 *bool `json:"signatureVersion2,omitempty"`
// Whether to use Server Side Encryption
EncryptSSE *bool `json:"encryptsse,omitempty"`
}
// RemoteWriteSpec defines the remote_write configuration for prometheus.

View file

@ -1058,91 +1058,9 @@ func (in *TLSConfig) DeepCopy() *TLSConfig {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThanosGCSSpec) DeepCopyInto(out *ThanosGCSSpec) {
*out = *in
if in.Bucket != nil {
in, out := &in.Bucket, &out.Bucket
*out = new(string)
**out = **in
}
if in.SecretKey != nil {
in, out := &in.SecretKey, &out.SecretKey
*out = new(corev1.SecretKeySelector)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThanosGCSSpec.
func (in *ThanosGCSSpec) DeepCopy() *ThanosGCSSpec {
if in == nil {
return nil
}
out := new(ThanosGCSSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThanosS3Spec) DeepCopyInto(out *ThanosS3Spec) {
*out = *in
if in.Bucket != nil {
in, out := &in.Bucket, &out.Bucket
*out = new(string)
**out = **in
}
if in.Endpoint != nil {
in, out := &in.Endpoint, &out.Endpoint
*out = new(string)
**out = **in
}
if in.AccessKey != nil {
in, out := &in.AccessKey, &out.AccessKey
*out = new(corev1.SecretKeySelector)
(*in).DeepCopyInto(*out)
}
if in.SecretKey != nil {
in, out := &in.SecretKey, &out.SecretKey
*out = new(corev1.SecretKeySelector)
(*in).DeepCopyInto(*out)
}
if in.Insecure != nil {
in, out := &in.Insecure, &out.Insecure
*out = new(bool)
**out = **in
}
if in.SignatureVersion2 != nil {
in, out := &in.SignatureVersion2, &out.SignatureVersion2
*out = new(bool)
**out = **in
}
if in.EncryptSSE != nil {
in, out := &in.EncryptSSE, &out.EncryptSSE
*out = new(bool)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ThanosS3Spec.
func (in *ThanosS3Spec) DeepCopy() *ThanosS3Spec {
if in == nil {
return nil
}
out := new(ThanosS3Spec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ThanosSpec) DeepCopyInto(out *ThanosSpec) {
*out = *in
if in.Peers != nil {
in, out := &in.Peers, &out.Peers
*out = new(string)
**out = **in
}
if in.Image != nil {
in, out := &in.Image, &out.Image
*out = new(string)
@ -1169,31 +1087,11 @@ func (in *ThanosSpec) DeepCopyInto(out *ThanosSpec) {
**out = **in
}
in.Resources.DeepCopyInto(&out.Resources)
if in.GCS != nil {
in, out := &in.GCS, &out.GCS
*out = new(ThanosGCSSpec)
(*in).DeepCopyInto(*out)
}
if in.S3 != nil {
in, out := &in.S3, &out.S3
*out = new(ThanosS3Spec)
(*in).DeepCopyInto(*out)
}
if in.ObjectStorageConfig != nil {
in, out := &in.ObjectStorageConfig, &out.ObjectStorageConfig
*out = new(corev1.SecretKeySelector)
(*in).DeepCopyInto(*out)
}
if in.GrpcAdvertiseAddress != nil {
in, out := &in.GrpcAdvertiseAddress, &out.GrpcAdvertiseAddress
*out = new(string)
**out = **in
}
if in.ClusterAdvertiseAddress != nil {
in, out := &in.ClusterAdvertiseAddress, &out.ClusterAdvertiseAddress
*out = new(string)
**out = **in
}
return
}

View file

@ -35,7 +35,7 @@ import (
const (
governingServiceName = "prometheus-operated"
DefaultPrometheusVersion = "v2.7.1"
DefaultThanosVersion = "v0.2.1"
DefaultThanosVersion = "v0.4.0"
defaultRetention = "24h"
defaultReplicaExternalLabelName = "prometheus_replica"
storageDir = "/prometheus"
@ -660,15 +660,14 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
}
if p.Spec.Thanos != nil {
thanosBaseImage := c.ThanosDefaultBaseImage
if p.Spec.Thanos.BaseImage != nil {
thanosBaseImage = *p.Spec.Thanos.BaseImage
}
// Version is used by default.
// If the tag is specified, we use the tag to identify the container image.
// If the sha is specified, we use the sha to identify the container image,
// as it has even stronger immutable guarantees to identify the image.
thanosBaseImage := c.ThanosDefaultBaseImage
if p.Spec.Thanos.BaseImage != nil {
thanosBaseImage = *p.Spec.Thanos.BaseImage
}
thanosImage := fmt.Sprintf("%s:%s", thanosBaseImage, *p.Spec.Thanos.Version)
if p.Spec.Thanos.Tag != nil {
thanosImage = fmt.Sprintf("%s:%s", thanosBaseImage, *p.Spec.Thanos.Tag)
@ -680,145 +679,25 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
thanosImage = *p.Spec.Thanos.Image
}
thanosVersion := semver.MustParse(strings.TrimPrefix(*p.Spec.Thanos.Version, "v"))
clusterSupport := thanosVersion.LT(semver.MustParse("0.5.0-rc.0"))
thanosArgs := []string{
"sidecar",
fmt.Sprintf("--prometheus.url=http://%s:9090%s", c.LocalHost, path.Clean(webRoutePrefix)),
fmt.Sprintf("--tsdb.path=%s", storageDir),
fmt.Sprintf("--grpc-address=[$(POD_IP)]:%d", 10901),
}
if clusterSupport {
thanosArgs = append(thanosArgs, fmt.Sprintf("--cluster.address=[$(POD_IP)]:%d", 10900))
if p.Spec.Thanos.Peers != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--cluster.peers=%s", *p.Spec.Thanos.Peers))
}
if p.Spec.Thanos.ClusterAdvertiseAddress != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--cluster.advertise-address=%s", *p.Spec.Thanos.ClusterAdvertiseAddress))
}
if p.Spec.Thanos.GrpcAdvertiseAddress != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--grpc-advertise-address=%s", *p.Spec.Thanos.GrpcAdvertiseAddress))
}
}
if p.Spec.LogLevel != "" && p.Spec.LogLevel != "info" {
thanosArgs = append(thanosArgs, fmt.Sprintf("--log.level=%s", p.Spec.LogLevel))
}
if thanosVersion.GTE(semver.MustParse("0.2.0")) {
if p.Spec.LogFormat != "" && p.Spec.LogFormat != "logfmt" {
thanosArgs = append(thanosArgs, fmt.Sprintf("--log.format=%s", p.Spec.LogFormat))
}
}
thanosVolumeMounts := []v1.VolumeMount{
{
Name: volName,
MountPath: storageDir,
SubPath: subPathForStorage(p.Spec.Storage),
},
}
envVars := []v1.EnvVar{
{
// Necessary for '--cluster.address', '--grpc-address' flags
Name: "POD_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "status.podIP",
},
},
},
{
Name: "HOST_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
},
},
}
if p.Spec.Thanos.ObjectStorageConfig != nil {
envVars = append(envVars, v1.EnvVar{
Name: "OBJSTORE_CONFIG",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: p.Spec.Thanos.ObjectStorageConfig,
},
})
thanosArgs = append(thanosArgs, "--objstore.config=$(OBJSTORE_CONFIG)")
}
if p.Spec.Thanos.GCS != nil {
if p.Spec.Thanos.GCS.Bucket != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--gcs.bucket=%s", *p.Spec.Thanos.GCS.Bucket))
}
if p.Spec.Thanos.GCS.SecretKey != nil {
secretFileName := "service-account.json"
if p.Spec.Thanos.GCS.SecretKey.Key != "" {
secretFileName = p.Spec.Thanos.GCS.SecretKey.Key
}
secretDir := path.Join("/var/run/secrets/prometheus.io", p.Spec.Thanos.GCS.SecretKey.Name)
envVars = append(envVars, v1.EnvVar{
Name: "GOOGLE_APPLICATION_CREDENTIALS",
Value: path.Join(secretDir, secretFileName),
})
volumeName := k8sutil.SanitizeVolumeName("secret-" + p.Spec.Thanos.GCS.SecretKey.Name)
volumes = append(volumes, v1.Volume{
Name: volumeName,
VolumeSource: v1.VolumeSource{
Secret: &v1.SecretVolumeSource{
SecretName: p.Spec.Thanos.GCS.SecretKey.Name,
},
},
})
thanosVolumeMounts = append(thanosVolumeMounts, v1.VolumeMount{
Name: volumeName,
ReadOnly: true,
MountPath: secretDir,
})
}
}
if p.Spec.Thanos.S3 != nil {
if p.Spec.Thanos.S3.Bucket != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--s3.bucket=%s", *p.Spec.Thanos.S3.Bucket))
}
if p.Spec.Thanos.S3.Endpoint != nil {
thanosArgs = append(thanosArgs, fmt.Sprintf("--s3.endpoint=%s", *p.Spec.Thanos.S3.Endpoint))
}
if p.Spec.Thanos.S3.Insecure != nil && *p.Spec.Thanos.S3.Insecure {
thanosArgs = append(thanosArgs, "--s3.insecure")
}
if p.Spec.Thanos.S3.SignatureVersion2 != nil && *p.Spec.Thanos.S3.SignatureVersion2 {
thanosArgs = append(thanosArgs, "--s3.signature-version2")
}
if p.Spec.Thanos.S3.AccessKey != nil {
envVars = append(envVars, v1.EnvVar{
Name: "S3_ACCESS_KEY",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: p.Spec.Thanos.S3.AccessKey,
},
})
}
if p.Spec.Thanos.S3.EncryptSSE != nil && *p.Spec.Thanos.S3.EncryptSSE {
thanosArgs = append(thanosArgs, "--s3.encrypt-sse")
}
if p.Spec.Thanos.S3.SecretKey != nil {
envVars = append(envVars, v1.EnvVar{
Name: "S3_SECRET_KEY",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: p.Spec.Thanos.S3.SecretKey,
},
})
}
}
c := v1.Container{
container := v1.Container{
Name: "thanos-sidecar",
Image: thanosImage,
Args: thanosArgs,
Args: []string{
"sidecar",
fmt.Sprintf("--prometheus.url=http://%s:9090%s", c.LocalHost, path.Clean(webRoutePrefix)),
fmt.Sprintf("--tsdb.path=%s", storageDir),
"--grpc-address=[$(POD_IP)]:10901",
},
Env: []v1.EnvVar{
{
Name: "POD_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
FieldPath: "status.podIP",
},
},
},
},
Ports: []v1.ContainerPort{
{
Name: "http",
@ -829,18 +708,34 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
ContainerPort: 10901,
},
},
Env: envVars,
VolumeMounts: thanosVolumeMounts,
Resources: p.Spec.Thanos.Resources,
VolumeMounts: []v1.VolumeMount{
{
Name: volName,
MountPath: storageDir,
SubPath: subPathForStorage(p.Spec.Storage),
},
},
Resources: p.Spec.Thanos.Resources,
}
if clusterSupport {
c.Ports = append(c.Ports, v1.ContainerPort{
Name: "cluster",
ContainerPort: 10900,
if p.Spec.Thanos.ObjectStorageConfig != nil {
container.Args = append(container.Args, "--objstore.config=$(OBJSTORE_CONFIG)")
container.Env = append(container.Env, v1.EnvVar{
Name: "OBJSTORE_CONFIG",
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: p.Spec.Thanos.ObjectStorageConfig,
},
})
}
additionalContainers = append(additionalContainers, c)
if p.Spec.LogLevel != "" {
container.Args = append(container.Args, fmt.Sprintf("--log.level=%s", p.Spec.LogLevel))
}
if p.Spec.LogFormat != "" {
container.Args = append(container.Args, fmt.Sprintf("--log.format=%s", p.Spec.LogFormat))
}
additionalContainers = append(additionalContainers, container)
promArgs = append(promArgs, "--storage.tsdb.min-block-duration=2h", "--storage.tsdb.max-block-duration=2h")
}

View file

@ -28,7 +28,7 @@ import (
"testing"
"time"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -1267,70 +1267,67 @@ func testThanos(t *testing.T) {
ns := ctx.CreateNamespace(t, framework.KubeClient)
ctx.SetupPrometheusRBAC(t, ns, framework.KubeClient)
peerServiceName := "thanos-peers"
querierServiceName := "thanos-querier"
basicPrometheus := framework.MakeBasicPrometheus(ns, "basic-prometheus", "test-group", 1)
peerServiceDNS := fmt.Sprintf("%s.%s.svc:10900", peerServiceName, ns)
version := "v0.1.0"
basicPrometheus.Spec.Thanos = &monitoringv1.ThanosSpec{
Peers: &peerServiceDNS,
version := prometheus.DefaultThanosVersion
prom := framework.MakeBasicPrometheus(ns, "basic-prometheus", "test-group", 1)
prom.Spec.Replicas = proto.Int32(2)
prom.Spec.Thanos = &monitoringv1.ThanosSpec{
Version: &version,
}
basicPrometheus.Spec.PodMetadata = &metav1.ObjectMeta{
CreationTimestamp: metav1.Now(),
Labels: map[string]string{
"thanos-peer": "true",
},
}
replicas := int32(2)
basicPrometheus.Spec.Replicas = &replicas
pservice := framework.MakePrometheusService(basicPrometheus.Name, "test-group", v1.ServiceTypeClusterIP)
tservice := framework.MakeThanosService(peerServiceName)
qservice := framework.MakeThanosQuerierService(querierServiceName)
s := framework.MakeBasicServiceMonitor("test-group")
thanosQuerier, err := testFramework.MakeDeployment("../../example/thanos/querier-deployment.yaml")
if err != nil {
t.Fatal("Making deployment failed: ", err)
}
querierArgs := []string{
"query",
"--log.level=debug",
"--query.replica-label=prometheus_replica",
fmt.Sprintf("--cluster.peers=%s", peerServiceDNS),
}
log.Println("setting up querier with args: ", querierArgs)
thanosQuerier.Spec.Template.Spec.Containers[0].Args = querierArgs
if err := testFramework.CreateDeployment(framework.KubeClient, ns, thanosQuerier); err != nil {
t.Fatal("Creating Thanos querier failed: ", err)
}
if _, err := testFramework.CreateServiceAndWaitUntilReady(framework.KubeClient, ns, qservice); err != nil {
t.Fatal("Creating Thanos querier service failed: ", err)
}
if _, err := framework.MonClientV1.ServiceMonitors(ns).Create(s); err != nil {
t.Fatal("Creating ServiceMonitor failed: ", err)
}
if _, err := framework.KubeClient.CoreV1().Services(ns).Create(pservice); err != nil {
t.Fatal("Creating prometheus service failed: ", err)
}
if _, err := framework.MonClientV1.Prometheuses(ns).Create(basicPrometheus); err != nil {
if _, err := framework.CreatePrometheusAndWaitUntilReady(ns, prom); err != nil {
t.Fatal("Creating prometheus failed: ", err)
}
if _, err := framework.KubeClient.CoreV1().Services(ns).Create(tservice); err != nil {
promSvc := framework.MakePrometheusService(prom.Name, "test-group", v1.ServiceTypeClusterIP)
if _, err := framework.KubeClient.CoreV1().Services(ns).Create(promSvc); err != nil {
t.Fatal("Creating prometheus service failed: ", err)
}
svcMon := framework.MakeBasicServiceMonitor("test-group")
if _, err := framework.MonClientV1.ServiceMonitors(ns).Create(svcMon); err != nil {
t.Fatal("Creating ServiceMonitor failed: ", err)
}
sidecarSvc := framework.MakeThanosSidecarService(prom.Name)
if _, err := framework.KubeClient.CoreV1().Services(ns).Create(sidecarSvc); err != nil {
t.Fatal("Creating thanos sidecar service failed: ", err)
}
qryDep, err := testFramework.MakeDeployment("../../example/thanos/query-deployment.yaml")
if err != nil {
t.Fatal("Making thanos query deployment failed: ", err)
}
// override image
qryImage := "improbable/thanos:" + version
t.Log("setting up query with image: ", qryImage)
qryDep.Spec.Template.Spec.Containers[0].Image = qryImage
// override args
qryArgs := []string{
"query",
"--log.level=debug",
"--query.replica-label=prometheus_replica",
fmt.Sprintf("--store=dnssrv+_grpc._tcp.%s.%s.svc.cluster.local", sidecarSvc.Name, ns),
}
t.Log("setting up query with args: ", qryArgs)
qryDep.Spec.Template.Spec.Containers[0].Args = qryArgs
if err := testFramework.CreateDeployment(framework.KubeClient, ns, qryDep); err != nil {
t.Fatal("Creating Thanos query deployment failed: ", err)
}
qrySvc := framework.MakeThanosQuerierService(qryDep.Name)
if _, err := testFramework.CreateServiceAndWaitUntilReady(framework.KubeClient, ns, qrySvc); err != nil {
t.Fatal("Creating Thanos query service failed: ", err)
}
err = wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) {
proxyGet := framework.KubeClient.CoreV1().Services(ns).ProxyGet
request := proxyGet("http", querierServiceName, "http-query", "/api/v1/query", map[string]string{"query": "prometheus_build_info", "dedup": "false"})
request := proxyGet("http", qrySvc.Name, "http-query", "/api/v1/query", map[string]string{
"query": "prometheus_build_info",
"dedup": "false",
})
b, err := request.DoRaw()
if err != nil {
log.Println(fmt.Sprintf("Error performing request against Thanos querier: %v\n\nretrying...", err))
t.Logf("Error performing request against Thanos query: %v\n\nretrying...", err)
return false, nil
}
@ -1351,13 +1348,13 @@ func testThanos(t *testing.T) {
// Prometheus replicas by both replicas.
expected := 4
if result != expected {
log.Printf("Unexpected number of results from query. Got %d, expected %d. retrying...\n", result, expected)
t.Logf("Unexpected number of results from query. Got %d, expected %d. retrying...", result, expected)
return false, nil
}
return true, nil
})
if err != nil {
t.Fatal("Failed to get correct result from Thanos querier: ", err)
t.Fatal("Failed to get correct result from Thanos query: ", err)
}
}

View file

@ -20,7 +20,7 @@ import (
"fmt"
"time"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
@ -143,21 +143,22 @@ func (f *Framework) MakeThanosQuerierService(name string) *v1.Service {
return service
}
func (f *Framework) MakeThanosService(name string) *v1.Service {
func (f *Framework) MakeThanosSidecarService(name string) *v1.Service {
service := &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: fmt.Sprintf("thanos-sidecar-%s", name),
},
Spec: v1.ServiceSpec{
ClusterIP: "None",
Ports: []v1.ServicePort{
{
Name: "cluster",
Port: 10900,
TargetPort: intstr.FromString("cluster"),
Name: "grpc",
Port: 10901,
TargetPort: intstr.FromString("grpc"),
},
},
Selector: map[string]string{
"thanos-peer": "true",
"prometheus": name,
},
},
}