Skip to content

Commit 2367777

Browse files
query, rule: make endpoint discovery dynamically reloadable (#7890)
* Removed previously deprecated and hidden flags to configure endpoints ( --rule, --target, ...) * Added new flags --endpoint.sd-config, --endpoint-sd-config-reload-interval to configure a dynamic SD file * Moved endpoint set construction into cmd/thanos/endpointset.go for a little cleanup * Renamed "thanos_(querier/ruler)_duplicated_store_addresses_total" to "thanos_(querier/ruler)_duplicated_endpoint_addresses_total" The new config makes it possible to also set "strict" and "group" flags on the endpoint instead of only their addresses, making it possible to have file based service discovery for endpoint groups too. Signed-off-by: Michael Hoffmann <[email protected]> Signed-off-by: Michael Hoffmann <[email protected]>
1 parent 300a9ed commit 2367777

16 files changed

+572
-541
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
2626

2727
### Changed
2828

29+
- [#7890](https://github.com/thanos-io/thanos/pull/7890) Query,Ruler: *breaking :warning:* deprecated `--store.sd-file` and `--store.sd-interval` to be replaced with `--endpoint.sd-config` and `--endpoint-sd-config-reload-interval`; removed legacy flags to pass endpoints `--store`, `--metadata`, `--rule`, `--exemplar`.
30+
2931
### Removed
3032

3133
## [v0.37.2](https://github.com/thanos-io/thanos/tree/release-0.37) - 11.12.2024

cmd/thanos/config.go

+38
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ import (
1414

1515
"github.com/KimMachineGun/automemlimit/memlimit"
1616
extflag "github.com/efficientgo/tools/extkingpin"
17+
"github.com/go-kit/log"
18+
"github.com/opentracing/opentracing-go"
1719
"github.com/pkg/errors"
20+
"google.golang.org/grpc"
1821

22+
"github.com/prometheus/client_golang/prometheus"
1923
"github.com/prometheus/common/model"
2024
"github.com/prometheus/prometheus/model/labels"
2125

26+
"github.com/thanos-io/thanos/pkg/extgrpc"
27+
"github.com/thanos-io/thanos/pkg/extgrpc/snappy"
2228
"github.com/thanos-io/thanos/pkg/extkingpin"
2329
"github.com/thanos-io/thanos/pkg/shipper"
2430
)
@@ -58,6 +64,38 @@ func (gc *grpcConfig) registerFlag(cmd extkingpin.FlagClause) *grpcConfig {
5864
return gc
5965
}
6066

67+
type grpcClientConfig struct {
68+
secure bool
69+
skipVerify bool
70+
cert, key, caCert string
71+
serverName string
72+
compression string
73+
}
74+
75+
func (gc *grpcClientConfig) registerFlag(cmd extkingpin.FlagClause) *grpcClientConfig {
76+
cmd.Flag("grpc-client-tls-secure", "Use TLS when talking to the gRPC server").Default("false").BoolVar(&gc.secure)
77+
cmd.Flag("grpc-client-tls-skip-verify", "Disable TLS certificate verification i.e self signed, signed by fake CA").Default("false").BoolVar(&gc.skipVerify)
78+
cmd.Flag("grpc-client-tls-cert", "TLS Certificates to use to identify this client to the server").Default("").StringVar(&gc.cert)
79+
cmd.Flag("grpc-client-tls-key", "TLS Key for the client's certificate").Default("").StringVar(&gc.key)
80+
cmd.Flag("grpc-client-tls-ca", "TLS CA Certificates to use to verify gRPC servers").Default("").StringVar(&gc.caCert)
81+
cmd.Flag("grpc-client-server-name", "Server name to verify the hostname on the returned gRPC certificates. See https://tools.ietf.org/html/rfc4366#section-3.1").Default("").StringVar(&gc.serverName)
82+
compressionOptions := strings.Join([]string{snappy.Name, compressionNone}, ", ")
83+
cmd.Flag("grpc-compression", "Compression algorithm to use for gRPC requests to other clients. Must be one of: "+compressionOptions).Default(compressionNone).EnumVar(&gc.compression, snappy.Name, compressionNone)
84+
85+
return gc
86+
}
87+
88+
func (gc *grpcClientConfig) dialOptions(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer) ([]grpc.DialOption, error) {
89+
dialOpts, err := extgrpc.StoreClientGRPCOpts(logger, reg, tracer, gc.secure, gc.skipVerify, gc.cert, gc.key, gc.caCert, gc.serverName)
90+
if err != nil {
91+
return nil, errors.Wrapf(err, "building gRPC client")
92+
}
93+
if gc.compression != compressionNone {
94+
dialOpts = append(dialOpts, grpc.WithDefaultCallOptions(grpc.UseCompressor(gc.compression)))
95+
}
96+
return dialOpts, nil
97+
}
98+
6199
type httpConfig struct {
62100
bindAddress string
63101
tlsConfig string

0 commit comments

Comments
 (0)