Problem
As part of T370037: Cloud VPS: extend tofu-infra coverage, we are using opentofu to track virtual resource definitions for Cloud VPS with an Infrastructure-as-Code approach.
The primary implementation is the tofu-infra repository: https://wikitech.wikimedia.org/wiki/Portal:Cloud_VPS/Admin/tofu-infra
There are, however, certain virtual resources that make more sense for tracking via tofu-infra, for a number of reasons:
- we need to define them via other methods (like, cookbook automation, via horizon, etc)
- we need the definition to be self-service by users
In the particular case of this decision request, we are interested in deciding over project resources (or, tenants).
This has been discussed multiple times in the past, for example in internal team meetings (with notes shared in public).
NOTE: the initial implementation of tofu-infra made by @aborrero considered the following:
- tracking project resource definitions in tofu-infra was a requirement for tracking other things like security groups, or DNS records
- this is not true, given we can associate resources within a project to that project via using a data reference, thus not needing the project itself being defined in the repo
- tracking project resources would give us a strong benefit from the IaC/gitops point of view
- but maybe not? Specially if we ever get interested in some scenarios, for example if project creation is self-service
Constraints and risks
- We may shot ourselves in the foot, for example:
- if we "track" too many resources on tofu-infra, that we don't really need
- if we miss the opportunity to track some resources
- Refactors are becoming heavy. The tofu-infra project already saw a few refactors, each being heavier than the previous one (as the resource count grows)
Options
Option 1
Track all project definitions (for projects in the "default" domain) via tofu-infra.
Cookbooks can create a patch in the repo if required.
This is what is implemented as of this writing.
Pros:
- We already have the projects defined in tofu-infra
Cons:
- There are certain conflicts - or role overlap - between automation via cookbooks and automation via opentofu
- Tracking hundred of resources (the project resources themselves) may make the repository a bit more complex to maintain
- May get in our way if we ever move to a self-service scenario in our future (users creating their own projects) -- this is not in the roadmap today anyway
Option 2
Only track admin projects via tofu-infra.
This is, projects that are under full control from the WMCS team with the purpose of offering and maintaining the Cloud VPS service itself.
Examples of projects to track: admin, admin-monitorin, metrics-infra, project-proxy, cloudinfra, bastion, etc.
Examples of project resources to don't track in the repo: tools, toolsbeta
See also: https://wikitech.wikimedia.org/wiki/Portal:Cloud_VPS/Admin/Infrastructure_projects
This will require removing from the tofu-infra state the projects that we no longer want to track.
Pros:
- This may make the tofu-infra repository simpler, as we don't need to track hundred of resources (the project resources themselves)
- This relaxes any conflict between automation via cookbook and automation via opentofu, given they would have different roles
- If we ever implement a self-service approach for Cloud VPS projects, then this is the right option for that scenario -- this is not in the roadmap today anyway
Cons:
- We don't track project creation on a git repository, for non-admin projects anyway.
Option 3
Similar to option 1, but split the project definitions into its own repo, let's call it "tofu-projects". All the resources inside the "admin" projects ("admin", "cloudinfra", "bastion", etc.) would remain in the "tofu-infra" repo.
Pros:
- cleaner separation between "admin" projects and resources (managed by cloud vps admins), and projects and resources for cloud vps tenants
Cons:
- potentially harder to share resources between the two (like network policies that might apply both to admin projects and generic projects). But I think we could still do it using a module that can be imported from one repo to the other, if needed.