-
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.
Provides the ability to create Zarf packages intended to work in online-only environments, i.e., without the internal Zarf airgap components typically provided by `zarf init`. Also adds early FAQ. ## Related Issue Fixes #1051 Fixes #1046 Related to #1134 Co-authored-by: unclegedd <[email protected]> Co-authored-by: Wayne Starr <[email protected]> Co-authored-by: MxNxPx <[email protected]>
- Loading branch information
1 parent
d2babf3
commit 79b432f
Showing
20 changed files
with
348 additions
and
86 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,19 @@ | ||
# 9. YOLO Mode | ||
|
||
Date: 2022-12-14 | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
Zarf was rooted in the idea of declarative K8s deployments for disconnected environments. Many of the design decisions made in Zarf are based on this idea. However, in certain connected environments, Zarf can still be leveraged as a way to define declarative deployments and upgrades without the constraints of disconnected environments. To that end, providing a declarative way to deploy Zarf packages without the need for a Zarf init package would be useful in such environments. | ||
|
||
## Decision | ||
|
||
YOLO mode is an optional boolean config set in the `metadata` section of the Zarf package manifest. Setting `metadata.yolo=true` will deploy the Zarf package "as is" without needing the Zarf state to exist or the Zarf Agent mutating webhook. Zarf packages with YOLO mode enabled are not allowed to specify components with container images or Git repos and validation will prevent the package from being created. | ||
|
||
## Consequences | ||
|
||
YOLO mode provides a way for existing, connected clusters to use Zarf for declarative deployments and upgrades because there is no need to perform any Zarf bootstrapping in order to deploy Zarf-packaged workloads. The addition of the `metadata.yolo` config should not affect existing Zarf users as it is entirely optional. Additionally, requiring the `metadata.yolo` config to be set to `true` and not allowing a runtime flag to override it makes it very clear both in `package create` and `package deploy` the intent and usage of the package. |
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 |
---|---|---|
@@ -1,5 +1,35 @@ | ||
# FAQ | ||
|
||
:::caution Hard Hat Area | ||
This page is still being developed. More content will be added soon! | ||
::: | ||
## Do I have to use [Homebrew](https://brew.sh/) to install Zarf? | ||
|
||
No, the Zarf binary and init package can be downloaded from the [Releases Page](https://github.com/defenseunicorns/zarf/releases). Zarf does not need to be installed or available to all users on the system, but it does need to be executable for the current user (i.e. `chmod +x zarf` for Linux/Mac). | ||
|
||
## What dependencies does Zarf have? | ||
|
||
Zarf is statically compiled and written in [Go](https://golang.org/) and [Rust](https://www.rust-lang.org/), so it has no external dependencies. For Linux, Zarf can bring a Kubernetes cluster using [K3s](https://k3s.io/). For Mac and Windows, Zarf can leverage any avaiilable local or remote cluster the user has access to. Currently, the K3s installation Zarf performs does require a [Systemd](https://en.wikipedia.org/wiki/Systemd) based system and root access. | ||
|
||
## What is the Zarf Agent? | ||
|
||
The Zarf Agent is a [Kubernetes Mutating Webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook) that is installed into the cluster during the `zarf init` operation. The Agent is responsible for modifying [Kubernetes PodSpec](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec) objects [Image](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container.Image) fields to point to the Zarf Registry. This allows the cluster to pull images from the Zarf Registry instead of the internet without having to modify the original image references. The Agent also modifies [Flux GitRepository](https://fluxcd.io/docs/components/source/gitrepositories/) objects to point to the local Git Server. | ||
|
||
## Why doesn't the Zarf Agent create secrets it needs in the cluster? | ||
|
||
During early discussions and [subsequent decision](../adr/0005-mutating-webhook.md) to use a Mutating Webhook, we decided to not have the Agent create any secrets in the cluster. This is to avoid the Agent having to have more priveleges than it needs as well as avoid collisions with Helm. The Agent today simply repsonds to requests to patch PodSpec and GitRepository objects. | ||
|
||
The Agent does not need to create any secrets in the cluster. Instead, during `zarf init` and `zarf package deploy`, secrets are automatically created as [Helm Postrender Hook](https://helm.sh/docs/topics/advanced/#post-rendering) for any namespaces Zarf sees. If you have resources managed by [Flux](https://fluxcd.io/) that are not in a namespace managed by Zarf, you can either create the secrets manually or include a manifest to create the namespace in your package and let Zarf create the secrets for you. | ||
|
||
## How can a Kubernetes resource be excluded from the Zarf Agent? | ||
|
||
Resources can be exluded at the namespace or resources level by adding the `zarf.dev/agent: ignore` label. | ||
|
||
## What happens to resources that exist in the cluster before `zarf init`? | ||
|
||
During the `zarf init` operation, the Zarf Agent will patch any existing namespaces with the `zarf.dev/agent: ignore` label to prevent the Agent from modifying any resources in that namespace. This is done because there is no way to guarantee the images used by pods in existing namespaces are available in the Zarf Registry. | ||
|
||
## What is YOLO Mode and why would I use it? | ||
|
||
YOLO Mode is a special package metatdata designation that be added to a package prior to `zarf package create` to allow the package to be installed without the need for a `zarf init` operation. In most cases this will not be used, but it can be useful for testing or for environments that manage their own registries and Git servers completely outside of Zarf. This can also be used as a way to transition slowly to using Zarf without having to do a full migration. | ||
|
||
:::note | ||
Typically you should not deploy a Zarf package in YOLO mode if the cluster has already been initialized with Zarf. This could lead to an [ImagePullBackOff](https://kubernetes.io/docs/concepts/containers/images/#imagepullbackoff) if the resources in the package do not include the `zarf.dev/agent: ignore` label and are not already available in the Zarf Registry. | ||
::: |
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,43 @@ | ||
# YOLO Mode | ||
This example demonstrates YOLO mode, an optional mode for using Zarf in a fully connected environment where users can bring their own external container registry and Git server. | ||
|
||
:::info | ||
|
||
To view the example source code, select the `Edit this page` link below the article and select the parent folder. | ||
|
||
::: | ||
|
||
|
||
## Prerequisites | ||
- A running K8s cluster. _Note that the cluster does not need to have the Zarf init package installed or any other Zarf-related bootstrapping._ | ||
|
||
## Instructions | ||
Create the package: | ||
```sh | ||
zarf package create | ||
``` | ||
|
||
### Deploy the package | ||
|
||
```sh | ||
# Run the following command to deploy the created package to the cluster | ||
zarf package deploy | ||
|
||
# Choose the yolo package from the list | ||
? Choose or type the package file [tab for suggestions] | ||
> zarf-package-yolo-<ARCH>.tar.zst | ||
|
||
# Confirm the deployment | ||
? Deploy this Zarf package? (y/N) | ||
|
||
# Wait a few seconds for the cluster to deploy the package; you should | ||
# see the following output when the package has been finished deploying: | ||
Connect Command | Description | ||
zarf connect doom | Play doom!!! | ||
zarf connect games | Play some old dos games 🦄 | ||
|
||
# Run the specified `zarf connect <game>` command to connect to the deployed | ||
# workload (ie. kill some demons). Note that the typical Zarf registry, | ||
# Gitea server and Zarf agent pods are not present in the cluster. This means | ||
# that the game's container image was pulled directly from the public registry and the URL was not mutated by Zarf. | ||
``` |
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,15 @@ | ||
kind: ZarfPackageConfig | ||
metadata: | ||
name: yolo | ||
yolo: true | ||
description: "Game example in YOLO (online-only) mode that can be deployed without a Zarf cluster" | ||
|
||
components: | ||
- name: yolo-games | ||
required: true | ||
manifests: | ||
- name: multi-games | ||
namespace: zarf-yolo-example | ||
files: | ||
- ../game/manifests/deployment.yaml | ||
- ../game/manifests/service.yaml |
Oops, something went wrong.