Skip to content

Commit 00b632f

Browse files
Eric Kuftaclaude
andcommitted
feat(eks-example): expose agent_values and cluster_controller_values for Helm customization
Adds agent_values and cluster_controller_values variables to the eks_cluster_existing example, enabling users to pass arbitrary Helm values (e.g. additionalEnv) to the castai-agent and cluster-controller charts without modifying castai.tf directly. Also fixes stale variable references in README and terraform.tfvars.example. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0c33c45 commit 00b632f

File tree

4 files changed

+59
-15
lines changed

4 files changed

+59
-15
lines changed

examples/eks/eks_cluster_existing/README.MD

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ Example configuration should be analysed in the following order:
99

1010
# Usage
1111
1. Copy `terraform.tfvars.example` to `terraform.tfvars`
12-
2. Update `terraform.tfvars` file with your cluster name, cluster region, vpc_id, cluster_security_group_id, node_security_group_id, subnets and CAST AI API token.
12+
2. Update `terraform.tfvars` file with your cluster name, cluster region, and CAST AI API token.
1313

1414
| Variable | Description |
1515
| --- | --- |
16-
| cluster_name = "" | Name of cluster |
17-
| cluster_region = "" | Name of region of cluster |
18-
| castai_api_token = "" | Cast api token |
19-
| vpc_id = "" | Virtual Private Cloud(VPC) id |
20-
| cluster_security_group_id = "" | Cluster security group id |
21-
| node_security_group_id = "" | Node security group id |
22-
| subnets = ["", ""] | Public subnets of cluster |
16+
| `cluster_name` | Name of the EKS cluster |
17+
| `cluster_region` | AWS region where the cluster runs |
18+
| `castai_api_token` | CAST AI API token from console.cast.ai → API Access keys |
19+
| `profile` | AWS CLI profile to use (default: `"default"`) |
20+
| `delete_nodes_on_disconnect` | Delete CAST AI-provisioned nodes on disconnect (default: `true`; set to `false` for production) |
21+
| `tags` | Optional map of tags applied to new nodes |
22+
| `agent_values` | Optional list of YAML Helm values for castai-agent. Example: `[<<-EOF\n additionalEnv:\n MY_VAR: "value"\nEOF\n]` — see [Customizing Helm values](#customizing-helm-values-additionalenv-and-more) |
23+
| `cluster_controller_values` | Optional list of YAML Helm values for castai-cluster-controller, same format as `agent_values` |
2324

2425
3. Initialize Terraform. Under example root folder run:
2526
```
@@ -44,4 +45,22 @@ AWS CLI profile is already set to default, override if only required.
4445
> used by CAST AI has to be present. Example of entry can be found [here](https://github.com/castai/terraform-provider-castai/blob/157babd57b0977f499eb162e9bee27bee51d292a/examples/eks/eks_cluster_autoscaler_polices/eks.tf#L28-L38).
4546
4647

48+
# Customizing Helm values (additionalEnv and more)
49+
50+
The `agent_values` and `cluster_controller_values` variables accept lists of YAML-formatted Helm values that are merged into the respective CAST AI Helm chart releases. This is the recommended way to configure environment variables, proxy settings, resource limits, or any other chart-level option.
51+
52+
Example `terraform.tfvars` entry to set environment variables on the agent:
53+
54+
```hcl
55+
agent_values = [<<-EOF
56+
additionalEnv:
57+
HTTP_PROXY: "http://proxy.example.com:8080"
58+
HTTPS_PROXY: "http://proxy.example.com:8080"
59+
NO_PROXY: "169.254.169.254,localhost"
60+
EOF
61+
]
62+
```
63+
64+
Use `cluster_controller_values` for the same pattern applied to the cluster-controller component.
65+
4766
Please refer to this guide if you run into any issues https://docs.cast.ai/docs/terraform-troubleshooting

examples/eks/eks_cluster_existing/castai.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ module "castai_eks_cluster" {
190190
# Installs network monitor
191191
install_egressd = true
192192

193+
# Optional: pass additional Helm values to castai-agent and cluster-controller.
194+
# This is useful for setting environment variables (additionalEnv), resource limits,
195+
# pod annotations, proxy settings, etc.
196+
#
197+
# Example terraform.tfvars entry:
198+
#
199+
# agent_values = [<<-EOF
200+
# additionalEnv:
201+
# MY_ENV_VAR: "my-value"
202+
# HTTP_PROXY: "http://proxy.example.com:8080"
203+
# EOF
204+
# ]
205+
#
206+
agent_values = var.agent_values
207+
cluster_controller_values = var.cluster_controller_values
208+
193209
# depends_on helps Terraform with creating proper dependencies graph in case of resource creation and in this case destroy.
194210
# module "castai-eks-cluster" has to be destroyed before module "castai-eks-role-iam".
195211
depends_on = [module.castai_eks_role_iam]
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
cluster_name = ""
2-
cluster_region = ""
3-
castai_api_token = ""
4-
grpc_url = ""
5-
vpc_id = ""
6-
subnets = ["", ""]
7-
profile = "default" # default aws cli profile is used, override if needed.
1+
cluster_name = ""
2+
cluster_region = ""
3+
castai_api_token = ""
4+
profile = "default" # default aws cli profile is used, override if needed.

examples/eks/eks_cluster_existing/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ variable "tags" {
4444
description = "Optional tags for new cluster nodes. This parameter applies only to new nodes - tags for old nodes are not reconciled."
4545
default = {}
4646
}
47+
48+
variable "agent_values" {
49+
type = list(string)
50+
description = "List of YAML-formatted Helm values for the castai-agent chart. Use this to set additionalEnv, resource limits, pod annotations, etc."
51+
default = []
52+
}
53+
54+
variable "cluster_controller_values" {
55+
type = list(string)
56+
description = "List of YAML-formatted Helm values for the castai-cluster-controller chart. Use this to set additionalEnv, resource limits, pod annotations, etc."
57+
default = []
58+
}

0 commit comments

Comments
 (0)