|
| 1 | +# 3. Connect AKS cluster to CAST AI with enabled Kvisor security agent. |
| 2 | + |
| 3 | +# Configure Data sources and providers required for CAST AI connection. |
| 4 | +data "azurerm_subscription" "current" {} |
| 5 | + |
| 6 | +# Configure AKS cluster connection to CAST AI using CAST AI aks-cluster module with enabled Kvisor security agent. |
| 7 | +module "castai-aks-cluster" { |
| 8 | + source = "castai/aks/castai" |
| 9 | + |
| 10 | + kvisor_grpc_addr = var.kvisor_grpc_addr |
| 11 | + |
| 12 | + # Kvisor is an open-source security agent from CAST AI. |
| 13 | + # install_security_agent by default installs Kvisor controller (k8s: deployment) |
| 14 | + # https://docs.cast.ai/docs/kvisor |
| 15 | + install_security_agent = true |
| 16 | + |
| 17 | + # Kvisor configuration examples, enable certain features: |
| 18 | + kvisor_values = [ |
| 19 | + yamlencode({ |
| 20 | + controller = { |
| 21 | + extraArgs = { |
| 22 | + # UI: Vulnerability management configuration = API: IMAGE_SCANNING |
| 23 | + "image-scan-enabled" = true |
| 24 | + # UI: Compliance configuration = API: CONFIGURATION_SCANNING |
| 25 | + "kube-bench-enabled" = true |
| 26 | + "kube-linter-enabled" = true |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + # UI: Runtime Security = API: RUNTIME_SECURITY |
| 31 | + agent = { |
| 32 | + # In order to enable Runtime security set agent.enabled to true. |
| 33 | + # This will install Kvisor agent (k8s: daemonset) |
| 34 | + # https://docs.cast.ai/docs/sec-runtime-security |
| 35 | + "enabled" = true |
| 36 | + |
| 37 | + extraArgs = { |
| 38 | + # Runtime security configuration examples: |
| 39 | + # By default, most users enable the eBPF events and file hash enricher. |
| 40 | + # For all flag explanations and code, see: https://github.com/castai/kvisor/blob/main/cmd/agent/daemon/daemon.go |
| 41 | + "ebpf-events-enabled" = true |
| 42 | + "file-hash-enricher-enabled" = true |
| 43 | + # other examples |
| 44 | + "netflow-enabled" = false |
| 45 | + "netflow-export-interval" = "30s" |
| 46 | + "ebpf-program-metrics-enabled" = false |
| 47 | + "prom-metrics-export-enabled" = false |
| 48 | + "prom-metrics-export-interval" = "30s" |
| 49 | + "process-tree-enabled" = false |
| 50 | + } |
| 51 | + } |
| 52 | + }) |
| 53 | + ] |
| 54 | + |
| 55 | + # Deprecated, leave this empty, to prevent setting defaults. |
| 56 | + kvisor_controller_extra_args = {} |
| 57 | + |
| 58 | + # Everything else... |
| 59 | + |
| 60 | + wait_for_cluster_ready = false |
| 61 | + |
| 62 | + install_workload_autoscaler = false |
| 63 | + install_pod_mutator = false |
| 64 | + delete_nodes_on_disconnect = var.delete_nodes_on_disconnect |
| 65 | + |
| 66 | + api_url = var.castai_api_url |
| 67 | + castai_api_token = var.castai_api_token |
| 68 | + grpc_url = var.castai_grpc_url |
| 69 | + |
| 70 | + aks_cluster_name = var.cluster_name |
| 71 | + aks_cluster_region = var.cluster_region |
| 72 | + node_resource_group = azurerm_kubernetes_cluster.this.node_resource_group |
| 73 | + resource_group = azurerm_kubernetes_cluster.this.resource_group_name |
| 74 | + |
| 75 | + subscription_id = data.azurerm_subscription.current.subscription_id |
| 76 | + tenant_id = data.azurerm_subscription.current.tenant_id |
| 77 | + |
| 78 | + default_node_configuration = module.castai-aks-cluster.castai_node_configurations["default"] |
| 79 | + |
| 80 | + node_configurations = { |
| 81 | + default = { |
| 82 | + disk_cpu_ratio = 25 |
| 83 | + subnets = [azurerm_subnet.internal.id] |
| 84 | + tags = var.tags |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments