kinvolk / lokomotive

🪦 DISCONTINUED Further Lokomotive development has been discontinued. Lokomotive is a 100% open-source, easy to use and secure Kubernetes distribution from the volks at Kinvolk
https://kinvolk.io/lokomotive-kubernetes/
Apache License 2.0
320 stars 49 forks source link

Create a well-defined way to pass infra data to components #499

Open johananl opened 4 years ago

johananl commented 4 years ago

General

In many cases, a Lokomotive component may need information from the infrastructure layer (Terraform). Examples:

We should think about adding a generic mechanism for making infrastructure data available to components.

Implementation

Terraform knows everything about the infrastructure. Therefore, it probably makes sense to rely on Terraform outputs as the source of the information.

There are at least two main approaches on how to make infrastructure information available to component: via lokoctl and via the k8s datastore.

Passing information via lokoctl

In this approach, lokoctl contains logic which reads Terraform outputs into memory. The components code can then use the in-memory information to interpolate values into component manifests, enable/disable components altogether etc.

If this approach is taken, it is critical to re-apply components following an infrastructure change.

Passing information via the k8s datastore

In this approach, Terraform outputs are written to the k8s datastore as k8s objects (e.g. using ConfigMap objects or custom k8s resources). Then, a component manifest can refer to a value from the relevant k8s object rather than using a hardcoded value.

IMO this approach is problematic for the following reasons:

johananl commented 4 years ago

@iaguis @surajssd @invidian - FYI.

invidian commented 4 years ago

Some thoughts:

surajssd commented 4 years ago

Using kubernetes as data store makes more sense from the perspective of controllers and operators.

Going forward when Lokomotive relies on it’s own operators and controllers, getting that information from terraform output would pose same problem we have today; How to extract data from terraform!

invidian commented 4 years ago

@surajssd I think considering controllers is slightly beyond our scope for now, as I think we will still need Terraform for infrastructure parts, at least initially, so it doesn't really matter where we run it.