Puppet Class: profile::docker_registry_ha::registry

Defined in:
modules/profile/manifests/docker_registry_ha/registry.pp

Overview

Parameters:

  • username (Any) (defaults to: hiera('docker_registry_ha::username'))
  • hash (Any) (defaults to: hiera('docker_registry_ha::hash'))
  • image_builders (Any) (defaults to: hiera('profile::docker_registry_ha::registry::image_builders', undef))
  • cache_nodes (Any) (defaults to: hiera('cache::nodes', {}))
  • certname (Any) (defaults to: hiera('profile::docker_registry_ha::registry::certname', undef))
  • swift_accounts (Any) (defaults to: hiera('profile::swift::accounts'))
  • swift_auth_url (Any) (defaults to: hiera('profile::docker_registry_ha::registry::swift_auth_url'))
  • swift_account_keys (Any) (defaults to: hiera('profile::swift::accounts_keys'))
  • swift_container (Any) (defaults to: hiera('profile::docker_registry_ha::registry::swift_container', undef))
  • swift_replication_configuration (Any) (defaults to: hiera('profile::docker_registry_ha::registry::swift_replication_configuration'))
  • swift_replication_key (Any) (defaults to: hiera('profile::docker_registry_ha::registry::swift_replication_key'))
  • swift_password (Any) (defaults to: hiera('profile::docker_registry_ha::registry::swift_password', undef))
  • redis_host (Any) (defaults to: hiera('profile::docker_registry_ha::registry::redis_host', undef))
  • redis_port (Any) (defaults to: hiera('profile::docker_registry_ha::registry::redis_port', undef))
  • redis_password (Any) (defaults to: hiera('profile::docker_registry_ha::registry::redis_password', undef))
  • docker_registry_shared_secret (Any) (defaults to: hiera('profile::docker_registry_ha::registry::shared_secret', undef))
  • registry_read_only_mode (Any) (defaults to: hiera('profile::docker_registry_ha::registry::read_only_mode', false))
  • metrics_allowed_hosts (Any) (defaults to: hiera('prometheus_nodes'))
  • deployment_hosts (Array[String]) (defaults to: hiera('deployment_hosts', []))


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'modules/profile/manifests/docker_registry_ha/registry.pp', line 1

class profile::docker_registry_ha::registry(
    # The following variables might be useful elsewhere too
    $username = hiera('docker_registry_ha::username'),
    $hash = hiera('docker_registry_ha::hash'),
    # Which machines are allowed to build images.
    $image_builders = hiera('profile::docker_registry_ha::registry::image_builders', undef),
    # cache text nodes are allowed to connect via HTTP, if defined
    $cache_nodes = hiera('cache::nodes', {}),
    # Storage configuration
    $certname = hiera('profile::docker_registry_ha::registry::certname', undef),
    $swift_accounts = hiera('profile::swift::accounts'),
    $swift_auth_url = hiera('profile::docker_registry_ha::registry::swift_auth_url'),
    # By default, the password will be extracted from swift, but can be overridden
    $swift_account_keys = hiera('profile::swift::accounts_keys'),
    $swift_container = hiera('profile::docker_registry_ha::registry::swift_container', undef),
    $swift_replication_configuration = hiera('profile::docker_registry_ha::registry::swift_replication_configuration'),
    $swift_replication_key = hiera('profile::docker_registry_ha::registry::swift_replication_key'),
    $swift_password = hiera('profile::docker_registry_ha::registry::swift_password', undef),
    $redis_host = hiera('profile::docker_registry_ha::registry::redis_host', undef),
    $redis_port = hiera('profile::docker_registry_ha::registry::redis_port', undef),
    $redis_password = hiera('profile::docker_registry_ha::registry::redis_password', undef),
    $docker_registry_shared_secret = hiera('profile::docker_registry_ha::registry::shared_secret', undef),
    $registry_read_only_mode = hiera('profile::docker_registry_ha::registry::read_only_mode', false),
    $metrics_allowed_hosts = hiera('prometheus_nodes'),
    Array[String] $deployment_hosts = hiera('deployment_hosts', []),
) {
    # if this looks pretty similar to profile::docker::registry
    # is intended.

    require ::network::constants
    # Hiera configurations
    if !$image_builders {
        $builders = $deployment_hosts
    } else {
        $builders = $image_builders
    }

    $varnish_hosts = pick($cache_nodes['text']['eqiad'], []) + pick($cache_nodes['text']['codfw'], [])
    $ats_hosts = pick($cache_nodes['text']['eqiad_ats'], []) + pick($cache_nodes['text']['codfw_ats'], [])
    $http_allowed_hosts = $varnish_hosts + $ats_hosts

    # Nginx frontend
    class { '::sslcert::dhparam': }

    if $certname {
        sslcert::certificate { $certname:
            ensure       => present,
            skip_private => false,
            before       => Service['nginx'],
        }
        $use_puppet = false
    } else {
        $use_puppet = true
    }
    $swift_account = $swift_accounts['docker_registry']
    if !$swift_password {
        $password = $swift_account_keys['docker_registry']
    }
    else {
        $password = $swift_password
    }

    class { '::docker_registry_ha':
        swift_user                      => $swift_account['user'],
        swift_password                  => $password,
        swift_url                       => $swift_auth_url,
        swift_replication_key           => $swift_replication_key,
        swift_replication_configuration => $swift_replication_configuration,
        swift_container                 => $swift_container,
        redis_host                      => $redis_host,
        redis_port                      => $redis_port,
        redis_passwd                    => $redis_password,
        registry_shared_secret          => $docker_registry_shared_secret
    }

    class { '::docker_registry_ha::web':
        docker_username      => $username,
        docker_password_hash => $hash,
        allow_push_from      => $image_builders,
        ssl_settings         => ssl_ciphersuite('nginx', 'mid'),
        use_puppet_certs     => $use_puppet,
        ssl_certificate_name => $certname,
        http_endpoint        => true,
        http_allowed_hosts   => $http_allowed_hosts,
        read_only_mode       => $registry_read_only_mode,
    }

    # T209709
    nginx::status_site { $::fqdn:
        port => 10080,
    }

    ferm::service { 'docker_registry_https':
        proto  => 'tcp',
        port   => 'https',
        srange => '$DOMAIN_NETWORKS',
    }

    ferm::service { 'docker_registry_http_81':
        proto  => 'tcp',
        port   => '81',
        srange => '$DOMAIN_NETWORKS',
    }

    $metrics_ferm_nodes = join($metrics_allowed_hosts, ' ')
    $ferm_srange = "(@resolve((${metrics_ferm_nodes})) @resolve((${metrics_ferm_nodes}), AAAA))"


    ferm::service { 'registry-prometheus-metrics':
        proto  => 'tcp',
        port   => '5001',
        srange => $ferm_srange,
    }


    # Monitoring
    # HTTP should return 403 forbidden
    monitoring::service { 'check_docker_registry_http':
        description   => 'Docker registry HTTP interface',
        check_command => 'check_http_port_status!81!403',
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Docker',
    }
    # This will test both nginx and the docker registry application
    monitoring::service { 'check_docker_registry_https':
        description   => 'Docker registry HTTPS interface',
        check_command => "check_https_url_for_string!${::fqdn}!/v2/wikimedia-stretch/manifests/latest!schemaVersion",
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Docker',
    }

    # This will query /debug/health registry endpoint on 5001 debug server
    monitoring::service { 'check_docker_registry_health':
        description   => 'Docker registry health',
        check_command => "check_http_url_for_regexp_on_port!${::fqdn}:5001!5001!/debug/health!\'\\\\{\\\\}\'",
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Docker',
    }

    nrpe::monitor_systemd_unit_state{ 'docker-registry': }

}