Skip to content

apple/pkl-k8s-examples

Repository files navigation

Pkl/K8s Examples

What’s In This Repo?

The yaml directory contains YAML manifests for the official guestbook Kubernetes example.

The pkl/basic example demonstrates how to

  • convert YAML manifests to Pkl

  • evaluate Pkl manifests back to YAML

  • catch manifest errors during evaluation

  • apply Pkl manifests to Kubernetes.

The pkl/advanced example demonstrates how to manage Pkl manifests for multiple applications, deployment environments, and Kubernetes clusters.

To run the examples, install the Pkl CLI.

Why Pkl/K8s?

Kubernetes requires a lot of YAML configuration. To make a single configuration change, users often need to touch multiple YAML files, which is time-consuming and error-prone. Configuration errors aren’t discovered until the configuration is applied.

Pkl/K8s, a set of Pkl templates derived from Kubernetes' OpenAPI spec, is here to save the day. Writing Kubernetes manifests in Pkl offers the following benefits:

  • Strong local validation that goes beyond Kubernetes' OpenAPI spec.

  • Easy sharing of configuration across applications, environments, and clusters with the AppEnvCluster Pkl template. See the advanced example for details.

  • Great IDE experience with validation, code completion, and direct access to Kubernetes documentation. Requires the Pkl IntelliJ Plugin for JetBrains IDEs (IDEA, GoLand, PyCharm, etc).

The io.k8s.convert Pkl module automatically converts Kubernetes manifests from YAML to Pkl. See the basic example for details.

Still unconvinced? See Comparison for the Pkl team’s perspective on how Pkl compares to other configuration formats and languages,

Where To Get Help?

About

Examples for using Pkl with Kubernetes

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •