Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 2.21 KB

README.adoc

File metadata and controls

52 lines (38 loc) · 2.21 KB

Advanced Pkl/K8s Example

This example demonstrates how to manage Pkl manifests for the guestbook and redis applications deployed to production and staging environments in the us-west Kubernetes cluster.

Manifest files amend the AppEnvCluster Pkl template. This template mandates a three-level application/environment/cluster directory structure whose leaf directories contain the manifest files for a particular combination of application, environment, and cluster. Manifest files placed in parent directories are merged with equally named manifest files in leaf directories.

To evaluate all Pkl manifests, run:

$ pkl eval **/*.pkl
NOTE

Depending on your shell, you may need to enable support for ** in glob patterns. In zsh, ** is enabled by default. In bash v4 and higher, ** is enabled with shopt -s globstar.

To evaluate Pkl manifests for all applications in the staging environment in the us-west cluster, run:

$ pkl eval */staging/us-west/*.pkl

To apply Pkl manifests for the guestbook application in the production environment in the us-west cluster to Kubernetes, run:

$ pkl eval guestbook/production/us-west/*.pkl | kubectl apply -f -

By default, all resources are written to standard output as a YAML stream (each resource gets separated by ---). This output may be written to disk using the -o flag.

Alternatively, each resource may be written to its own file using the -m flag. In this mode, each resource gets written to a directory that matches the three-level hierarchy.

# Write all resources as a YAML stream to `output.yml`
$ pkl eval -o output.yml **/*.pkl

# Write each resource as its own file to a path within `.output/`
$ pkl eval -m .output/ **/*.pkl