vmware-tanzu / tanzu-framework

Tanzu Framework provides a set of building blocks to build atop of the Tanzu platform and leverages Carvel packaging and plugins to provide users with a much stronger, more integrated experience than the loose coupling and stand-alone commands of the previous generation of tools.
Apache License 2.0
197 stars 194 forks source link

Make YTTProcessor easy to run outside without the fully operational tanzu-framework machinery #521

Open jayunit100 opened 2 years ago

jayunit100 commented 2 years ago

Problem

You cant make a workload cluster dry-run, without a management cluster.

I think the root of this problem is that we dont have an easy way to just generate cluster YAMLs without Tanzu client.

Solution

Its actually not hard to use raw YTT to generate cluster yaml, i.e. https://github.com/jayunit100/k8sprototypes/tree/master/peri2

Can we make this style of pure YTT generation of CAPI yaml integrated somehow into tanzu-framework? that way, we can easily hack on YTT cluster templates without having to create management-clusters.... (let me know if im missing an obvious solution).

Alt Solution

We also could just make it ultra easy to run the TAnzu cli YTT.go program, as it only has one external dependency, which we could remove and doc how to use it to generate.

Seems like the YTT Processor YAML has only one internal dependency: PAthInfo


import (
    "fmt"
    "io"
    "strconv"

    "github.com/k14s/ytt/pkg/cmd/template"
    yttui "github.com/k14s/ytt/pkg/cmd/ui"
    "github.com/k14s/ytt/pkg/files"
    "github.com/k14s/ytt/pkg/workspace"
    "github.com/k14s/ytt/pkg/yamlmeta"
    "github.com/pkg/errors"
    "gopkg.in/yaml.v3"

    "github.com/vmware-tanzu/tanzu-framework/apis/providers/v1alpha1"
)

Could we remove the PathInfo dependency , so that the logic for how we process YTT was a standalone go program ? would make it easier to reason about / debug in certain cases....

... let me know if this is the wrong approach . Its mostly just an idea at this point ....

swalner-vmware commented 2 years ago

I strongly second the idea of having a way to iterate on template development without running the tkg cli. I'd love to see a hack directory that has a shell script allowing me to specify an input file with data and have the output be the result of the templating engine's machinations. This would help de-mystify the template process and make it easier to make template changes. It might also facilitate a test suite that could use this approach to ensure against regressions when making template changes.

vuil commented 2 years ago

two things:

  1. There was already a test script to do just that in an earlier branch. @Anuj2512 can you see about dusting it off and including in pkg/v1/providers/hack perhaps?
  2. We used to be able to do dry-run without the existence of a management cluster. So recent validations added necessitates it, but there discussion to enable some option to turn that off. @saji-pivotal any idea on the status of that?