-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
zarf dev deploy
for quickly testing packages and restruct…
…ure `zarf prepare` (#2170) ## Description Adds a `zarf dev deploy` command that will create + deploy a local package in one shot. ## Related Issue Fixes #2169 Fixes #2098 ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Other (security config, docs update, etc) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Signed-off-by: razzle <[email protected]> Co-authored-by: Wayne Starr <[email protected]>
- Loading branch information
Showing
33 changed files
with
1,177 additions
and
823 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,42 @@ | ||
# 22. Introduce `dev` command | ||
|
||
Date: 2023-12-03 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
> Feature request: <https://github.com/defenseunicorns/zarf/issues/2169> | ||
The current package development lifecycle is: | ||
|
||
1. Create a `zarf.yaml` file and add components | ||
2. Create a package with `zarf package create <dir>` | ||
3. Debug any create errors and resolve by editing `zarf.yaml` and repeating step 2 | ||
4. Run `zarf init` to initialize the cluster | ||
5. Deploy the package with `zarf package deploy <tarball>` | ||
6. Debug any deploy errors and resolve by editing `zarf.yaml` and repeating step 2 or 5 | ||
|
||
If there are deployment errors, the common pattern is to reset the cluster (ex: `k3d cluster delete && k3d cluster create`) and repeat steps 4-6. Re-initializing the cluster, recreating the package, and redeploying the package is tedious and time consuming; especially when the package is large or the change was small. | ||
|
||
`zarf package create` is designed around air-gapped environments where the package is created in one environment and deployed in another. Due to this architecture, a package's dependencies _must_ be retrieved and assembled _each_ and _every_ time. | ||
|
||
There already exists the concept of [`YOLO` mode](0010-yolo-mode.md), which can build + deploy a package without the need for `zarf init`, and builds without fetching certain heavy dependencies (like Docker images). However, `YOLO` mode is not exposed via CLI flags, and is meant to develop and deploy packages in fully connected environments. | ||
|
||
## Decision | ||
|
||
Introduce a `dev deploy` command that will combine the lifecycle of `package create` and `package deploy` into a single command. This command will: | ||
|
||
- Not result in a re-usable tarball / OCI artifact | ||
- Not have any interactive prompts | ||
- Not require `zarf init` to be run by default (override-able with a CLI flag) | ||
- Be able to create+deploy a package in either YOLO mode (default) or prod mode (exposed via a CLI flag) | ||
- Only build + deploy components that _will_ be deployed (contrasting with `package create` which builds _all_ components regardless of whether they will be deployed) | ||
|
||
## Consequences | ||
|
||
The `dev deploy` command will make it easier to develop and deploy packages in connected **development** environments. It will also make it easier to debug deployment errors by allowing the user to iterate on the package without having to re-initialize the cluster, re-build and re-deploy the package each cycle. | ||
|
||
There is a purpose to placing this functionality behind a new command, rather than adding it to `package create`. Commands under `dev` are meant to be used in **development** environments, and are **not** meant to be used in **production** environments. There is still the possibility that a user will use `dev deploy` in a production environment, but the command name and documentation will make it clear that this is not the intended use case. |
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,41 @@ | ||
# zarf dev deploy | ||
<!-- Auto-generated by hack/gen-cli-docs.sh --> | ||
|
||
[beta] Creates and deploys a Zarf package from a given directory | ||
|
||
## Synopsis | ||
|
||
[beta] Creates and deploys a Zarf package from a given directory, setting options like YOLO mode for faster iteration. | ||
|
||
``` | ||
zarf dev deploy [flags] | ||
``` | ||
|
||
## Options | ||
|
||
``` | ||
--components string Comma-separated list of components to install. Adding this flag will skip the init prompts for which components to install | ||
--create-set stringToString Specify package variables to set on the command line (KEY=value) (default []) | ||
--deploy-set stringToString Specify deployment variables to set on the command line (KEY=value) (default []) | ||
-f, --flavor string The flavor of components to include in the resulting package (i.e. have a matching or empty "only.flavor" key) | ||
-h, --help help for deploy | ||
--no-yolo Disable the YOLO mode default override and create / deploy the package as-defined | ||
--registry-override stringToString Specify a map of domains to override on package create when pulling images (e.g. --registry-override docker.io=dockerio-reg.enterprise.intranet) (default []) | ||
``` | ||
|
||
## Options inherited from parent commands | ||
|
||
``` | ||
-a, --architecture string Architecture for OCI images and Zarf packages | ||
--insecure Allow access to insecure registries and disable other recommended security enforcements such as package checksum and signature validation. This flag should only be used if you have a specific reason and accept the reduced security posture. | ||
-l, --log-level string Log level when running Zarf. Valid options are: warn, info, debug, trace (default "info") | ||
--no-color Disable colors in output | ||
--no-log-file Disable log file creation | ||
--no-progress Disable fancy UI progress bars, spinners, logos, etc | ||
--tmpdir string Specify the temporary directory to use for intermediate files | ||
--zarf-cache string Specify the location of the Zarf cache directory (default "~/.zarf-cache") | ||
``` | ||
|
||
## SEE ALSO | ||
|
||
* [zarf dev](zarf_dev.md) - Commands useful for developing packages |
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
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,57 @@ | ||
# Developing Zarf Packages | ||
|
||
## `dev` Commands | ||
|
||
Zarf contains many commands that are useful while developing a Zarf package to iterate on configuration, discover resources and more! Below are explanations of some of these commands with the full list discoverable with `zarf dev --help`. | ||
|
||
:::caution | ||
|
||
The `dev` commands are meant to be used in **development** environments / workflows. They are **not** meant to be used in **production** environments / workflows. | ||
|
||
::: | ||
|
||
### `dev deploy` | ||
|
||
The `dev deploy` command will combine the lifecycle of `package create` and `package deploy` into a single command. This command will: | ||
|
||
- Not result in a re-usable tarball / OCI artifact | ||
- Not have any interactive prompts | ||
- Not require `zarf init` to be run (by default, but _is required_ if `--no-yolo` is not set) | ||
- Be able to create+deploy a package in either YOLO mode (default) or prod mode (exposed via `--no-yolo` flag) | ||
- Only build + deploy components that _will_ be deployed (contrasting with `package create` which builds _all_ components regardless of whether they will be deployed) | ||
|
||
```bash | ||
# Create and deploy dos-games in yolo mode | ||
$ zarf dev deploy examples/dos-games | ||
``` | ||
|
||
```bash | ||
# If deploying a package in prod mode, `zarf init` must be run first | ||
$ zarf init --confirm | ||
# Create and deploy dos-games in prod mode | ||
$ zarf dev deploy examples/dos-games --no-yolo | ||
``` | ||
|
||
### `dev find-images` | ||
|
||
Evaluates components in a `zarf.yaml` to identify images specified in their helm charts and manifests. | ||
|
||
Components that have `git` repositories that host helm charts can be processed by providing the `--repo-chart-path`. | ||
|
||
```bash | ||
$ zarf dev find-images examples/wordpress | ||
|
||
components: | ||
|
||
- name: wordpress | ||
images: | ||
- docker.io/bitnami/apache-exporter:0.13.3-debian-11-r2 | ||
- docker.io/bitnami/mariadb:10.11.2-debian-11-r21 | ||
- docker.io/bitnami/wordpress:6.2.0-debian-11-r18 | ||
``` | ||
|
||
### Misc `dev` Commands | ||
|
||
Not all `dev` commands have been mentioned here. | ||
|
||
Further `dev` commands can be discovered by running `zarf dev --help`. |
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.