Thumbnail image

Tanzu Application Platform Accelerator With YTT

Table of Contents

Intro

Tanzu Appliation Platform (TAP) has the concept of accelerators.

Accelerators contain complete and runnable application code and deployment configurations, and can be used by developers to create new projects that follow enterprise standards, as stated in the documentation.

While learning TAP, I quickly saw, that a good way for me, would be to use the Carvel project YTT, to create my templates.

YTT

YTT a really nice way, to customize your yaml files, with inputs from TAP. Here I can use variables instead of text search/replace, and also do a lot of logic, which is beyond this blog post.

My problem was however, that when I created my accelerator.yaml file with

engine:
  type: YTT

that it only keept my yaml files, in the generated accelerator zip file, and not my code files.

I could read from the documentation, that the way TAP uses YTT, is by running it as an external command, as the following command

ytt -f <input-folder> \
    --data-values-file <symbols.json> \
    --output-files <output-folder> \
    <extra-args>

So since TAP point YTT to the entire directory, this was probably why it only keep the files it knew.

The solution ended up not being in the documentation, but in one of the sample accelerators accelerator.yaml files.

So the correct syntex, if you want to use YTT for your accelerator, and select which files to keep is the following :

engine:
  merge:
    - type: YTT
    - include:
        - "**/*.py"
        - "**/*.txt"
        - "Procfile"

In this example, I keep all .py and .txt files in the repo, and also the Procfile in the root.

Hope this saves others some headaches if you encounter the same :-)

Photo by Pro Church Media on Unsplash

Related Posts