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

Add tools kubectl, tools wait-for & Wait Action. #1373

Merged
merged 21 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ In this walkthrough, we are going to show how you can use Zarf on a fresh linux
1. The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([`git clone` Instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository))
1. Zarf binary installed on your $PATH: ([Install Instructions](../3-getting-started.md#installing-zarf))
1. An init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases))
1. kubectl: ([kubectl Install Instructions](https://kubernetes.io/docs/tasks/tools/#kubectl))
1. `root` access on a Linux machine

## Install the k3s component
Expand Down
4 changes: 1 addition & 3 deletions docs/13-walkthroughs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
This section of the documentation has a collection of walkthroughs that will help you get more familiar with Zarf and its features. The walkthroughs assume that you have a very basic understanding of what Zarf is and aims to help expand your working knowledge of how to use Zarf and what Zarf is capable of doing.

## Walk Through Prerequisites
<!-- TODO: Should we add `kubectl` as a pre req? -->
If a walkthrough has any prerequisites, they will be listed at the beginning of the walkthrough with instructions on how to fulfill them.
Almost all walkthroughs will have the following prerequisites/assumptions:

1. The [Zarf](https://github.com/defenseunicorns/zarf) repository cloned: ([git clone instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository))
1. You have a Zarf binary installed on your $PATH: ([Zarf Install Instructions](../3-getting-started.md#installing-zarf))
1. You have an init-package built/downloaded: ([init-package Build Instructions](./0-using-zarf-package-create.md)) or ([Download Location](https://github.com/defenseunicorns/zarf/releases))
1. Have a kubernetes cluster running/available (ex. [k3s](https://k3s.io/)/[k3d](https://k3d.io/v5.4.1/)/[Kind](https://kind.sigs.k8s.io/docs/user/quick-start#installation))
1. You have kubectl installed: ([kubectl Install Instructions](https://kubernetes.io/docs/tasks/tools/#kubectl))

## Setting Up a Local Kubernetes Cluster

Expand All @@ -29,7 +27,7 @@ k3d cluster create # Creates a k3d cluster
# This will take a couple of minutes to complete


kubectl get pods -A # Check to see if the cluster is ready
zarf tools kubectl get pods -A # Check to see if the cluster is ready
```

### Tear Down k3d CLuster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ Collection of additional tools to make airgap easier
* [zarf tools clear-cache](zarf_tools_clear-cache.md) - Clears the configured git and image cache directory.
* [zarf tools gen-pki](zarf_tools_gen-pki.md) - Generates a Certificate Authority and PKI chain of trust for the given host
* [zarf tools get-creds](zarf_tools_get-creds.md) - Display a Table of credentials for deployed components. Pass a component name to get a single credential.
* [zarf tools kubectl](zarf_tools_kubectl.md) - Kubectl command. See https://kubernetes.io/docs/reference/kubectl/overview/ for more information.
* [zarf tools monitor](zarf_tools_monitor.md) - Launch a terminal UI to monitor the connected cluster using K9s.
* [zarf tools registry](zarf_tools_registry.md) - Tools for working with container registries using go-containertools.
* [zarf tools sbom](zarf_tools_sbom.md) - Generates a Software Bill of Materials (SBOM) for the given package
* [zarf tools wait-for](zarf_tools_wait-for.md) - Waits for a given Kubernetes resource to be ready

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# zarf tools kubectl
<!-- Auto-generated by docs/gen-cli-docs.sh -->

Kubectl command. See https://kubernetes.io/docs/reference/kubectl/overview/ for more information.

```
zarf tools kubectl [flags]
```

## Options

```
-h, --help help for kubectl
```

## Options inherited from parent commands

```
-a, --architecture string Architecture for OCI images
--insecure Allow access to insecure registries and disable other recommended security enforcements. 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-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 tools](zarf_tools.md) - Collection of additional tools to make airgap easier

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# zarf tools wait-for
<!-- Auto-generated by docs/gen-cli-docs.sh -->

Waits for a given Kubernetes resource to be ready

## Synopsis

By default Zarf will wait for all Kubernetes resources to be ready before completion of a component during a deployment.
This command can be used to wait for a Kubernetes resources to exist and be ready that may be created by a Gitops tool or a Kubernetes operator.
You can also wait for aribtrary network endpoints using REST or TCP checks.



```
zarf tools wait-for {KIND|PROTOCOL} {NAME|SELECTOR|URI} {CONDITION|HTTP_CODE} [flags]
```

## Examples

```
Wait for Kubernetes resources:
zarf tools wait-for pod my-pod-name ready -n default wait for pod my-pod-name in namespace default to be ready
zarf tools wait-for p cool-pod-name ready -n cool wait for pod (using p alias) cool-pod-name in namespace cool to be ready
zarf tools wait-for deployment podinfo available -n podinfo wait for deployment podinfo in namespace podinfo to be available
zarf tools wait-for pod app=podinfo ready -n podinfo wait for pod with label app=podinfo in namespace podinfo to be ready
zarf tools wait-for svc zarf-docker-registry exists -n zarf wait for service zarf-docker-registry in namespace zarf to exist
zarf tools wait-for svc zarf-docker-registry -n zarf same as above, except exists is the default condition
zarf tools wati-for crd addons.k3s.cattle.io wait for crd addons.k3s.cattle.io to exist

Wait for network endpoints:
zarf tools wait-for http localhost:8080 200 wait for a 200 response from http://localhost:8080
zarf tools wait-for tcp localhost:8080 wait for a connection to be established on localhost:8080
zarf tools wait-for https 1.1.1.1 200 wait for a 200 response from https://1.1.1.1
zarf tools wait-for http google.com wait for any 2xx response from http://google.com
zarf tools wait-for http google.com success wait for any 2xx response from http://google.com

```

## Options

```
-h, --help help for wait-for
-n, --namespace string Specify the namespace of the resources to wait for.
--timeout string Specify the timeout duration for the wait command. (default "5m")
```

## Options inherited from parent commands

```
-a, --architecture string Architecture for OCI images
--insecure Allow access to insecure registries and disable other recommended security enforcements. 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-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 tools](zarf_tools.md) - Collection of additional tools to make airgap easier

183 changes: 181 additions & 2 deletions docs/4-user-guide/3-zarf-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ Must be one of:
&nbsp;
<blockquote>

**Description:** The command to run
**Description:** The command to run. Must specify either cmd or wait for the action to do anything.

| | |
| -------- | -------- |
Expand All @@ -1051,7 +1051,7 @@ Must be one of:
&nbsp;
<blockquote>

**Description:** The name of a variable to update with the output of the command. This variable will be available to all remaining actions and components in the package.
**Description:** (Cmd only) The name of a variable to update with the output of the command. This variable will be available to all remaining actions and components in the package.

| | |
| -------- | -------- |
Expand Down Expand Up @@ -1080,6 +1080,185 @@ Must be one of:
</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait"></a>wait</strong>

</summary>
&nbsp;
<blockquote>

**Description:** Wait for a condition to be met before continuing. Must specify either cmd or wait for the action to do anything. If both are specified

| | |
| ------------------------- | -------------------------------------------------------------------------------------------------------- |
| **Type** | `object` |
| **Additional properties** | [![Not allowed](https://img.shields.io/badge/Not%20allowed-red)](# "Additional Properties not allowed.") |
| **Defined in** | #/definitions/ZarfComponentActionWait |

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_cluster"></a>cluster</strong>

</summary>
&nbsp;
<blockquote>

**Description:** Wait for a condition to be met in the cluster before continuing. Only one of cluster or network can be specified.

| | |
| ------------------------- | -------------------------------------------------------------------------------------------------------- |
| **Type** | `object` |
| **Additional properties** | [![Not allowed](https://img.shields.io/badge/Not%20allowed-red)](# "Additional Properties not allowed.") |
| **Defined in** | #/definitions/ZarfComponentActionWaitCluster |

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_cluster_kind"></a>kind *</strong>

</summary>
&nbsp;
<blockquote>

![Required](https://img.shields.io/badge/Required-red)

**Description:** The kind of resource to wait for (e.g. Pod; Deployment; etc.)

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_cluster_name"></a>name *</strong>

</summary>
&nbsp;
<blockquote>

![Required](https://img.shields.io/badge/Required-red)

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_cluster_namespace"></a>namespace</strong>

</summary>
&nbsp;
<blockquote>

**Description:** The namespace of the resource to wait for

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_cluster_condition"></a>condition</strong>

</summary>
&nbsp;
<blockquote>

**Description:** The condition to wait for (e.g. Ready; Available; etc.). Defautls to exist

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_network"></a>network</strong>

</summary>
&nbsp;
<blockquote>

**Description:** Wait for a condition to be met on the network before continuing. Only one of cluster or network can be specified.

| | |
| ------------------------- | -------------------------------------------------------------------------------------------------------- |
| **Type** | `object` |
| **Additional properties** | [![Not allowed](https://img.shields.io/badge/Not%20allowed-red)](# "Additional Properties not allowed.") |
| **Defined in** | #/definitions/ZarfComponentActionWaitNetwork |

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_network_protocol"></a>protocol *</strong>

</summary>
&nbsp;
<blockquote>

![Required](https://img.shields.io/badge/Required-red)

**Description:** The protocol to wait for (e.g. tcp; http; etc.).

| | |
| -------- | ------------------ |
| **Type** | `enum (of string)` |

:::note
Must be one of:
* "tcp"
* "http"
* "https"
:::

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_network_address"></a>address *</strong>

</summary>
&nbsp;
<blockquote>

![Required](https://img.shields.io/badge/Required-red)

**Description:** The address to wait for (e.g. localhost:8080; 1.1.1.1; etc.)

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

<details>
<summary><strong> <a name="components_items_actions_onCreate_before_items_wait_network_code"></a>code</strong>

</summary>
&nbsp;
<blockquote>

**Description:** The HTTP status code to wait for if using http or https (e.g. 200; 404; etc.)

| | |
| -------- | --------- |
| **Type** | `integer` |

</blockquote>
</details>

</blockquote>
</details>

</blockquote>
</details>

</blockquote>
</details>

Expand Down
Loading