Skip to content

Commit

Permalink
update single-big-bang-package example docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-mccoy committed Feb 8, 2022
1 parent 37cc2c1 commit d47f7f3
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 51 deletions.
149 changes: 133 additions & 16 deletions examples/single-big-bang-package/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,133 @@
## Zarf Big Bang Single Package Example

This example demonstrates using Zarf in a very low-resources/singlue-use environment. In this mode there is no gitops service and Zarf is simply a standard means of wrapping airgap concerns for K3s. This example deploys a basic K3s cluster using Traefik 2 and configures TLS / airgap concerns to deploy a single BB Package (twistlock).

### Steps to use:

1. `cd examples/`
2. Run one of these two commands:
- `make all` - Download the latest version of Zarf, build the deploy package, and start a VM with Vagrant
- `make all-dev` - Build Zarf locally, build the deploy package, and start a VM with Vagrant
3. Run: `./zarf init --confirm --components k3s` - Initialize Zarf, telling it to install k3s on your new VM. If you want to use interactive mode instead just run `./zarf init`.
4. Wait a bit, run `./zarf tools k9s` to see pods come up. Don't move on until everything is running
5. Run: `./zarf package deploy zarf-package-big-bang-core-demo.tar.zst --components kubescape --confirm` - Deploy Big Bang Core. If you want interactive mode instead just run `./zarf package deploy`, it will give you a picker to choose the package.
6. Wait several minutes. Run `./zarf tools k9s` to watch progress
8. Run `./zarf connect twistlock` to be taken to the twistlock consule in your browser.
9. When you're done, run `exit` to leave the VM then `make vm-destroy` to bring everything down
# Zarf Single Big Bang Package Example

This example uses Zarf to deploy a single [Big Bang](https://p1.dso.mil/#/products/big-bang/) Package into a KinD cluster.

## The Flow

Here's what you'll do in this example:

1. [Get ready](#get-ready)

1. [Create a cluster](#create-a-cluster)

1. [Package it](#package-it)

1. [Deploy it](#deploy-it)

1. [Try it](#try-it)

1. [Cleanup](#cleanup)

 

## Get ready

Before the magic can happen you have to do a few things:

1. Install [Docker](https://docs.docker.com/get-docker/). Other container engines will likely work as well but aren't actively tested by the Zarf team.

2. Install [KinD](https://github.com/kubernetes-sigs/kind). Other Kubernetes distros will work as well, but we'll be using KinD for this example since it is easy and tested frequently and thoroughly.

3. Clone the Zarf project — for the example configuration files.

4. Download a Zarf release — you need a binary _**and**_ an init package, [here](../../docs/workstation.md#just-gimmie-zarf).

 

## Create a cluster

You can't run software without _somewhere to run it_, so the first thing to do is create a local Kubernetes cluster that Zarf can deploy to. In this example we'll be using KinD to create a lightweight, local K8s cluster running in Docker.

Kick that off by running this command:

```sh
kind create cluster
```

This will result in a single-node Kubernetes cluster called `kind-kind` on your local machine running in Docker. Your KUBECONFIG should be automatically configured to talk to the new cluster.

```sh
cd <same dir as zarf-init.tar.zst>
zarf init
```

Follow the prompts, answering "no" to each of the optional components, since we don't need them for this deployment.

Congratulations! Your machine is now running a single-node Kubernetes cluster powered by Zarf!

> _**Note**_
>
> Zarf supports non-interactive installs too! Give `zarf init --confirm --components logging` a try next time.
**Troubleshooting:**

> _**ERROR: Unable to find the package on the local system, expected package at zarf-init.tar.zst**_
>
> The zarf binary needs an init package to know how to setup your cluster! So, if `zarf init` returns an error like this:
>
> ```sh
> ERROR: Unable to find the package on the local system, expected package at zarf-init.tar.zst
> ```
>
> It's likely you've either forgotten to download `zarf-init.tar.zst` (as part of [getting ready](#get-ready)) _**OR**_ you are _not_ running `zarf init` from the directory the init package is sitting in.
> _**ERROR: failed to create cluster: node(s) already exist for a cluster with the name "kind"**_
>
> You already have a KinD cluster running. Either just move on to use the current cluster, or run `kind delete cluster`, then `kind create cluster`.
> _**Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?**_
>
> Docker isn't running or you're otherwise not able to talk to it. Check your Docker installation, then try again.
&nbsp;
## Package it
Zarf is (at heart) a tool for making it easy to get software from _where you have it_ to _**where you need it**_&mdash;specifically, across an airgap. Since moving bits is so core to Zarf the idea of a "ready-to-move group of software" has a specific name&mdash;the _package_.
All of the software a Zarf cluster runs is installed via package&mdash;for many reasons like versioning, auditability, etc&mdash;which means that if you want to run a in your cluster you're going to have to build a package for it.
Luckily, this is very easy to do&mdash;package contents are defined by simple, declarative yaml files and _we've already made one for you_. To build this package you simply:
```sh
cd <zarf dir>/examples/single-big-bang-package # directory with zarf.yaml, and
zarf package create --confirm # make the package
```
Watch the terminal scroll for a while. Once things are downloaded & zipped up and you'll see a file ending in `.tar.zst` drop. _That's_ your package.
&nbsp;
## Deploy it
It's time to feed the package you built into your cluster.
Since you're running a Zarf cluster directly on your local machine&mdash;where this package & `zarf` binary _already are_&mdash;deploying the package is very simple:
```sh
zarf package deploy zarf-package-big-bang-single-package-demo.tar.zst --confirm
```
In a couple seconds the cluster will have loaded your package.
&nbsp;
## Use it
Run `./zarf connect twistlock` to be taken to the twistlock consule in your browser.
&nbsp;
## Cleanup
Once you've had your fun it's time to clean up.
In this case, since the Zarf cluster was installed specifically (and _only_) to serve this example, clean up is really easy&mdash;you just tear down the entire cluster:
```sh
kind delete cluster
```
It only takes a couple moments for the _entire cluster_ to disappear&mdash;long-running system services and all&mdash;leaving your machine ready for the next adventure.
&nbsp;
49 changes: 14 additions & 35 deletions examples/tiny-kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@ This example demonstrates using Zarf to deploy a simple operator example, in thi

## The Flow


Here's what you'll do in this example:

1. [Get ready](#get-ready)

1. [Create a cluster](#create-a-cluster)

2. [Package it](#package-it)
1. [Package it](#package-it)

3. [Deploy it](#deploy-it)
1. [Deploy it](#deploy-it)

4. [Try it](#try-it)
1. [Try it](#try-it)

5. [Cleanup](#cleanup)
1. [Cleanup](#cleanup)

&nbsp;


## Get ready


Before the magic can happen you have to do a few things:

1. Install [Docker](https://docs.docker.com/get-docker/). Other container engines will likely work as well but aren't actively tested by the Zarf team.
Expand All @@ -37,7 +34,6 @@ Before the magic can happen you have to do a few things:

&nbsp;


## Create a cluster

You can't run software without _somewhere to run it_, so the first thing to do is create a local Kubernetes cluster that Zarf can deploy to. In this example we'll be using KinD to create a lightweight, local K8s cluster running in Docker.
Expand All @@ -57,20 +53,22 @@ zarf init

Follow the prompts, answering "no" to each of the optional components, since we don't need them for this deployment.

Congratulations! Your machine is now running a single-node Kubernetes cluster powered by Zarf!
Congratulations! Your machine is now running a single-node Kubernetes cluster powered by Zarf!

> _**Note**_
>
> Zarf supports non-interactive installs too! Give `zarf init --confirm --components logging` a try next time.
> _**Note**_
>
> Zarf supports non-interactive installs too! Give `zarf init --confirm --components logging` a try next time.
**Troubleshooting:**

> _**ERROR: Unable to find the package on the local system, expected package at zarf-init.tar.zst**_
> _**ERROR: Unable to find the package on the local system, expected package at zarf-init.tar.zst**_
>
> The zarf binary needs an init package to know how to setup your cluster! So, if `zarf init` returns an error like this:
>
> ```sh
> ERROR: Unable to find the package on the local system, expected package at zarf-init.tar.zst
> ```
>
> It's likely you've either forgotten to download `zarf-init.tar.zst` (as part of [getting ready](#get-ready)) _**OR**_ you are _not_ running `zarf init` from the directory the init package is sitting in.
> _**ERROR: failed to create cluster: node(s) already exist for a cluster with the name "kind"**_
Expand All @@ -83,13 +81,11 @@ Congratulations! Your machine is now running a single-node Kubernetes cluster p
&nbsp;
## Package it
Zarf is (at heart) a tool for making it easy to get software from _where you have it_ to _**where you need it**_&mdash;specifically, across an airgap. Since moving bits is so core to Zarf the idea of a "ready-to-move group of software" has a specific name&mdash;the _package_.
All of the software a Zarf cluster runs is installed via package&mdash;for many reasons like versioning, auditability, etc&mdash;which means that if you want to run a in your cluster you're going to have to build a package for it.
All of the software a Zarf cluster runs is installed via package&mdash;for many reasons like versioning, auditability, etc&mdash;which means that if you want to run a in your cluster you're going to have to build a package for it.
Luckily, this is very easy to do&mdash;package contents are defined by simple, declarative yaml files and _we've already made one for you_. To build this package you simply:
Expand All @@ -98,14 +94,12 @@ cd <zarf dir>/examples/tiny-kafka # directory with zarf.yaml, and
zarf package create --confirm # make the package
```
Watch the terminal scroll for a while. Once things are downloaded & zipped up and you'll see a file ending in `.tar.zst` drop. _That's_ your package.
Watch the terminal scroll for a while. Once things are downloaded & zipped up and you'll see a file ending in `.tar.zst` drop. _That's_ your package.
&nbsp;
## Deploy it
It's time to feed the package you built into your cluster.
Since you're running a Zarf cluster directly on your local machine&mdash;where this package & `zarf` binary _already are_&mdash;deploying the package is very simple:
Expand All @@ -120,7 +114,7 @@ In a couple seconds the cluster will have loaded your package.
## Use it
Testing will require JDK and the kafka tools: `sudo apt install openjdk-14-jdk-headless` for Ubuntu. More details can be found at https://kafka.apache.org/quickstart. Steps to test:
Testing will require JDK and the kafka tools: `sudo apt install openjdk-14-jdk-headless` for Ubuntu. More details can be found at https://kafka.apache.org/quickstart. Steps to test:
1. Install JDK and extract the Kafka tools from the package `kafka.tgz`
2. Get the Nodeport: `NODEPORT=$(kubectl get service demo-kafka-external-bootstrap -n kafka-demo -o=jsonpath='{.spec.ports[0].nodePort}{"\n"}')`
Expand All @@ -131,7 +125,6 @@ Testing will require JDK and the kafka tools: `sudo apt install openjdk-14-jdk-
## Cleanup
Once you've had your fun it's time to clean up.
In this case, since the Zarf cluster was installed specifically (and _only_) to serve this example, clean up is really easy&mdash;you just tear down the entire cluster:
Expand All @@ -141,17 +134,3 @@ kind delete cluster
```
It only takes a couple moments for the _entire cluster_ to disappear&mdash;long-running system services and all&mdash;leaving your machine ready for the next adventure.
&nbsp;
---
&nbsp;
### Credits
✨ Special thanks to these fine references! ✨
- https://www.reddit.com/r/programming/comments/nap4pt/dos_gaming_in_docker/
- https://earthly.dev/blog/dos-gaming-in-docker/

0 comments on commit d47f7f3

Please sign in to comment.