Skip to content

Commit

Permalink
Remove import chaining from import pacakge
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Laine <[email protected]>
  • Loading branch information
phillebaba committed Oct 17, 2024
1 parent 92ccc6d commit 7872fd3
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 73 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,24 @@ build-local-agent-image: ## Build the Zarf agent image to be used in a locally b

init-package: ## Create the zarf init package (must `brew install coreutils` on macOS and have `docker` first)
@test -s $(ZARF_BIN) || $(MAKE)
$(ZARF_BIN) package create -o build -a $(ARCH) --confirm .
$(ZARF_BIN) package create -o build -a $(ARCH) --confirm ./packages/init

# INTERNAL: used to build a release version of the init package with a specific agent image
release-init-package:
$(ZARF_BIN) package create -o build -a $(ARCH) --set AGENT_IMAGE_TAG=$(AGENT_IMAGE_TAG) --confirm .
$(ZARF_BIN) package create -o build -a $(ARCH) --set AGENT_IMAGE_TAG=$(AGENT_IMAGE_TAG) --confirm packages/init

# INTERNAL: used to build an iron bank version of the init package with an ib version of the registry image
ib-init-package:
@test -s $(ZARF_BIN) || $(MAKE)
$(ZARF_BIN) package create -o build -a $(ARCH) --confirm . \
$(ZARF_BIN) package create -o build -a $(ARCH) --confirm ./packages/init \
--set REGISTRY_IMAGE_DOMAIN="registry1.dso.mil/" \
--set REGISTRY_IMAGE="ironbank/opensource/docker/registry-v2" \
--set REGISTRY_IMAGE_TAG="2.8.3"

# INTERNAL: used to publish the init package
publish-init-package:
$(ZARF_BIN) package publish build/zarf-init-$(ARCH)-$(CLI_VERSION).tar.zst oci://$(REPOSITORY_URL)
$(ZARF_BIN) package publish . oci://$(REPOSITORY_URL)
$(ZARF_BIN) package publish ./packages/init oci://$(REPOSITORY_URL)

build-examples: ## Build all of the example packages
@test -s $(ZARF_BIN) || $(MAKE)
Expand Down
55 changes: 0 additions & 55 deletions packages/distros/k3s/common/zarf.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
89 changes: 83 additions & 6 deletions packages/distros/k3s/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ metadata:
name: distro-k3s
description: Used to establish a new Zarf cluster

variables:
- name: K3S_ARGS
description: Arguments to pass to K3s
default: --disable traefik

components:
# AMD-64 version of the K3s stack
- name: k3s
import:
path: common
name: k3s
only:
localOS: linux
cluster:
architecture: amd64
description: >
*** REQUIRES ROOT (not sudo) ***
Install K3s, a certified Kubernetes distribution built for IoT & Edge computing.
K3s provides the cluster need for Zarf running in Appliance Mode as well as can
host a low-resource Gitops Service if not using an existing Kubernetes platform.
files:
# K3s removal script
- source: zarf-clean-k3s.sh
target: /opt/zarf/zarf-clean-k3s.sh
executable: true
# The K3s systemd service definition
- source: k3s.service
target: /etc/systemd/system/k3s.service
symlinks:
- /etc/systemd/system/multi-user.target.wants/k3s.service
# Include the actual K3s binary
- source: https://github.com/k3s-io/k3s/releases/download/v1.28.4+k3s2/k3s
shasum: 9014535a4cd20c788282d60398a06279983562093455b53ab76701539ce67acf
Expand All @@ -29,20 +46,56 @@ components:
target: /var/lib/rancher/k3s/agent/images/k3s.tar.zst
actions:
onDeploy:
defaults:
maxRetries: 5
before:
- cmd: if [ "$(uname -m)" != "x86_64" ]; then echo "this package architecture is amd64, but the target system has a different architecture. These architectures must be the same" && exit 1; fi
description: Check that the host architecture matches the package architecture
maxRetries: 0
- cmd: ./zarf internal is-valid-hostname
maxRetries: 0
description: Check if the current system has a, RFC1123 compliant hostname
# If running RHEL variant, disable firewalld
# https://rancher.com/docs/k3s/latest/en/advanced/#additional-preparation-for-red-hat-centos-enterprise-linux
# NOTE: The empty echo prevents infinite retry loops on non-RHEL systems where the exit code would be an error
- cmd: "[ -e /etc/redhat-release ] && systemctl disable firewalld --now || echo ''"
description: If running a RHEL variant, disable 'firewalld' per k3s docs
after:
# Configure K3s systemd service
- cmd: systemctl daemon-reload
description: Reload the system services
- cmd: systemctl enable k3s
description: Enable 'k3s' to run at system boot
- cmd: systemctl restart k3s
description: Start the 'k3s' system service
onRemove:
before:
- cmd: /opt/zarf/zarf-clean-k3s.sh
description: Remove 'k3s' from the system
- cmd: rm /opt/zarf/zarf-clean-k3s.sh
description: Remove the cleanup script

# ARM-64 version of the K3s stack
- name: k3s
import:
path: common
name: k3s
only:
localOS: linux
cluster:
architecture: arm64
description: >
*** REQUIRES ROOT (not sudo) ***
Install K3s, a certified Kubernetes distribution built for IoT & Edge computing.
K3s provides the cluster need for Zarf running in Appliance Mode as well as can
host a low-resource Gitops Service if not using an existing Kubernetes platform.
files:
# K3s removal script
- source: zarf-clean-k3s.sh
target: /opt/zarf/zarf-clean-k3s.sh
executable: true
# The K3s systemd service definition
- source: k3s.service
target: /etc/systemd/system/k3s.service
symlinks:
- /etc/systemd/system/multi-user.target.wants/k3s.service
# Include the actual K3s binary
- source: https://github.com/k3s-io/k3s/releases/download/v1.28.4+k3s2/k3s-arm64
shasum: 1ae72ca06d3302f3e86ef92e6e8f84e14a084da69564e87d6e2e75f62e72388d
Expand All @@ -59,7 +112,31 @@ components:
target: /var/lib/rancher/k3s/agent/images/k3s.tar.zst
actions:
onDeploy:
defaults:
maxRetries: 5
before:
- cmd: if [ "$(uname -m)" != "aarch64" ] && [ "$(uname -m)" != "arm64" ]; then echo "this package architecture is arm64, but the target system has a different architecture. These architectures must be the same" && exit 1; fi
description: Check that the host architecture matches the package architecture
maxRetries: 0
- cmd: ./zarf internal is-valid-hostname
maxRetries: 0
description: Check if the current system has a, RFC1123 compliant hostname
# If running RHEL variant, disable firewalld
# https://rancher.com/docs/k3s/latest/en/advanced/#additional-preparation-for-red-hat-centos-enterprise-linux
# NOTE: The empty echo prevents infinite retry loops on non-RHEL systems where the exit code would be an error
- cmd: "[ -e /etc/redhat-release ] && systemctl disable firewalld --now || echo ''"
description: If running a RHEL variant, disable 'firewalld' per k3s docs
after:
# Configure K3s systemd service
- cmd: systemctl daemon-reload
description: Reload the system services
- cmd: systemctl enable k3s
description: Enable 'k3s' to run at system boot
- cmd: systemctl restart k3s
description: Start the 'k3s' system service
onRemove:
before:
- cmd: /opt/zarf/zarf-clean-k3s.sh
description: Remove 'k3s' from the system
- cmd: rm /opt/zarf/zarf-clean-k3s.sh
description: Remove the cleanup script
12 changes: 6 additions & 6 deletions zarf.yaml → packages/init/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ metadata:
components:
- name: k3s
import:
path: packages/distros/k3s
path: ../distros/k3s

# This package moves the injector & registries binaries
- name: zarf-injector
required: true
import:
path: packages/zarf-registry
path: ../zarf-registry

# Creates the temporary seed-registry
- name: zarf-seed-registry
required: true
import:
path: packages/zarf-registry
path: ../zarf-registry

# Creates the permanent registry
- name: zarf-registry
required: true
import:
path: packages/zarf-registry
path: ../zarf-registry

# Creates the pod+git mutating webhook
- name: zarf-agent
required: true
import:
path: packages/zarf-agent
path: ../zarf-agent

# (Optional) Adds a git server to the cluster
- name: git-server
import:
path: packages/gitea
path: ../gitea
2 changes: 1 addition & 1 deletion src/test/e2e/12_lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestLint(t *testing.T) {
t.Log("E2E: Test lint on schema success")

// This runs lint on the zarf.yaml in the base directory of the repo
_, _, err := e2e.Zarf(t, "dev", "lint")
_, _, err := e2e.Zarf(t, "dev", "lint", "packages/init")
require.NoError(t, err, "Expect no error here because the yaml file is following schema")
})

Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/13_find_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestFindImages(t *testing.T) {
registry := "zarf.dev"
agentTag := "test"

stdOut, _, err := e2e.Zarf(t, "dev", "find-images", ".", "--registry-url", registry, "--create-set", fmt.Sprintf("agent_image_tag=%s", agentTag), "--skip-cosign")
stdOut, _, err := e2e.Zarf(t, "dev", "find-images", "packages/init", "--registry-url", registry, "--create-set", fmt.Sprintf("agent_image_tag=%s", agentTag), "--skip-cosign")

require.NoError(t, err)
internalRegistryImage := fmt.Sprintf("%s/%s:%s", registry, "zarf-dev/zarf/agent", agentTag)
Expand Down

0 comments on commit 7872fd3

Please sign in to comment.