Puppet Class: calico

Defined in:
modules/calico/manifests/init.pp

Overview

Class calico

Installs calico-cni and calicoctl

Parameters:

  • master_fqdn (Stdlib::Host)
  • calicoctl_username (String)
  • calicoctl_token (String)
  • calico_version (String) (defaults to: '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
# File 'modules/calico/manifests/init.pp', line 4

class calico(
    Stdlib::Host            $master_fqdn,
    String                  $calicoctl_username,
    String                  $calicoctl_token,
    String                  $calico_version     = '3',
) {
    file { '/etc/calico':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    case $calico_version {
        '3': {
            apt::package_from_component { 'calico-future':
                component => 'component/calico-future',
                packages  => ['calicoctl', 'calico-cni'],
            }

            # Create a kubeconfig for calicoctl to use.
            $kubeconfig = '/etc/calico/calicoctl-kubeconfig'
            k8s::kubeconfig { $kubeconfig:
                master_host => $master_fqdn,
                username    => $calicoctl_username,
                token       => $calicoctl_token,
            }

            file { '/etc/calico/calicoctl.cfg':
                ensure  => present,
                owner   => 'root',
                group   => 'root',
                mode    => '0444',
                content => template('calico/calicoctl.cfg_v3.erb'),
            }
        }
        default: { fail('Unsupported calico version') }
    }
}