Files
awesome-kubernetes/docs/yaml.md
Inaki Fernandez 9ae7fba3fb update
2020-10-05 18:27:11 +02:00

4.6 KiB
Raw Blame History

Templating YAML with YAML Processors. Static Checking of Kubernetes YAML Files

Templating YAML Files

  • wikipedia: YAML
  • thoughtworks.com: Templating in YAML As infrastructures grow in complexity, so do the configuration files that define them. Tools such as AWS CloudFormation, Kubernetes and Helm expect configuration files in JSON or YAML syntax, presumably in an attempt to make them easy to write and process. However, in most cases, teams quickly reach the point where they have some parts that are similar but not quite the same, for example, when the same service must be deployed in different regions with a slightly different setup. For such cases tools offer templating in YAML (or JSON), which has caused a huge amount of frustration with practitioners. The problem is that the syntax of JSON and YAML requires all sorts of awkward compromises to graft templating features such as conditionals and loops into the files. We recommend using an API from a programming language instead or, when this is not an option, a templating system in a programming language, either a general-purpose language such as Python or something specialized such as Jsonnet.
  • Steve Horsfield: DevOps tricks - Templating YAML files Basic text tools fall foul of YAMLs indentation sensitivity. On the other hand, YAML tools like ytt are pretty difficult to interpret. In my case, I opted for a small jq program executed via yq.

YAML Processors

Templating JSON Files

Static Checking of Kubernetes YAML Files

  • The ecosystem of static checking of Kubernetes YAML files can be grouped in the following categories:
    • API validators: Tools in this category validate a given YAML manifest against the Kubernetes API server.
    • Built-in checkers: Tools in this category bundle opinionated checks for security, best practices, etc.
    • Custom validators: Tools in this category allow writing custom checks in several languages such as Rego and Javascript.
  • Validating Kubernetes YAML for best practice and policies 🌟 In this article, you will learn and compare six different tools: