44 lines
1.2 KiB
Puppet
44 lines
1.2 KiB
Puppet
# manage helm
|
|
class rke2::helm (
|
|
Enum['server', 'agent'] $node_type = $rke2::node_type,
|
|
Stdlib::Fqdn $bootstrap_node = $rke2::bootstrap_node,
|
|
Boolean $helm_install = $rke2::helm_install,
|
|
Hash $helm_repos = $rke2::helm_repos
|
|
){
|
|
|
|
# when installing helm, manage the repos
|
|
if $helm_install {
|
|
|
|
package {'helm':
|
|
ensure => installed,
|
|
}
|
|
|
|
file { '/etc/helm':
|
|
ensure => directory,
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0755',
|
|
}
|
|
|
|
# on the controller nodes only, and after 3 master nodes exist
|
|
if $node_type == 'server' and $facts['k8s_masters'] and $facts['k8s_masters'] > 2 {
|
|
|
|
# check if the repo already exists
|
|
$helm_repos.each | String $repo, Stdlib::HTTPSUrl $url | {
|
|
|
|
# if repo isnt in repo list from helm, install it
|
|
if ! $facts['helm_repos'].any |$existing| { $existing['name'] == $repo } {
|
|
|
|
exec { "helm_add_repo_${repo}":
|
|
command => "helm repo add ${repo} ${url} --repository-config /etc/helm/repositories.yaml",
|
|
path => ['/usr/bin'],
|
|
environment => [
|
|
'KUBECONFIG=/etc/rancher/rke2/rke2.yaml',
|
|
],
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|