Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: init package clarity and cleanup #2447

Merged
merged 21 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions site/src/content/docs/ref/create.mdx

This file was deleted.

14 changes: 13 additions & 1 deletion site/src/content/docs/ref/init-package.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ The `registry:2` image and the Zarf Agent image can be configured with a custom

:::

## Cluster creation

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. To install a K8s distribution other than k3s, finding or creating a custom Zarf package is necessary.

Typically, an init package is the first Zarf Package to be deployed on a cluster as other packages often rely on the services it installs or configures, however Zarf may be used to package and install the cluster distribution itself. In this scenario, the distribution package would be deployed first, followed by the init package, and then any other packages planned for deployment.

:::tip

Check out our [k3s cluster package](https://github.com/defenseunicorns/zarf/blob/main/packages/distros/k3s/zarf.yaml) to see an example of a Zarf package which installs a kubernetes distribution

:::
lucasrod16 marked this conversation as resolved.
Show resolved Hide resolved

## The `zarf init` Lifecycle

The `zarf init` lifecycle is _very similar_ to the [`zarf package deploy` lifecycle](/ref/deploy/) except that it sets up resources specific to Zarf such as the `zarf-state` and performs special actions such as the injection procedure.
Expand All @@ -123,7 +135,7 @@ graph TD
B12(prompt to confirm components)-->B13
B13(prompt to choose components in '.group')-->B14

subgraph
subgraph ""
B52 --> |Yes|B14(deploy each component)-->B14
B14 --> B15{Component is \n zarf-seed-registry}
B15 --> |Yes|B51(initialize zarf-state secret):::action
Expand Down
70 changes: 60 additions & 10 deletions site/src/content/docs/ref/packages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@ Throughout the rest of the documentation, we will refer to the `ZarfInitConfig`

### `ZarfInitConfig`

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](/ref/init-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.

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.

:::note

To clarify, in most cases, the first Zarf Package you deploy onto a cluster should be the init package since other packages often depend on the services it installs onto your cluster. However, if you don't want to use the K3s distribution included in the init package or if you already have a preferred K8s distribution, you can deploy the distribution package first, followed by the init package, and then any other packages you want. This only applies if you don't have a K8s cluster yet.

:::

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.
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. For additional information on the init package, we provide detailed documentation on the Zarf ['init' package page](/ref/init-package/).

#### Using the init-package

Expand Down Expand Up @@ -89,3 +81,61 @@ In addition to the traditional sources outlined above, there is also a special "
Additionally, inspecting a package deployed to a cluster will not be able to show the package's SBOMs, as they are not currently persisted to the cluster.

:::

## Package create lifecycle
import Mermaid from "@components/Mermaid.astro";
import Details from "@components/Details.astro";

The following diagram shows the order of operations for the `zarf package create` command and the hook locations for [actions](/ref/actions).

<Details label="Lifecycle Diagram">
<Mermaid 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\n'.actions.onCreate.success'):::action-->A22
A21-->|No|A23(run each\n'.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
`}/>
</Details>
Loading