Puppet Class: profile::imagecatalog

Defined in:
modules/profile/manifests/imagecatalog.pp

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • kubernetes_cluster_groups (Hash[String, Hash]) (defaults to: lookup('kubernetes_cluster_groups'))
  • tokens (Hash[String, Hash[String, Hash]]) (defaults to: lookup('profile::kubernetes::infrastructure_users', {default_value => {}}))
  • deployment_server (Stdlib::Fqdn) (defaults to: lookup('deployment_server'))


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
# File 'modules/profile/manifests/imagecatalog.pp', line 2

class profile::imagecatalog (
    Hash[String, Hash] $kubernetes_cluster_groups = lookup('kubernetes_cluster_groups'),
    Hash[String, Hash[String, Hash]] $tokens      = lookup('profile::kubernetes::infrastructure_users', {default_value => {}}),
    Stdlib::Fqdn $deployment_server               = lookup('deployment_server'),
) {
    $kubernetes_clusters = $kubernetes_cluster_groups.map |$cluster_group, $clusters| {
        $_tokens = $tokens[$cluster_group]
        $token = $_tokens['imagecatalog']
        if ($token) {
            $clusters.map |$cluster, $cluster_data| {
                $kubeconfig_path = "/etc/kubernetes/imagecatalog-${cluster}.config"
                if ($cluster_data['imagecatalog']) {
                    k8s::kubeconfig{ $kubeconfig_path:
                        master_host => $cluster_data['master'],
                        username    => 'imagecatalog',
                        token       => $token['token'],
                        owner       => 'imagecatalog',
                        group       => 'imagecatalog',
                    }
                    [$cluster, $kubeconfig_path]
                }
            }
        }
    }
    .reduce([]) |$acc, $v| { $acc + $v }  # Flatten one level to get an array of [cluster, path] tuples...
    .filter |$v| { $v =~ NotUndef }       # and remove the undef entries for clusters where imagecatalog isn't enabled.

    $ensure = $deployment_server ? {
        $::fqdn => 'present',
        default => 'absent'
    }

    class {'imagecatalog':
        port                => 3691,
        data_dir            => '/srv/deployment/imagecatalog',
        kubernetes_clusters => $kubernetes_clusters,
        ensure              => $ensure,
    }
}