Skip to content

Create a Package

The following diagram shows the order of operations for the zarf package create command and the hook locations for actions.

Lifecycle Diagram
graph TD A1(set working directory)-->A2 A2(parse zarf.yaml)-->A3 A3(filter components by architecture)-->A4 A4(detect init package)-->A5 A5(handle deprecations)-->A6 A6(parse component imports)-->A7 A7(process create-time variables)-->A8 A8(write build data and zarf.yaml)-->A9 A9(run validations)-->A10 A10(confirm package create):::prompt-->A11 A11{Init package?} A11 -->|Yes| A12(add seed image)-->A13 A11 -->|No| A13 subgraph A13(add each component)-->A13 A13 --> A14(run each '.actions.onCreate.before'):::action-->A14 A14 --> A15(load '.charts')-->A16 A16(load '.files')-->A17 A17(load '.dataInjections')-->A18 A18(load '.manifests')-->A19 A19(load '.repos')-->A20 A20(run each '.actions.onCreate.after'):::action-->A20 A20-->A21{Success?} A21-->|Yes|A22(run each '.actions.onCreate.success'):::action-->A22 A21-->|No|A23(run each '.actions.onCreate.failure'):::action-->A23-->A999 end A22-->A24(load all '.images') A24-->A25{Skip SBOM?} A25-->|Yes|A27 A25-->|No|A26 A26(generate SBOM)-->A27 A27(reset working directory)-->A28 A28(create package archive)-->A29 A29{Is multipart?} A29-->|Yes|A30(split package archive)-->A31 A29-->|No|A31 A31(handle sbom view/out flags) A999[Abort]:::fail classDef prompt fill:#4adede,color:#000000 classDef action fill:#bd93f9,color:#000000 classDef fail fill:#aa0000

There are two types of Zarf Packages, the ZarfInitConfig and the ZarfPackageConfig, which are distinguished by the kind: field and specified in the zarf.yaml file.

Throughout the rest of the documentation, we will refer to the ZarfInitConfig as an init config package or init package, and to the ZarfPackageConfig as simply a “package”.

The init package is used to initialize a cluster, making it ready for deployment of other Zarf Packages. It must be executed once on each cluster that you want to deploy another package onto, even if multiple clusters share the same host. For additional information on the init package, we provide detailed documentation on the Zarf ‘init’ package page.

If there is no running cluster, the init package can be used to create one. It has a deployable K3s cluster component that can be optionally deployed on your machine. Usually, an init package is the first Zarf Package to be deployed on a cluster as other packages often depend on the services installed or configured by the init package. If you want to install a K8s cluster with Zarf, but you don’t want to use K3s as your cluster, you will need to create or find another Zarf Package that will stand up your cluster before you run the zarf init command.

During the initialization process, Zarf will seed your cluster with a container registry to store images that other packages may require. Additionally, the init package has the option to deploy other features to your cluster, such as a Git server to manage your repositories or a PLG logging stack that allows you to monitor the applications running on your cluster.

To initialize your cluster, you need to run the command zarf init. This command will search for a file with the specific naming convention: zarf-init-{ARCHITECTURE}-{VERSION}.tar.zst. The architecture must match that of the cluster you are deploying to. If you are deploying to a cluster with a different architecture, you will need to specify the name of the architecture you are deploying on with the -a flag. For example, if you are on an arm64 machine but are deploying on an amd64 machine, you will run zarf init -a amd64.

Init packages can also be run with zarf package deploy zarf-init-{ARCHITECTURE}-{VERSION}.tar.zst.

You do not need to create init configs by yourself unless you want to customize how your cluster is installed/configured. For example, if you want to use the init process to install a specifically configured K3s cluster onto your host machine, you can create a specific package to do that before running the init package.

ZarfPackageConfig refers to any package that is not an init package and is used to define specific capabilities that you want to deploy onto your initialized cluster.

To deploy a Zarf Package, you can use the command zarf package deploy. This will prompt you to select from all of the files in your current directory that match the name zarf-package-*.tar.zst. Alternatively, if you already know which package you want to deploy, you can simply use the command zarf package deploy {PACKAGE_NAME}.

During the deployment process, Zarf will leverage the infrastructure created during the ‘init’ process (such as the Docker registry and Git server) to push all the necessary images and repositories required for the package to operate.

You can also specify zarf.yaml package configuration templates at package create time by including ###_ZARF_PKG_TMPL_*### as the value for any string-type data in your package definition. These values are discovered during zarf package create and will always be prompted for if not using --confirm or --set. An example of this is below:

kind: ZarfPackageConfig
metadata:
name: 'pkg-variables'
description: 'Prompt for a variables during package create'
constants:
- name: PROMPT_IMAGE
value: '###ZARF_PKG_TMPL_PROMPT_ON_CREATE###'
components:
- name: zarf-prompt-image
required: true
images:
- '###ZARF_PKG_TMPL_PROMPT_ON_CREATE###'