Project: Kapitan (Provisioning / Automation & Configuration)
File: targets.md

A target is a file that lives under the subdirectory, and that tells Kapitan what you want it to do for you. Kapitan will recognise all YAML files in the subtree as targets. !!! note Only use `.yml` as extension for Inventory files. `.yaml` will not be recognised as a valid Inventory file. What you do with a is largely up to you and your setup. Common examples: clusters*: Map each to a cluster, capturing all configurations needed for a given cluster. For instance: `targets/clusters/production-cluster1.yml` applications: When using Kapitan to manage Kubernetes* applications, you might define a for everything that you would normally deploy in a single namespace, including all its resources, scripts, secrets and documentation. For instance: `targets/mysql.yml` environments*: You might have want to define a different for each environment you have, like `dev.yml`, `test.yml` and `prod.yml` cloud projects: When working with Terraform*, it may be convenient to group by cloud project. For instance: `targets/gcp/projects/engineering-prod.yml`. single tenancy: When deploying a single-tenancy application, you might combine the approaches above, and have a `acme.yml` that is used to define both Terraform and Kubernetes resources for a given tenant, perhaps also with some ArgoCD or Spinnaker* pipelines to go with it. !!! example If you have configured your kapitan repository like in instructions, you can run the commands we give during the course of this documentation. !!! quote "" `kapitan compile` ```shell Compiled gke-pvm-killer (0.09s) Compiled vault (0.18s) Compiled pritunl (0.17s) Compiled mysql (0.07s) Compiled examples (0.25s) Compiled postgres-proxy (0.06s) Compiled echo-server (0.08s) Compiled global (0.05s) Compiled tutorial (0.09s) Compiled guestbook-argocd (0.08s) Compiled sock-shop (0.30s) Compiled kapicorp-demo-march (0.04s) Compiled kapicorp-project-123 (0.03s) Compiled kapicorp-terraform-admin (0.08s) Compiled tesoro (0.09s) Compiled prod-sockshop (0.34s) Compiled dev-sockshop (0.41s) Compiled argocd (2.53s) ``` When you run `kapitan compile`, you instruct Kapitan to generate for each given a directory under `compiled` with the same name. Under this directory you will find all the files that have been generated by Kapitan for that target. !!! quote "" `tree compiled/mysql/` ```shell compiled/mysql/ argocd docs mysql-readme.md README.md manifests mysql-bundle.yml mysql-config.yml mysql-namespace.yml mysql-secret.yml pre-deploy rabbitmq scripts terraform 7 directories, 6 files ``` A typical might look like this: !!! example "`inventory/targets/acme/dev.yaml`" ```yaml classes: common components.acme.frontend components.acme.backend parameters: target_name: dev ``` Note that it is made of 2 sections: `classes` is a list of class files you will want to import. `parameters` allows for local override of what is unique to this target. !!! info the `kapitan` key under the root `parameters` is reserved for kapitan usage. Some examples: ```yaml parameters: kapitan: compile: # input types configuration section dependencies: # dependencies configuration section to download resources secrets: # secret encryption/decryption configuration section validate: # items which indicate which compiled output to validate vars: # which are also passed down to input types as context ``` *[SSOT]: Single Source Of Truth