Module: Pangea::Kubernetes::Backends::AzureAks
- Includes:
- Base
- Defined in:
- lib/pangea/kubernetes/backends/azure_aks.rb
Overview
Azure AKS backend — creates managed AKS clusters. AKS bundles default node pool with the cluster resource, so create_cluster handles both.
Class Method Summary collapse
- .backend_name ⇒ Object
-
.create_cluster(ctx, name, config, result, tags) ⇒ Object
Create AKS cluster with default node pool.
-
.create_iam(_ctx, _name, _config, _tags) ⇒ Object
AKS uses managed identity — no standalone IAM resources needed.
-
.create_network(ctx, name, config, tags) ⇒ Object
Create Azure VNet + subnet.
-
.create_node_pool(ctx, name, cluster_ref, pool_config, tags) ⇒ Object
Create additional AKS node pool.
- .load_provider! ⇒ Object
- .managed_kubernetes? ⇒ Boolean
- .required_gem ⇒ Object
Methods included from Base
Class Method Details
.backend_name ⇒ Object
29 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 29 def backend_name = :azure |
.create_cluster(ctx, name, config, result, tags) ⇒ Object
Create AKS cluster with default node pool
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 81 def create_cluster(ctx, name, config, result, ) system_pool = config.system_node_pool rg_name = config.resource_group_name || result.network&.dig(:resource_group)&.name || "#{name}-rg" dns_prefix = config.dns_prefix || name.to_s cluster_attrs = { name: "#{name}-cluster", resource_group_name: rg_name, location: config.region, dns_prefix: dns_prefix, kubernetes_version: config.kubernetes_version, default_node_pool: { name: system_pool.name.to_s[0..11], # AKS max 12 chars vm_size: system_pool.instance_types.first, node_count: system_pool.effective_desired_size, min_count: system_pool.min_size, max_count: system_pool.max_size, enable_auto_scaling: true, os_disk_size_gb: system_pool.disk_size_gb }, identity: { type: 'SystemAssigned' }, tags: } cluster_attrs[:sku_tier] = 'Standard' if [:Environment] == 'production' # Network profile if result.network&.dig(:subnet) cluster_attrs[:default_node_pool][:vnet_subnet_id] = result.network[:subnet].id end ctx.azurerm_kubernetes_cluster(:"#{name}_cluster", cluster_attrs) end |
.create_iam(_ctx, _name, _config, _tags) ⇒ Object
AKS uses managed identity — no standalone IAM resources needed
76 77 78 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 76 def create_iam(_ctx, _name, _config, ) Architecture::IamResult.new end |
.create_network(ctx, name, config, tags) ⇒ Object
Create Azure VNet + subnet
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 43 def create_network(ctx, name, config, ) network = Architecture::AzureNetworkResult.new network.resource_group = ctx.azurerm_resource_group( :"#{name}_rg", name: "#{name}-rg", location: config.region, tags: ) network.vnet = ctx.azurerm_virtual_network( :"#{name}_vnet", name: "#{name}-vnet", resource_group_name: network.resource_group.ref(:name), location: config.region, address_space: [config.network&.vpc_cidr || '10.0.0.0/16'], tags: ) network.vpc = network.vnet subnet = ctx.azurerm_subnet( :"#{name}_subnet", name: "#{name}-subnet", resource_group_name: network.resource_group.ref(:name), virtual_network_name: network.vnet.ref(:name), address_prefixes: [config.network&.pod_cidr || '10.0.1.0/24'] ) network.add_subnet(:subnet, subnet) network end |
.create_node_pool(ctx, name, cluster_ref, pool_config, tags) ⇒ Object
Create additional AKS node pool
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 116 def create_node_pool(ctx, name, cluster_ref, pool_config, ) pool_name = :"#{name}_#{pool_config.name}" node_pool_attrs = { name: pool_config.name.to_s[0..11], # AKS max 12 chars kubernetes_cluster_id: cluster_ref.id, vm_size: pool_config.instance_types.first, node_count: pool_config.effective_desired_size, min_count: pool_config.min_size, max_count: pool_config.max_size, enable_auto_scaling: true, os_disk_size_gb: pool_config.disk_size_gb, tags: .merge(NodePool: pool_config.name.to_s) } node_pool_attrs[:node_labels] = pool_config.labels if pool_config.labels.any? if pool_config.taints.any? node_pool_attrs[:node_taints] = pool_config.taints.map do |t| "#{t[:key]}=#{t[:value]}:#{t[:effect]}" end end ctx.azurerm_kubernetes_cluster_node_pool(pool_name, node_pool_attrs) end |
.load_provider! ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 33 def load_provider! require required_gem rescue LoadError => e raise LoadError, "Backend :azure requires gem 'pangea-azure'. " \ "Add it to your Gemfile: gem 'pangea-azure'\n" \ "Original error: #{e.}" end |
.managed_kubernetes? ⇒ Boolean
30 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 30 def managed_kubernetes? = true |
.required_gem ⇒ Object
31 |
# File 'lib/pangea/kubernetes/backends/azure_aks.rb', line 31 def required_gem = 'pangea-azure' |