feat: k8s helm rework (#396)

- remove helm-generated-yaml, replace with helm execs
- template/parameterise ceph csi

Reviewed-on: #396
This commit was merged in pull request #396.
This commit is contained in:
2025-09-20 17:40:41 +10:00
parent 4e77fb7ee7
commit 762f415d2d
22 changed files with 646 additions and 13979 deletions
+35
View File
@@ -7,6 +7,13 @@ class rke2::config (
Stdlib::Fqdn $bootstrap_node = $rke2::bootstrap_node,
String $node_token = $rke2::node_token,
Array[String[1]] $extra_config_files = $rke2::extra_config_files,
Boolean $csi_ceph_enable = $rke2::csi_ceph_enable,
Array[String] $csi_ceph_files = $rke2::csi_ceph_files,
Array[String] $csi_ceph_templates = $rke2::csi_ceph_templates,
Optional[String[1]] $csi_ceph_key = $rke2::csi_ceph_key,
Optional[String[1] ] $csi_ceph_clusterid = $rke2::csi_ceph_clusterid,
Optional[Array[String]] $csi_ceph_monitors = $rke2::csi_ceph_monitors,
Optional[String[1]] $csi_ceph_poolname = $rke2::csi_ceph_poolname,
){
# if agent, add token. what other fields should i add?
@@ -83,5 +90,33 @@ class rke2::config (
require => Service['rke2-server'],
}
}
# manage ceph files
if $csi_ceph_enable {
$csi_ceph_files.each |$file| {
file {"/var/lib/rancher/rke2/server/manifests/${file}.yaml":
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => "puppet:///modules/rke2/${file}.yaml",
require => Service['rke2-server'],
}
}
$csi_ceph_templates.each |$file| {
file {"/var/lib/rancher/rke2/server/manifests/${file}.yaml":
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template("rke2/${file}.yaml.erb"),
require => Service['rke2-server'],
}
}
}
}
}
+38 -1
View File
@@ -1,4 +1,3 @@
# manage helm
class rke2::helm (
Enum['server', 'agent'] $node_type = $rke2::node_type,
@@ -39,6 +38,44 @@ class rke2::helm (
}
}
}
# install specific helm charts to bootstrap environment
$plb_cmd = 'helm install purelb purelb/purelb \
--create-namespace \
--namespace=purelb \
--repository-config /etc/helm/repositories.yaml'
exec { 'install_purelb':
command => $plb_cmd,
path => ['/usr/bin', '/bin'],
environment => ['KUBECONFIG=/etc/rancher/rke2/rke2.yaml'],
unless => 'helm list -n purelb | grep -q ^purelb',
}
$cm_cmd = 'helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--set crds.enabled=true \
--repository-config /etc/helm/repositories.yaml'
exec { 'install_cert_manager':
command => $cm_cmd,
path => ['/usr/bin', '/bin'],
environment => ['KUBECONFIG=/etc/rancher/rke2/rke2.yaml'],
unless => 'helm list -n cert-manager | grep -q ^cert-manager',
}
$r_cmd = 'helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--create-namespace \
--set hostname=rancher.main.unkin.net \
--set bootstrapPassword=admin \
--set ingress.tls.source=secret \
--repository-config /etc/helm/repositories.yaml'
exec { 'install_rancher':
command => $r_cmd,
path => ['/usr/bin', '/bin'],
environment => ['KUBECONFIG=/etc/rancher/rke2/rke2.yaml'],
unless => 'helm list -n cattle-system | grep -q ^rancher',
}
}
}
}
+7
View File
@@ -12,6 +12,13 @@ class rke2 (
Hash $helm_repos = $rke2::params::helm_repos,
Array[String[1]] $extra_config_files = $rke2::params::extra_config_files,
Stdlib::HTTPUrl $container_archive_source = $rke2::params::container_archive_source,
Boolean $csi_ceph_enable = $rke2::params::csi_ceph_enable,
Array[String] $csi_ceph_files = $rke2::params::csi_ceph_files,
Array[String] $csi_ceph_templates = $rke2::params::csi_ceph_templates,
Optional[String[1]] $csi_ceph_key = $rke2::params::csi_ceph_key,
Optional[String[1] ] $csi_ceph_clusterid = $rke2::params::csi_ceph_clusterid,
Optional[Array[String]] $csi_ceph_monitors = $rke2::params::csi_ceph_monitors,
Optional[String[1]] $csi_ceph_poolname = $rke2::params::csi_ceph_poolname,
) inherits rke2::params {
include rke2::install
+7
View File
@@ -12,4 +12,11 @@ class rke2::params (
Hash $helm_repos = {},
Array[String[1]] $extra_config_files = [],
Stdlib::HTTPUrl $container_archive_source = 'https://github.com/rancher/rke2/releases/download',
Boolean $csi_ceph_enable = false,
Array[String] $csi_ceph_files = [],
Array[String] $csi_ceph_templates = [],
Optional[String[1]] $csi_ceph_key = undef,
Optional[String[1] ] $csi_ceph_clusterid = undef,
Optional[Array[String]] $csi_ceph_monitors = undef,
Optional[String[1]] $csi_ceph_poolname = undef,
) {}