Puppet Class: profile::calico::builder

Defined in:
modules/profile/manifests/calico/builder.pp

Overview

Parameters:

  • calico_release (Any) (defaults to: hiera('profile::calico::builder::calico_release'))
  • directory (Any) (defaults to: hiera('profile::calico::builder::directory'))
  • proxy_address (Any) (defaults to: hiera('profile::calico::builder::proxy_address'))
  • registry_address (Any) (defaults to: hiera('docker::registry'))
  • registry_user (Any) (defaults to: hiera('docker::registry_user'))


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
# File 'modules/profile/manifests/calico/builder.pp', line 1

class profile::calico::builder(
    $calico_release=hiera('profile::calico::builder::calico_release'),
    # Calico builder directory
    $directory=hiera('profile::calico::builder::directory'),
    # Proxy url, if present
    $proxy_address=hiera('profile::calico::builder::proxy_address'),
    $registry_address=hiera('docker::registry'),
    $registry_user=hiera('docker::registry_user'),
) {

    # Needs docker to be installed and working
    require ::docker

    # Taken from http://docs.projectcalico.org/$version/releases/
    $releases = {
        'v2.2.0' => { 'node' => '1.2.0', 'cni' => '1.8.3', 'kube-policy-controller' => '0.6.0' }
    }
    $release = $releases[$calico_release]
    $node_version = $release['node']
    $k8s_policy_version = $release['kube-policy-controller']
    $cni_version = $release['cni']
    # Needed to build install go
    apt::repository{ 'component-ci':
        uri        => 'http://apt.wikimedia.org/wikimedia',
        dist       => "${::lsbdistcodename}-wikimedia",
        components => 'component/ci',
        source     => false,
    }

    package { 'golang-go':
        ensure => present,
    }

    require_package('build-essential', 'fakeroot')

    if $proxy_address {
        file_line { 'Docker proxy':
            ensure => present,
            path   => '/etc/default/docker',
            line   => "export http_proxy=${proxy_address}",
            match  => '^\#?export http_proxy=',
            notify => Service['docker'],
        }
    }


    # Glide is needed to build calicoctl
    # It is a go binary that is available on debian unstable
    file { '/usr/local/bin/glide':
        ensure => present,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
        # lint:ignore:puppet_url_without_modules
        source => 'puppet:///volatile/misc/glide-binaries/glide',
        # lint:endignore
    }

    # User for the build needs to be part of the docker group,
    # as building depends on docker.
    user { 'calicobuild':
        ensure     => present,
        shell      => '/bin/bash',
        system     => true,
        managehome => true,
        groups     => 'docker',
    }

    git::clone{ 'operations/calico-containers':
        branch    => 'master',
        owner     => 'calicobuild',
        require   => User['calicobuild'],
        directory => "${directory}/calico-containers",
    }

    # Script to build the project and push it to our registry
    file { '/usr/local/bin/build-calico':
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        content => template('profile/calico/build-calico.sh.erb'),
    }

    # Clone the calico CNI plugin repository and the calico policy controller for kubernetes repository
    git::clone { 'operations/calico-cni':
        branch    => 'master',
        owner     => 'calicobuild',
        require   => User['calicobuild'],
        directory => "${directory}/calico-cni",

    }

    git::clone { 'operations/calico-k8s-policy-controller':
        branch    => $k8s_policy_version,
        owner     => 'calicobuild',
        require   => User['calicobuild'],
        directory => "${directory}/calico-k8s-policy-controller",

    }

}