Heads-up: this revision is meant for illustrating how you template well with ytt.

To get started quickly, switch to the master branch:

$ git checkout master
$ git clean -df

... and start from there.

If you are keen to learn how to use the k14s toolchain skillfully, good on ya. Let's carry on...

Overview

In this revision ...

We externalize commonly specified configuration into "data values."

This is done by:

  1. creating a new file named _defaults.yaml
    • the @data/values annotation marks this as a "data values" file
    • ytt loads configuration values from such files, first, before rendering any templates
  2. declaring variables in the data values file (in YAML format)
  3. loading the data ytt library in each template and using those data values.

Remember this:

Externalize what the user must own.

In other templating systems, the author must externalize all variables that the user might want to change. This can result in an explosion of input values, making it harder to understand.

With ytt, when the user wants to own a piece of configuration, they can use an overlay to make the change.

Examine the changes to the configuration to see how this is true:

$ git show -- config

Instructions

  1. Obtain and target a Kubernetes Cluster.
  2. Deploy the application to the cluster:
    $ ytt -f config/application-name | kubectl apply -f-
    deployment.apps/application-name-server created
    ingress.extensions/application-name created
    service/application-service-name created
  3. Verify the deployment
    $ curl localhost/app/
  4. Re-deploy the application, specifying the environment name
    $ ytt -f config/application-name -v "environmentName=pink-poodle" | kubectl apply -f-
  5. Verify that the deployment was updated
    $ curl localhost/app/

Creating a KIND Cluster

  1. install KIND.
  2. create the cluster:
    $ kind create cluster --config=config/kind-cluster/cluster.yaml
  3. install the Ingress Controller
    $ kubectl apply -f config/kind-cluster/ingress-nginx.yaml

What Next?

In the next revision,

$ git checkout rev3 && git clean -df