microsoft / bedrock

Automation for Production Kubernetes Clusters with a GitOps Workflow
MIT License
129 stars 12 forks source link

Refactor Bedrock Terraform structure #83

Closed dtzar closed 5 years ago

dtzar commented 5 years ago

The current terraform structure doesn't allow people to bring their own infrastructure (i.e. vnet) and should optimize for modularity & composability. This proposal would align to DRY and allow many "environments" combinations. I'd also like to see at least one environment flavor have a default GitOps URL variable & ssh keys (no private key needed) set to enable some form of stack (i.e. cloud native stack) deployed to the cluster.

If there is a desire to make this module available in the public terraform registry, then I'd recommend to either: a. move the /aks/ folder contents to the root which may add other items in the above folder if desired OR b. add main. variables, output, etc. at the root which includes aks/* etc (similar to one of the environment examples)

bold - means this resource is put behind a count switch and corresponding var to enable/disable

timfpark commented 5 years ago

I'm assuming that all of this would be under the /cluster directory off of the root of the project - if so, this looks largely great.

One large question - we will likely have a multicloud project in the near future with GCP. Given that, should we add an azure layer to denote that everything contained in it is azure related? Tactically, I think this means that everything outside of perhaps /backend-state would be housed in this azure directory?

dtzar commented 5 years ago

I'm not sure why you would add the /cluster folder since everything in this repo creates the cluster (currently 83% HCL, 10% shell, 7 % Dockerfile and HCL % will increase once Dockerfile is gone).

As for multi-cloud I didn't consider this. I'd say to stick everything with the existing structure minus the files in the root to an /azure folder. Even the backend-state is specific to azure since it creates an Azure storage account for backend state. Other cloud providers could add a similar structure to Azure at the root /gcp/ or /aws/.

timfpark commented 5 years ago

The reasoning around having a /cluster top level directory is that @andrebriggs team is currently doing a bunch of work around the GitOps portion of this that will also land in the repo that is substantially different -- but builds on -- the cluster creation portion. I'm open to other ideas, but let's factor in -- and logically separate -- that part of the repo from the Terraform work.

In the current conception, all of that work lives in a top level gitops directory but we might want to consider in the long term breaking this out into at least a couple parts -- either at the top level or underneath gitops:

dtzar commented 5 years ago

Some alternative ideas to the gitops folder:

This way the code in bedrock remains tied to the terraform/cluster creation which makes it a cleaner separation for CI/PRs as well as easier to understand the folder structure. You can also keep the spirit of the GitOps attach via the readmes.