Module: Pangea::Kubernetes::BareMetal::CloudInit
- Defined in:
- lib/pangea/kubernetes/bare_metal/cloud_init.rb
Overview
Generates user_data for NixOS servers running k3s or vanilla Kubernetes via blackmatter-kubernetes modules.
The NixOS boot sequence reads /etc/pangea/cluster-config.json and applies the corresponding blackmatter-kubernetes module (k3s or kubernetes).
Config is cloud-agnostic — the same JSON drives k3s/k8s setup on AWS EC2, GCP GCE, Azure VMs, and Hetzner servers.
Two output formats:
:shell — bash script (NixOS AMIs with amazon-init, default)
:cloud_config — #cloud-config YAML (providers with real cloud-init)
Class Method Summary collapse
-
.generate(cluster_name:, distribution: :k3s, profile: 'cloud-server', distribution_track: '1.34', role: 'server', node_index: 0, cluster_init: false, network_id: nil, join_server: nil, fluxcd: nil, argocd: nil, k3s: nil, kubernetes: nil, secrets: nil, vpn: nil, bootstrap_secrets: nil, persistent_state: nil, format: :shell) ⇒ String
Generate user_data for a NixOS Kubernetes node.
Class Method Details
.generate(cluster_name:, distribution: :k3s, profile: 'cloud-server', distribution_track: '1.34', role: 'server', node_index: 0, cluster_init: false, network_id: nil, join_server: nil, fluxcd: nil, argocd: nil, k3s: nil, kubernetes: nil, secrets: nil, vpn: nil, bootstrap_secrets: nil, persistent_state: nil, format: :shell) ⇒ String
Generate user_data for a NixOS Kubernetes node.
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 |
# File 'lib/pangea/kubernetes/bare_metal/cloud_init.rb', line 57 def generate(cluster_name:, distribution: :k3s, profile: 'cloud-server', distribution_track: '1.34', role: 'server', node_index: 0, cluster_init: false, network_id: nil, join_server: nil, fluxcd: nil, argocd: nil, k3s: nil, kubernetes: nil, secrets: nil, vpn: nil, bootstrap_secrets: nil, persistent_state: nil, format: :shell) config = { 'cluster_name' => cluster_name, 'distribution' => distribution.to_s, 'profile' => profile, 'distribution_track' => distribution_track, 'role' => normalize_role(distribution, role), 'node_index' => node_index, 'cluster_init' => cluster_init } config['network_id'] = network_id if network_id config['join_server'] = join_server if join_server config['fluxcd'] = fluxcd if fluxcd config['argocd'] = stringify_keys_recursive(argocd) if argocd && !argocd.empty? config['k3s'] = stringify_keys_recursive(k3s) if k3s && !k3s.empty? config['kubernetes'] = stringify_keys_recursive(kubernetes) if kubernetes && !kubernetes.empty? config['secrets'] = stringify_keys_recursive(secrets) if secrets && !secrets.empty? config['vpn'] = stringify_keys_recursive(vpn) if vpn && !vpn.empty? config['bootstrap_secrets'] = stringify_keys_recursive(bootstrap_secrets) if bootstrap_secrets && !bootstrap_secrets.empty? config['persistent_state'] = stringify_keys_recursive(persistent_state) if persistent_state && !persistent_state.empty? case format.to_sym when :cloud_config generate_cloud_config(config) else generate_shell_script(config) end end |