Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## master / unreleased

* [CHANGE] Ingester: don't update internal "last updated" timestamp of TSDB if tenant only sends invalid samples. This affects how "idle" time is computed. #3727
* [CHANGE] Require explicit flag `-<prefix>.tls-enabled` to enable TLS in GRPC clients. Previously it was enough to specify a TLS flag to enable TLS validation. #3156
* [FEATURE] Adds support to S3 server side encryption using KMS. Deprecated `-<prefix>.s3.sse-encryption`, you should use the following CLI flags that have been added. #3651
- `-<prefix>.s3.sse.type`
- `-<prefix>.s3.sse.kms-key-id`
Expand All @@ -13,6 +14,7 @@
* Prevent compaction loop in TSDB on data gap.
* [ENHANCEMENT] Return server side performance metrics for query-frontend (using Server-timing header). #3685
* [ENHANCEMENT] Runtime Config: Add a `mode` query parameter for the runtime config endpoint. `/runtime_config?mode=diff` now shows the YAML runtime configuration with all values that differ from the defaults. #3700
* [ENHANCEMENT] Add flag `-<prefix>.tls-server-name` to require a specific server name instead of the hostname on the certificate. #3156
* [BUGFIX] HA Tracker: don't track as error in the `cortex_kv_request_duration_seconds` metric a CAS operation intentionally aborted. #3745

## 1.7.0 in progress
Expand Down
8 changes: 8 additions & 0 deletions docs/blocks-storage/querier.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ querier:
[store_gateway_addresses: <string> | default = ""]

store_gateway_client:
# Enable TLS for gRPC client connecting to store-gateway.
# CLI flag: -querier.store-gateway-client.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -querier.store-gateway-client.tls-cert-path
Expand All @@ -183,6 +187,10 @@ querier:
# CLI flag: -querier.store-gateway-client.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -querier.store-gateway-client.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -querier.store-gateway-client.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down
104 changes: 101 additions & 3 deletions docs/configuration/config-file-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ query_scheduler:
# CLI flag: -query-scheduler.grpc-client-config.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any
# other TLS flag is set. If set to false, insecure connection to gRPC server
# will be used.
# CLI flag: -query-scheduler.grpc-client-config.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -query-scheduler.grpc-client-config.tls-cert-path
Expand All @@ -234,6 +240,10 @@ query_scheduler:
# CLI flag: -query-scheduler.grpc-client-config.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -query-scheduler.grpc-client-config.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -query-scheduler.grpc-client-config.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -826,6 +836,10 @@ The `querier_config` configures the Cortex querier.
[store_gateway_addresses: <string> | default = ""]

store_gateway_client:
# Enable TLS for gRPC client connecting to store-gateway.
# CLI flag: -querier.store-gateway-client.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -querier.store-gateway-client.tls-cert-path
Expand All @@ -841,6 +855,10 @@ store_gateway_client:
# CLI flag: -querier.store-gateway-client.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -querier.store-gateway-client.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -querier.store-gateway-client.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -940,6 +958,12 @@ grpc_client_config:
# CLI flag: -frontend.grpc-client-config.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any other
# TLS flag is set. If set to false, insecure connection to gRPC server will be
# used.
# CLI flag: -frontend.grpc-client-config.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -frontend.grpc-client-config.tls-cert-path
Expand All @@ -955,6 +979,10 @@ grpc_client_config:
# CLI flag: -frontend.grpc-client-config.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -frontend.grpc-client-config.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -frontend.grpc-client-config.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -1100,6 +1128,12 @@ ruler_client:
# CLI flag: -ruler.client.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any other
# TLS flag is set. If set to false, insecure connection to gRPC server will be
# used.
# CLI flag: -ruler.client.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -ruler.client.tls-cert-path
Expand All @@ -1115,6 +1149,10 @@ ruler_client:
# CLI flag: -ruler.client.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -ruler.client.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -ruler.client.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -2359,6 +2397,35 @@ bigtable:
# CLI flag: -bigtable.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any
# other TLS flag is set. If set to false, insecure connection to gRPC server
# will be used.
# CLI flag: -bigtable.tls-enabled
[tls_enabled: <boolean> | default = true]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -bigtable.tls-cert-path
[tls_cert_path: <string> | default = ""]

# Path to the key file for the client certificate. Also requires the client
# certificate to be configured.
# CLI flag: -bigtable.tls-key-path
[tls_key_path: <string> | default = ""]

# Path to the CA certificates file to validate server certificate against.
# If not set, the host's root CA certificates are used.
# CLI flag: -bigtable.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -bigtable.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -bigtable.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]

# If enabled, once a tables info is fetched, it is cached.
# CLI flag: -bigtable.table-cache.enabled
[table_cache_enabled: <boolean> | default = true]
Expand Down Expand Up @@ -2879,6 +2946,12 @@ grpc_client_config:
# CLI flag: -ingester.client.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any other
# TLS flag is set. If set to false, insecure connection to gRPC server will be
# used.
# CLI flag: -ingester.client.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -ingester.client.tls-cert-path
Expand All @@ -2894,6 +2967,10 @@ grpc_client_config:
# CLI flag: -ingester.client.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -ingester.client.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -ingester.client.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -2976,6 +3053,12 @@ grpc_client_config:
# CLI flag: -querier.frontend-client.backoff-retries
[max_retries: <int> | default = 10]

# Enable TLS in the GRPC client. This flag needs to be enabled when any other
# TLS flag is set. If set to false, insecure connection to gRPC server will be
# used.
# CLI flag: -querier.frontend-client.tls-enabled
[tls_enabled: <boolean> | default = false]

# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -querier.frontend-client.tls-cert-path
Expand All @@ -2991,6 +3074,10 @@ grpc_client_config:
# CLI flag: -querier.frontend-client.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -querier.frontend-client.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -querier.frontend-client.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -3027,18 +3114,25 @@ The `etcd_config` configures the etcd client. The supported CLI flags `<prefix>`
# CLI flag: -<prefix>.etcd.tls-enabled
[tls_enabled: <boolean> | default = false]

# The TLS certificate file path.
# Path to the client certificate file, which will be used for authenticating
# with the server. Also requires the key path to be configured.
# CLI flag: -<prefix>.etcd.tls-cert-path
[tls_cert_path: <string> | default = ""]

# The TLS private key file path.
# Path to the key file for the client certificate. Also requires the client
# certificate to be configured.
# CLI flag: -<prefix>.etcd.tls-key-path
[tls_key_path: <string> | default = ""]

# The trusted CA file path.
# Path to the CA certificates file to validate server certificate against. If
# not set, the host's root CA certificates are used.
# CLI flag: -<prefix>.etcd.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -<prefix>.etcd.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -<prefix>.etcd.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down Expand Up @@ -3659,6 +3753,10 @@ The `configstore_config` configures the config database storing rules and alerts
# CLI flag: -<prefix>.configs.tls-ca-path
[tls_ca_path: <string> | default = ""]

# Override the expected name on the server certificate.
# CLI flag: -<prefix>.configs.tls-server-name
[tls_server_name: <string> | default = ""]

# Skip validating server certificate.
# CLI flag: -<prefix>.configs.tls-insecure-skip-verify
[tls_insecure_skip_verify: <boolean> | default = false]
Expand Down
12 changes: 5 additions & 7 deletions integration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ func getServerTLSFlags() map[string]string {

func getClientTLSFlagsWithPrefix(prefix string) map[string]string {
return map[string]string{
"-" + prefix + ".tls-cert-path": filepath.Join(e2e.ContainerSharedDir, clientCertFile),
"-" + prefix + ".tls-key-path": filepath.Join(e2e.ContainerSharedDir, clientKeyFile),
"-" + prefix + ".tls-ca-path": filepath.Join(e2e.ContainerSharedDir, caCertFile),

// TODO: Remove this in the future to test if TLS verification works,
// this requires a TLSServerName flags to be specified
"-" + prefix + ".tls-insecure-skip-verify": "true",
"-" + prefix + ".tls-cert-path": filepath.Join(e2e.ContainerSharedDir, clientCertFile),
"-" + prefix + ".tls-key-path": filepath.Join(e2e.ContainerSharedDir, clientKeyFile),
"-" + prefix + ".tls-ca-path": filepath.Join(e2e.ContainerSharedDir, caCertFile),
"-" + prefix + ".tls-server-name": "ingester.client",
"-" + prefix + ".tls-enabled": "true",
}
}
16 changes: 12 additions & 4 deletions pkg/chunk/gcp/bigtable_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.BoolVar(&cfg.TableCacheEnabled, "bigtable.table-cache.enabled", true, "If enabled, once a tables info is fetched, it is cached.")
f.DurationVar(&cfg.TableCacheExpiration, "bigtable.table-cache.expiration", 30*time.Minute, "Duration to cache tables before checking again.")

// This overrides our default from TLS disabled to TLS enabled
cfg.GRPCClientConfig.TLSEnabled = true
cfg.GRPCClientConfig.RegisterFlagsWithPrefix("bigtable", f)
}

Expand All @@ -73,8 +75,11 @@ type storageClientV1 struct {

// NewStorageClientV1 returns a new v1 StorageClient.
func NewStorageClientV1(ctx context.Context, cfg Config, schemaCfg chunk.SchemaConfig) (chunk.IndexClient, error) {
opts := toOptions(cfg.GRPCClientConfig.DialOption(bigtableInstrumentation()))
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, opts...)
dialOpts, err := cfg.GRPCClientConfig.DialOption(bigtableInstrumentation())
if err != nil {
return nil, err
}
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, toOptions(dialOpts)...)
if err != nil {
return nil, err
}
Expand All @@ -97,8 +102,11 @@ func newStorageClientV1(cfg Config, schemaCfg chunk.SchemaConfig, client *bigtab

// NewStorageClientColumnKey returns a new v2 StorageClient.
func NewStorageClientColumnKey(ctx context.Context, cfg Config, schemaCfg chunk.SchemaConfig) (chunk.IndexClient, error) {
opts := toOptions(cfg.GRPCClientConfig.DialOption(bigtableInstrumentation()))
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, opts...)
dialOpts, err := cfg.GRPCClientConfig.DialOption(bigtableInstrumentation())
if err != nil {
return nil, err
}
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, toOptions(dialOpts)...)
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/chunk/gcp/bigtable_object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ type bigtableObjectClient struct {
// NewBigtableObjectClient makes a new chunk.Client that stores chunks in
// Bigtable.
func NewBigtableObjectClient(ctx context.Context, cfg Config, schemaCfg chunk.SchemaConfig) (chunk.Client, error) {
opts := toOptions(cfg.GRPCClientConfig.DialOption(bigtableInstrumentation()))
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, opts...)
dialOpts, err := cfg.GRPCClientConfig.DialOption(bigtableInstrumentation())
if err != nil {
return nil, err
}
client, err := bigtable.NewClient(ctx, cfg.Project, cfg.Instance, toOptions(dialOpts)...)
if err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/chunk/gcp/table_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ type tableClient struct {

// NewTableClient returns a new TableClient.
func NewTableClient(ctx context.Context, cfg Config) (chunk.TableClient, error) {
opts := toOptions(cfg.GRPCClientConfig.DialOption(bigtableInstrumentation()))
client, err := bigtable.NewAdminClient(ctx, cfg.Project, cfg.Instance, opts...)
dialOpts, err := cfg.GRPCClientConfig.DialOption(bigtableInstrumentation())
if err != nil {
return nil, err
}
client, err := bigtable.NewAdminClient(ctx, cfg.Project, cfg.Instance, toOptions(dialOpts)...)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/frontend/v2/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (

// Config for a Frontend.
type Config struct {
SchedulerAddress string `yaml:"scheduler_address"`
DNSLookupPeriod time.Duration `yaml:"scheduler_dns_lookup_period"`
WorkerConcurrency int `yaml:"scheduler_worker_concurrency"`
GRPCClientConfig grpcclient.ConfigWithTLS `yaml:"grpc_client_config"`
SchedulerAddress string `yaml:"scheduler_address"`
DNSLookupPeriod time.Duration `yaml:"scheduler_dns_lookup_period"`
WorkerConcurrency int `yaml:"scheduler_worker_concurrency"`
GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"`

// Used to find local IP address, that is sent to scheduler and querier-worker.
InfNames []string `yaml:"instance_interface_names"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingester/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *closableHealthAndIngesterClient) Close() error {

// Config is the configuration struct for the ingester client
type Config struct {
GRPCClientConfig grpcclient.ConfigWithTLS `yaml:"grpc_client_config"`
GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"`
}

// RegisterFlags registers configuration settings used by the ingester client config.
Expand Down
5 changes: 2 additions & 3 deletions pkg/querier/blocks_store_balanced_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cortexproject/cortex/pkg/ring/client"
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/services"
"github.com/cortexproject/cortex/pkg/util/tls"
)

// BlocksStoreSet implementation used when the blocks are not sharded in the store-gateway
Expand All @@ -31,15 +30,15 @@ type blocksStoreBalancedSet struct {
dnsProvider *dns.Provider
}

func newBlocksStoreBalancedSet(serviceAddresses []string, tlsCfg tls.ClientConfig, logger log.Logger, reg prometheus.Registerer) *blocksStoreBalancedSet {
func newBlocksStoreBalancedSet(serviceAddresses []string, clientConfig ClientConfig, logger log.Logger, reg prometheus.Registerer) *blocksStoreBalancedSet {
const dnsResolveInterval = 10 * time.Second

dnsProviderReg := extprom.WrapRegistererWithPrefix("cortex_storegateway_client_", reg)

s := &blocksStoreBalancedSet{
serviceAddresses: serviceAddresses,
dnsProvider: dns.NewProvider(logger, dnsProviderReg, dns.GolangResolverType),
clientsPool: newStoreGatewayClientPool(nil, tlsCfg, logger, reg),
clientsPool: newStoreGatewayClientPool(nil, clientConfig, logger, reg),
}

s.Service = services.NewTimerService(dnsResolveInterval, s.starting, s.resolve, nil)
Expand Down
Loading