-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 2102-fix-zarf-on-windows
- Loading branch information
Showing
68 changed files
with
2,101 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 21. Composable Components | ||
|
||
Date: 2023-10-26 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
Zarf has supports composing components together between packages on `zarf package create` since v0.16.0. This has allowed package creators to make more complex packages from smaller reusable bits. As this functionality grew however there were a few problems that developed: | ||
|
||
1. Import chains did not handle scaling to larger numbers of layers with test coverage usually only covering the first import. | ||
2. When OCI skeletons were added they were largely bolted on after the fact without rethinking how they would impact composability. | ||
3. Component filtering via the `only` filter was not implemented in a central location leading to bugs with create-time filters. | ||
|
||
## Decision | ||
|
||
We decided to separate composability into its own package that represents a composability import chain as a doubly linked list. This allows us to represent the whole chain as it exists relative to the "head" Zarf package (the definition that Zarf was asked to build) to more easily handle packages that are in different locations (such as OCI skeletons in one's cache). We also run the compose functions on all components so that the additional filter logic that is needed for these components can be handled more concisely and built upon (as it might for `flavor` https://github.com/defenseunicorns/zarf/issues/2101). | ||
|
||
## Consequences | ||
|
||
Maintaining the full context within a linked list does use more memory and some operations on it are less efficient than they could be if we one-shotted the compose. This is a decent tradeoff however as most import chains won't be longer than 4 or 5 elements in practice and these structs and operations are relatively small. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import ExampleYAML from "@site/src/components/ExampleYAML"; | ||
|
||
# Package Flavors | ||
|
||
This example demonstrates how to define variants of packages within the same package definition. This can be combined with [Composable Packages](../composable-packages/README.md) to build up packages and include the necessary [merge overrides](../composable-packages/README.md#merge-strategies) for each variant. | ||
|
||
Given package flavors are built by specifying the `--flavor` flag on `zarf package create`. This will include any components that match that flavor or that do not specify a flavor. | ||
|
||
## `zarf.yaml` {#zarf.yaml} | ||
|
||
:::info | ||
|
||
To view the example in its entirety, select the `Edit this page` link below the article and select the parent folder. | ||
|
||
::: | ||
|
||
<ExampleYAML src={require('./zarf.yaml')} showLink={false} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: enterprise-linux | ||
labels: | ||
app: enterprise-linux | ||
spec: | ||
containers: | ||
- name: enterprise-linux-container | ||
image: "###ZARF_VAR_IMAGE###" | ||
command: [ "sh", "-c", "while true; do ls; sleep 1; done"] | ||
resources: | ||
requests: | ||
memory: "32Mi" | ||
cpu: "50m" | ||
limits: | ||
memory: "128Mi" | ||
cpu: "250m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
kind: ZarfPackageConfig | ||
metadata: | ||
name: package-flavors | ||
description: Simple example to show how to use the `only.flavor` key to build package variants. | ||
|
||
components: | ||
- name: image | ||
required: true | ||
description: "Sets the Enterprise Linux flavor to Rocky Linux" | ||
only: | ||
flavor: rocky-road | ||
images: | ||
- rockylinux:9-minimal | ||
actions: | ||
onDeploy: | ||
before: | ||
- cmd: echo "rockylinux:9-minimal" | ||
setVariables: | ||
- name: IMAGE | ||
|
||
- name: image | ||
required: true | ||
description: "Sets the Enterprise Linux flavor to Oracle Linux" | ||
only: | ||
flavor: oracle-cookie-crunch | ||
images: | ||
- oraclelinux:9-slim | ||
actions: | ||
onDeploy: | ||
before: | ||
- cmd: echo "oraclelinux:9-slim" | ||
setVariables: | ||
- name: IMAGE | ||
|
||
- name: image | ||
required: true | ||
description: "Sets the Enterprise Linux flavor to Alma Linux" | ||
only: | ||
flavor: vanilla-alma-nd | ||
images: | ||
- almalinux:9-minimal | ||
actions: | ||
onDeploy: | ||
before: | ||
- cmd: echo "almalinux:9-minimal" | ||
setVariables: | ||
- name: IMAGE | ||
|
||
- name: image | ||
required: true | ||
description: "Sets the Enterprise Linux flavor to OpenSUSE" | ||
only: | ||
flavor: strawberry-suse | ||
images: | ||
- opensuse/leap:15 | ||
actions: | ||
onDeploy: | ||
before: | ||
- cmd: echo "opensuse/leap:15" | ||
setVariables: | ||
- name: IMAGE | ||
|
||
- name: pod | ||
description: "The pod that runs the specified flavor of Enterprise Linux" | ||
required: true | ||
manifests: | ||
- name: enterprise-linux | ||
namespace: enterprise-linux | ||
files: | ||
- pod.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.