Puppet Class: thanos::store

Defined in:
modules/thanos/manifests/store.pp

Overview

Parameters:

  • objstore_account (Hash[String, String])
  • objstore_password (String)
  • http_port (Stdlib::Port::Unprivileged) (defaults to: 11902)
  • grpc_port (Stdlib::Port::Unprivileged) (defaults to: 11901)
  • min_time (Optional[String]) (defaults to: undef)
  • max_time (Optional[String]) (defaults to: undef)
  • consistency_delay (Optional[String]) (defaults to: undef)
  • memlimit_ratio (Float[0, 1]) (defaults to: 0.7)
  • tracing_enabled (Boolean) (defaults to: false)
  • memcached_hosts (Array[Stdlib::Host]) (defaults to: [])
  • memcached_port (Stdlib::Port) (defaults to: 11211)
  • limits_request_series (Integer[0]) (defaults to: 0)
  • limits_request_samples (Integer[0]) (defaults to: 0)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'modules/thanos/manifests/store.pp', line 26

class thanos::store (
    Hash[String, String] $objstore_account,
    String $objstore_password,
    Stdlib::Port::Unprivileged $http_port = 11902,
    Stdlib::Port::Unprivileged $grpc_port = 11901,
    Optional[String] $min_time = undef,
    Optional[String] $max_time = undef,
    Optional[String] $consistency_delay = undef,
    Float[0, 1] $memlimit_ratio = 0.7,
    Boolean $tracing_enabled = false,
    Array[Stdlib::Host] $memcached_hosts = [],
    Stdlib::Port $memcached_port = 11211,
    Integer[0] $limits_request_series = 0,
    Integer[0] $limits_request_samples = 0,
) {
    ensure_packages(['thanos'])

    $http_address = "0.0.0.0:${http_port}"
    $grpc_address = "0.0.0.0:${grpc_port}"
    $service_name = 'thanos-store'
    $data_dir = '/srv/thanos-store'
    $cache_config_file = '/etc/thanos-store/cache.yaml'
    $objstore_config_file = '/etc/thanos-store/objstore.yaml'
    $tracing_config_file = '/etc/thanos-store/tracing-config.yml'

    file { $data_dir:
        ensure => directory,
        mode   => '0750',
        owner  => 'thanos',
        group  => 'thanos',
    }

    file { '/etc/thanos-store':
        ensure => directory,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
    }

    if empty($memcached_hosts) {
      $cache_config = {
        'type'   => 'IN-MEMORY',
        'config' => {
          'max_size'      => '16GB',
          'max_item_size' => '30MB',
        }
      }
    } else {
      $cache_config = {
        'type'   => 'MEMCACHED',
        'config' => {
          'addresses' => $memcached_hosts.map |$h| { "${h}:${memcached_port}" },
        }
      }
    }

    file { $cache_config_file:
        ensure  => present,
        mode    => '0444',
        content => to_yaml($cache_config),
        notify  => Service[$service_name],
    }

    file { $objstore_config_file:
        ensure    => present,
        mode      => '0440',
        owner     => 'thanos',
        group     => 'root',
        show_diff => false,
        content   => template('thanos/objstore.yaml.erb'),
    }

    thanos::tracing { $tracing_config_file:
        service_name => $service_name,
        sampler_type => 'parentbasedalwayssample',
        notify       => Service[$service_name],
    }

    systemd::service { $service_name:
        ensure         => present,
        restart        => true,
        override       => true,
        content        => systemd_template('thanos-store'),
        service_params => {
            enable     => true,
            hasrestart => true,
        },
    }
}