Puppet Class: kubeinstall::install::krew

Defined in:
manifests/install/krew.pp

Summary

A short summary of the purpose of this class

Overview

A description of what this class does

Examples:

include kubeinstall::install::krew

Parameters:

  • version (String) (defaults to: $kubeinstall::krew_version)
  • manage_git (Boolean) (defaults to: true)


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
# File 'manifests/install/krew.pp', line 7

class kubeinstall::install::krew (
  String  $version    = $kubeinstall::krew_version,
  Boolean $manage_git = true,
)
{
  # git package could be controlled in different place of role/profile
  # therefore make it possible to disable it here
  if $manage_git {
    include kubeinstall::system::git
  }

  $archive   = 'krew.tar.gz'
  $source    = "https://github.com/kubernetes-sigs/krew/releases/download/v${version}/krew.tar.gz"

  file { '/usr/local/krew':
    ensure => directory,
  }

  archive { $archive:
    path         => "/tmp/${archive}",
    source       => $source,
    extract      => true,
    extract_path => '/usr/local/krew',
    cleanup      => true,
    creates      => '/usr/local/krew/krew-linux_amd64',
    require      => File['/usr/local/krew'],
  }

  if $::facts['kernel'] == 'Linux' and $::facts['os']['architecture'] == 'x86_64' {
    exec { '/usr/local/krew/krew-linux_amd64 install krew':
      path        => '/root/.krew/bin:/usr/bin:/bin:/usr/sbin:/sbin',
      environment => [
        'KUBECONFIG=/etc/kubernetes/admin.conf',
      ],
      onlyif      => 'test -x /usr/local/krew/krew-linux_amd64',
      unless      => 'kubectl krew version',
      require     => Archive[$archive],
    }

    file { '/etc/profile.d/krew.sh':
      ensure => file,
      source => 'puppet:///modules/kubeinstall/krew/profile.d.sh',
    }
  }
}