Skip to content

Commit b62f60c

Browse files
RothAndrewjeff-mccoy
authored andcommitted
Big Bang Core Example (zarf-dev#29)
Signed-off-by: Jeff McCoy <code@jeffm.us>
1 parent 72479d4 commit b62f60c

15 files changed

+692
-26
lines changed

.editorconfig

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ max_line_length = 120
1111
tab_width = 4
1212

1313
[*.md]
14-
trim_trailing_whitespace = false
14+
trim_trailing_whitespace = false
15+
16+
[Makefile]
17+
indent_style = tab

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif
1616

1717
# remove all zarf packages recursively
1818
remove-packages:
19-
find . -type f -name 'zarf-package*' -delete
19+
find . -type f -name 'zarf-package-*' -delete
2020

2121
# usage: make test OS=ubuntu
2222
test:
@@ -27,21 +27,21 @@ test:
2727
test-close:
2828
vagrant destroy -f
2929

30-
package:
30+
init-package:
3131
$(ZARF_BIN) package create --confirm
32-
mv zarf*.tar.zst build
32+
mv zarf-init.tar.zst build
3333

34-
cd build && sha256sum -b zarf* > zarf.sha256
34+
cd build && sha256sum -b zarf* > zarf.sha256
3535
ls -lh build
3636

3737
build-cli:
3838
rm -fr build
3939
cd cli && $(MAKE) build
4040
cd cli && $(MAKE) build-mac
4141

42-
build-test: build-cli package
42+
build-test: build-cli init-package
4343

44-
ci-release: package
44+
ci-release: init-package
4545

4646
# automatically package all example directories and add the tarballs to the build directory
4747
package-examples:

Vagrantfile

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Vagrant.configure("2") do |config|
22

3+
config.vm.provider "virtualbox" do |vb|
4+
vb.check_guest_additions = false
5+
vb.cpus = 6
6+
vb.memory = 8192
7+
end
8+
9+
config.vm.disk :disk, size: "20GB", primary: true
10+
311
config.vm.define "rhel7" do |target|
412
target.vm.box = "generic/rhel7"
513
end
@@ -35,20 +43,10 @@ Vagrant.configure("2") do |config|
3543
config.vm.network "forwarded_port", guest: 80, host: 8080
3644
config.vm.network "forwarded_port", guest: 443, host: 8443
3745

38-
config.vm.disk :disk, size: "20GB", primary: true
3946
config.ssh.insert_key = false
4047

41-
config.vm.provider "virtualbox" do |vb|
42-
vb.check_guest_additions = false
43-
vb.cpus = 6
44-
vb.memory = 8192
45-
end
46-
4748
config.vm.provision "shell", inline: <<-SHELL
48-
cd /opt/zarf
4949
# Airgap images please
50-
echo "0.0.0.0 charts.helm.sh repo1.dso.mil github.com registry.dso.mil registry1.dso.mil index.docker.io auth.docker.io registry-1.docker.io dseasb33srnrn.cloudfront.net production.cloudflare.docker.com registry.opensource.zalan.do" >> /etc/hosts
51-
# ./zarf init --confirm --host=localhost
52-
SHELL
53-
50+
echo "0.0.0.0 registry.hub.docker.com hub.docker.com charts.helm.sh repo1.dso.mil github.com registry.dso.mil registry1.dso.mil docker.io index.docker.io auth.docker.io registry-1.docker.io dseasb33srnrn.cloudfront.net production.cloudflare.docker.com registry.opensource.zalan.do" >> /etc/hosts
51+
SHELL
5452
end

examples/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sync/

examples/.gitkeep

Whitespace-only changes.

examples/Makefile

100644100755
+70-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Figure out which Zarf binary we should use based on the operating system we are on
2-
ZARF_BIN := ../../build/zarf
2+
ZARF_BIN := ../sync/zarf
33
UNAME_S := $(shell uname -s)
44
UNAME_P := $(shell uname -p)
55
ifneq ($(UNAME_S),Linux)
@@ -14,10 +14,73 @@ ifneq ($(UNAME_S),Linux)
1414
endif
1515
endif
1616

17-
package-examples:
18-
cd appliance && $(ZARF_BIN) package create --confirm && mv zarf*.tar.zst ../../build
19-
cd data-injection && $(ZARF_BIN) package create --confirm && mv zarf*.tar ../../build
20-
cd game && $(ZARF_BIN) package create --confirm && mv zarf*.tar.zst ../../build
21-
cd single-big-bang-package && $(ZARF_BIN) package create --confirm && mv zarf*.tar.zst ../../build
22-
cd tiny-kafka && $(ZARF_BIN) package create --confirm && mv zarf*.tar.zst ../../build
17+
# Download zarf, build all packages and launch a basic VM with the assets
18+
.PHONY: all
19+
all: fetch-release package-examples vm-init
20+
21+
# Same as target 'all', but build the binaries using the current codebase rather than downloading the latest version from the internet
22+
.PHONY: all-dev
23+
all-dev: build-release package-examples vm-init
24+
25+
# Clean the sync dir
26+
.PHONY: clean
27+
clean:
28+
@rm -fr sync && mkdir -p sync
29+
30+
# Grab the latest release as an alternative to needing to build the binaries
31+
.PHONY: fetch-release
32+
fetch-release: clean
33+
@# This probably isn't the cleanest way to get a release, but since we're moving to github, not worth adding the code until post-migration
34+
@curl -fL "https://zarf-public.s3-us-gov-west-1.amazonaws.com/release/$$(git describe --tags --abbrev=0)/{zarf,zarf-mac-intel,zarf-mac-apple,zarf-init.tar.zst}" -o "sync/#1"
35+
@chmod +x sync/*
36+
37+
# Build the binaries as an alternative to downloading the latest release
38+
.PHONY: build-release
39+
build-release: clean
40+
@cd .. && $(MAKE) build-test
41+
@cp -R ../build/* sync
42+
43+
# Stripped-down vagrant box to reduce friction for basic user testing
44+
# Note the need to perform disk resizing for some examples
45+
.PHONY: vm-init
46+
vm-init: vm-destroy
47+
@VAGRANT_EXPERIMENTAL="disks" vagrant up --no-color
48+
@echo -e "\n\n\n\033[1;93m ✅ VM READY. Logging in now, run \"sudo su\" once the prompt appears.\n\n\n\033[0m"
49+
@vagrant ssh
50+
51+
# Cleanup plz
52+
.PHONY: vm-destroy
53+
vm-destroy:
54+
@vagrant destroy -f
55+
56+
# Create zarf packages from all examples
57+
.PHONY: package-examples
58+
package-examples: package-example-big-bang package-example-appliance package-example-data-injection package-example-game package-example-single-big-bang-package package-example-tiny-kafka
59+
60+
.PHONY: package-example-big-bang
61+
package-example-big-bang:
62+
cd big-bang && kustomize build template/bigbang > manifests/bigbang_generated.yaml && kustomize build template/flux > manifests/flux_generated.yaml && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
63+
64+
.PHONY: package-example-appliance
65+
package-example-appliance:
66+
cd appliance && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
67+
68+
.PHONY: package-example-data-injection
69+
package-example-data-injection:
70+
cd data-injection && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
71+
72+
.PHONY: package-example-game
73+
package-example-game:
74+
cd game && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
75+
76+
.PHONY: package-example-single-big-bang-package
77+
package-example-single-big-bang-package:
78+
cd single-big-bang-package && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
79+
80+
.PHONY: package-example-tiny-kafka
81+
package-example-tiny-kafka:
82+
cd tiny-kafka && $(ZARF_BIN) package create --confirm && mv zarf-package-* ../sync/
83+
84+
.PHONY: package-example-postgres-operator
85+
package-example-postgres-operator:
2386
cd postgres-operator && $(ZARF_BIN) package create --confirm && mv zarf*.tar.zst ../../build

examples/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
# Zarf Examples
2+
13
The Zarf examples demonstrate different ways to utility Zarf in your environment. All of these examples follow the same general release pattern and assume an offline / air-gapped deployment target.
4+
5+
To test create a virtual area to test all examples, you can run `make all` or `make vm-init` if you've already run the examples before. Run `make vm-destroy` to clean up.

examples/Vagrantfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Vagrant.configure("2") do |config|
2+
config.vm.provider "virtualbox" do |vb|
3+
vb.check_guest_additions = false
4+
vb.cpus = 6
5+
vb.memory = 20000
6+
end
7+
8+
config.vm.disk :disk, size: "100GB", primary: true
9+
config.vm.box = "boxomatic/ubuntu-20.04"
10+
11+
config.vm.hostname = "zarf-examples"
12+
config.vm.synced_folder '.', '/vagrant', disabled: true
13+
config.vm.synced_folder './sync/', '/home/vagrant/zarf-examples', SharedFoldersEnableSymlinksCreate: false
14+
15+
config.vm.network "forwarded_port", guest: 80, host: 8080
16+
config.vm.network "forwarded_port", guest: 443, host: 8443
17+
config.vm.network "forwarded_port", guest: 8080, host: 9080
18+
config.vm.network "forwarded_port", guest: 8443, host: 9443
19+
20+
config.ssh.insert_key = false
21+
22+
config.vm.provision "shell", inline: <<-SHELL
23+
# The partition is 100GB but the filesystem isn't yet
24+
growpart /dev/sda 1 && resize2fs /dev/sda1
25+
26+
# Elasticsearch needs this
27+
sysctl -w vm.max_map_count=262144
28+
29+
# Airgap images please
30+
echo "0.0.0.0 registry.hub.docker.com hub.docker.com charts.helm.sh repo1.dso.mil github.com registry.dso.mil registry1.dso.mil docker.io index.docker.io auth.docker.io registry-1.docker.io dseasb33srnrn.cloudfront.net production.cloudflare.docker.com" >> /etc/hosts
31+
SHELL
32+
end

examples/big-bang/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Example: Big Bang Core All-In-One
2+
3+
This example deploys Big Bang Core to a Utility Cluster. This is not normally the method that will be used in production but for a demo it works great.
4+
5+
Because the same cluster will be running both Traefik and Istio, Istio's VirtualServices will be available on port 9443
6+
7+
## Prerequisites
8+
9+
1. Install [Vagrant](https://www.vagrantup.com/)
10+
2. Install `make` and `kustomize`
11+
12+
## Instructions
13+
14+
1. From within the examples directory, Run: `make all`, which will download the latest built binaries, build all of the example packages, and launch a basic VM to run in. Alternatively, run `make all-dev` if you want to build the binaries using the current codebase instead of downloading them.
15+
5. Run: `sudo su` - Change user to root
16+
6. Run: `cd zarf-examples` - Change to the directory where the examples folder is mounted
17+
7. Run: `./zarf init --confirm --features management,utility-cluster --host localhost` - Initialize Zarf, telling it to install the management feature and utility cluster and skip logging feature (since BB has logging already) and tells Zarf to use `localhost` as the domain
18+
8. Wait a bit, run `k9s` to see pods come up. Don't move on until everything is running
19+
9. Run: `./zarf package deploy zarf-package-big-bang-core-demo.tar.zst --confirm` - Deploy Big Bang Core
20+
10. Wait several minutes. Run `k9s` to watch progress
21+
11. Use a browser to visit the various services, available at https://*.bigbang.dev:9443
22+
12. When you're done, run `make vm-destroy` to bring everything down
23+
24+
## To-Do
25+
26+
1. Re-enable the NetworkPolicies - They got disabled to resolve an issue connecting to the k8s cluster API server, which is fine for a demo but unacceptable in production
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*_generated.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Secret
3+
type: Opaque
4+
metadata:
5+
name: zarf-git-secret
6+
namespace: bigbang
7+
stringData:
8+
username: "zarf-git-user"
9+
password: "###ZARF_SECRET###"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
bases:
2+
- git::https://repo1.dso.mil/platform-one/big-bang/bigbang.git/base?ref=1.14.1
3+
4+
configMapGenerator:
5+
- name: common
6+
namespace: bigbang
7+
behavior: merge
8+
files:
9+
- values.yaml
10+
11+
patchesStrategicMerge:
12+
- |-
13+
apiVersion: source.toolkit.fluxcd.io/v1beta1
14+
kind: GitRepository
15+
metadata:
16+
name: bigbang
17+
namespace: bigbang
18+
spec:
19+
url: http://stuart-gitea-http.git.svc.cluster.local:3000/zarf-git-user/mirror__repo1.dso.mil__platform-one__big-bang__bigbang.git
20+
secretRef:
21+
name: zarf-git-secret

0 commit comments

Comments
 (0)