Autogenerate Helm and CRD Vars#121
Conversation
f6c168a to
e83a36e
Compare
|
this looks promising will take a look in detail on monday |
alex-hunt-materialize
left a comment
There was a problem hiding this comment.
This is a great idea, but I really don't want us manually parsing and building HCL. Terraform supports json, or we could use a proper HCL parser. I lean toward just converting it all to json, as that opens the door for customers to use their own tools for this too.
I didn't review most of this PR, as it is just a draft. I only did a quick skim of the generator code.
|
|
||
| # Rollout configuration | ||
| force_rollout = var.force_rollout | ||
| request_rollout = var.request_rollout |
There was a problem hiding this comment.
We should get consistent about how we handle this stuff. These are removed, while most of the others are marked as deprecated.
There was a problem hiding this comment.
yeah, marking this as deprecated is probably for the best.
Great ideas I'll give both a shot. |
6a3990f to
63cb495
Compare
|
@alex-hunt-materialize I went down a rabbit hole with variables in json.tf... the variable type ends up being a string with horrific formatting. We could also use python-hcl2 to output hcl, but it also has shit formatting for complex variables. Hand rolling hcl gen and formatting is potentially the ugliest option to code up, but it generates the cleanest output which I think is worth prioritizing. |
83e2a04 to
a1e37fb
Compare
alex-hunt-materialize
left a comment
There was a problem hiding this comment.
Overall this looks pretty good. I do worry a bit about how we will test this, as it is a pretty significant change.
| affinity = optional(any) | ||
| defaultResources = optional(any) | ||
| enabled = optional(bool) | ||
| nodeSelector = optional(any) |
There was a problem hiding this comment.
Many of these are labeled any. We should at least be able to indicate object(any) for the ones that are objects, even if we can't easily say they are a map of string to string.
I have an update to the auto-generated helm values documentation in MaterializeInc/materialize#34563 which may help with this, if you decide to use the helm-docs generated file.
There was a problem hiding this comment.
ok, I think I fixed this now... we'll attempt to use the typenotation k8s/affinity, k8s/tolerations... in the chart parameters to inject some hard coded tfvar types.
| environmentdExtraEnv = length(var.environmentd_extra_env) > 0 ? [{ | ||
| name = "MZ_SYSTEM_PARAMETER_DEFAULT" | ||
| value = join(";", [ | ||
| for item in var.environmentd_extra_env : | ||
| "${item.name}=${item.value}" | ||
| ]) | ||
| }] : null |
There was a problem hiding this comment.
Maybe not something to fix in this PR, but this seems like it is wrong and was wrong before this PR. The environmentd_extra_env should not be assumed to be setting a default parameter, but any environment variable.
There was a problem hiding this comment.
I'm sure this has been debated and there's good cause for having this in each cloud provider, but naviely it seems like the operator module should just be in the kubernetes module and it makes the tests make more sense.
48d3417 to
d50dc10
Compare
Introduces generate_terraform_types.py which dynamically generates Terraform variable type definitions from Materialize's upstream schemas: - CRD types from materialize_crd_descriptions.json - Helm parameter types from materialize_operator_chart_parameter.yml The script reads the version from the environmentd_version variable default in the source code and outputs native HCL format (.gen.tf) with proper formatting via terraform fmt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add check_schema_sync.py to verify generated types match upstream schemas - Add GitHub Actions workflow to run sync check on PRs - Update CONTRIBUTING.md with instructions for regenerating types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Generated type definitions:
- kubernetes/modules/materialize-instance/crd_variables.gen.tf
- {aws,azure,gcp}/modules/operator/helm_variables.gen.tf
- {aws,azure,gcp}/examples/simple/override_variables.gen.tf
Additional changes:
- Add helm_values_override and materialize_spec_override variables to
operator modules and examples for full customization
- Add deprecated force_rollout and request_rollout variables to examples
for backwards compatibility, merged into materialize_spec_override
- Update materialize-instance module to use the new override variable
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add test-kind.yml workflow to run integration tests on PR
- Add kubernetes/modules/operator module with generated helm_values
types
- Add kind cluster config and backend manifests (postgres, minio)
- Add pytest fixtures for cluster lifecycle and terraform deployment
- Add integration tests validating operator, instance creation, and
pods
d50dc10 to
7bc97c1
Compare
Auto generating terraform variables for our CRD and Helm chart is something I've been thinking about for a while and this is a proof of concept for it.
There are many benefits to having an object or set of vars that work with LSP or AI in order to help write code (as opposed to
object(any)). And it's also extremely beneficial to be able to set any viable attribute for the helm chart or the materialize CR.PR has been updated to be a bit more reviewable.
Commit 1 - adds generation script
Commit 2 - adds GH action and docs
Commit 3 - Adds the auto-generated files and adds deprecations
Commit 4 - Adds pytests (yes pytests) for basic validation of our input files to tf_vars
Commit 5 - Adds pytests that use kind and generated tf_vars to deploy a materialize operator via helm and a materialize instance
TODO: