Puppet Class: profile::kubernetes::deployment_server

Defined in:
modules/profile/manifests/kubernetes/deployment_server.pp

Overview

Class makes sure we got a deployment server ready

Parameters:

  • services (Hash[String, Any]) (defaults to: hiera('profile::kubernetes::deployment_server::services', {}))
  • tokens (Hash[String, Any]) (defaults to: hiera('profile::kubernetes::deployment_server::tokens', {}))
  • git_owner (String) (defaults to: hiera('profile::kubernetes::deployment_server::git_owner'))
  • git_group (String) (defaults to: hiera('profile::kubernetes::deployment_server::git_group'))


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

class profile::kubernetes::deployment_server(
    Hash[String, Any] $services=hiera('profile::kubernetes::deployment_server::services', {}),
    Hash[String, Any] $tokens=hiera('profile::kubernetes::deployment_server::tokens', {}),
    String $git_owner=hiera('profile::kubernetes::deployment_server::git_owner'),
    String $git_group=hiera('profile::kubernetes::deployment_server::git_group'),
){
    include profile::kubernetes::deployment_server::helmfile
    class { '::helm': }

    # The deployment script
    # TODO: remove this when helmfile is used in production
    file { '/usr/local/bin/scap-helm':
        ensure => file,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => 'puppet:///modules/profile/kubernetes/scap-helm.sh',
    }


    file { '/etc/kubernetes':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
    }

    $envs = {
        'eqiad' => 'kubemaster.svc.eqiad.wmnet',
        'codfw' => 'kubemaster.svc.codfw.wmnet',
        'staging' => 'neon.eqiad.wmnet',
    }

    $real_services = deep_merge($services, $tokens)

    # Now populate the /etc/kubernetes/ kubeconfig resources
    $envs.each |String $env, String $master_host| {
        $real_services.each |String $service, Hash $data| {
            # lint:ignore:variable_scope
            if has_key($data, 'username') and has_key($data, 'token') {
                k8s::kubeconfig { "/etc/kubernetes/${service}-${env}.config":
                    master_host => $master_host,
                    username    => $data['username'],
                    token       => $data['token'],
                    group       => $data['group'],
                    mode        => $data['mode'],
                    namespace   => $data['namespace'],
                }
            }
            # lint:endignore
        }
    }
    # Add a script to profile.d with functions to set the configuration for kubernetes.
    file { '/etc/profile.d/kube-env.sh':
        ensure => present,
        source => 'puppet:///modules/profile/kubernetes/kube-env.sh',
        mode   => '0555',
    }
}