Skip to content

Commit

Permalink
add type meta
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Abro <[email protected]>
  • Loading branch information
AustinAbro321 committed Sep 19, 2024
1 parent cc060d5 commit 7be99b9
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 152 deletions.
260 changes: 130 additions & 130 deletions examples/bb-generate/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,137 +3,137 @@ kind: ZarfPackageConfig
metadata:
name: bigbang
components:
- name: flux
required: true
manifests:
- name: flux-system
namespace: flux-system
files:
- flux/bb-flux.yaml
images:
- registry1.dso.mil/ironbank/fluxcd/source-controller:v1.3.0
- registry1.dso.mil/ironbank/fluxcd/kustomize-controller:v1.3.0
- registry1.dso.mil/ironbank/fluxcd/helm-controller:v1.0.1
- registry1.dso.mil/ironbank/fluxcd/notification-controller:v1.3.0
- name: flux
required: true
manifests:
- name: flux-system
namespace: flux-system
files:
- flux/bb-flux.yaml
images:
- registry1.dso.mil/ironbank/fluxcd/source-controller:v1.3.0
- registry1.dso.mil/ironbank/fluxcd/kustomize-controller:v1.3.0
- registry1.dso.mil/ironbank/fluxcd/helm-controller:v1.0.1
- registry1.dso.mil/ironbank/fluxcd/notification-controller:v1.3.0
- name: bigbang
required: true
manifests:
- name: bigbang
required: true
manifests:
- name: bigbang
namespace: bigbang
files:
- manifests/bb-gitrepository.yaml
- manifests/bb-zarf-credentials.yaml
- values-files/ingress.yaml
- values-files/kyverno.yaml
- values-files/loki.yaml
- values-files/neuvector.yaml
- manifests/bb-helmrelease.yaml
images:
- registry1.dso.mil/ironbank/big-bang/grafana/grafana-plugins:11.1.4
- registry1.dso.mil/ironbank/kiwigrid/k8s-sidecar:1.27.5
- registry1.dso.mil/ironbank/big-bang/base:2.1.0
- registry1.dso.mil/ironbank/opensource/istio/pilot:1.22.4
- registry1.dso.mil/ironbank/opensource/istio/proxyv2:1.22.4
- registry1.dso.mil/ironbank/opensource/istio/operator:1.22.4
- registry1.dso.mil/ironbank/opensource/kiali/kiali:v1.89.0
- registry1.dso.mil/ironbank/opensource/kiali/kiali-operator:v1.89.1
- registry1.dso.mil/ironbank/opensource/kyverno:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyvernopre:v1.12.5
- registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.7
- registry1.dso.mil/ironbank/redhat/ubi/ubi9-minimal:9.4
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/reports-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/background-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/cleanup-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyvernocli:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/policy-reporter:2.20.1
- registry1.dso.mil/ironbank/opensource/grafana/loki:3.1.1
- registry1.dso.mil/ironbank/opensource/kubernetes-sigs/metrics-server:v0.7.1
- registry1.dso.mil/ironbank/opensource/prometheus/alertmanager:v0.27.0
- registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.6
- registry1.dso.mil/ironbank/opensource/kubernetes/kube-state-metrics:v2.12.0
- registry1.dso.mil/ironbank/opensource/ingress-nginx/kube-webhook-certgen:v1.3.0
- registry1.dso.mil/ironbank/opensource/prometheus/prometheus:v2.53.0
- registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-config-reloader:v0.75.0
- registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-operator:v0.75.0
- registry1.dso.mil/ironbank/opensource/prometheus/node-exporter:v1.8.1
- registry1.dso.mil/ironbank/opensource/thanos/thanos:v0.35.1
- registry1.dso.mil/ironbank/neuvector/neuvector/controller:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/enforcer:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/manager:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/scanner:5
- registry1.dso.mil/ironbank/neuvector/neuvector/prometheus-exporter:5.3.2
- registry1.dso.mil/ironbank/opensource/grafana/promtail:v3.0.0
- registry1.dso.mil/ironbank/opensource/grafana/tempo:2.5.0
- registry1.dso.mil/ironbank/opensource/grafana/tempo-query:2.5.0
repos:
- https://repo1.dso.mil/big-bang/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
actions:
onRemove:
before:
- cmd: ./zarf tools kubectl patch helmrelease -n bigbang bigbang --type=merge -p '{"spec":{"suspend":true}}'
description: Suspend Big Bang HelmReleases to prevent reconciliation during removal.
healthChecks:
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: grafana
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: istio
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: istio-operator
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kiali
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno-policies
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno-reporter
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: loki
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: monitoring
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: neuvector
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: promtail
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: tempo
namespace: bigbang
files:
- manifests/bb-gitrepository.yaml
- manifests/bb-zarf-credentials.yaml
- values-files/ingress.yaml
- values-files/kyverno.yaml
- values-files/loki.yaml
- values-files/neuvector.yaml
- manifests/bb-helmrelease.yaml
images:
- registry1.dso.mil/ironbank/big-bang/grafana/grafana-plugins:11.1.4
- registry1.dso.mil/ironbank/kiwigrid/k8s-sidecar:1.27.5
- registry1.dso.mil/ironbank/big-bang/base:2.1.0
- registry1.dso.mil/ironbank/opensource/istio/pilot:1.22.4
- registry1.dso.mil/ironbank/opensource/istio/proxyv2:1.22.4
- registry1.dso.mil/ironbank/opensource/istio/operator:1.22.4
- registry1.dso.mil/ironbank/opensource/kiali/kiali:v1.89.0
- registry1.dso.mil/ironbank/opensource/kiali/kiali-operator:v1.89.1
- registry1.dso.mil/ironbank/opensource/kyverno:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyvernopre:v1.12.5
- registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.7
- registry1.dso.mil/ironbank/redhat/ubi/ubi9-minimal:9.4
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/reports-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/background-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyverno/cleanup-controller:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/kyvernocli:v1.12.5
- registry1.dso.mil/ironbank/opensource/kyverno/policy-reporter:2.20.1
- registry1.dso.mil/ironbank/opensource/grafana/loki:3.1.1
- registry1.dso.mil/ironbank/opensource/kubernetes-sigs/metrics-server:v0.7.1
- registry1.dso.mil/ironbank/opensource/prometheus/alertmanager:v0.27.0
- registry1.dso.mil/ironbank/opensource/kubernetes/kubectl:v1.29.6
- registry1.dso.mil/ironbank/opensource/kubernetes/kube-state-metrics:v2.12.0
- registry1.dso.mil/ironbank/opensource/ingress-nginx/kube-webhook-certgen:v1.3.0
- registry1.dso.mil/ironbank/opensource/prometheus/prometheus:v2.53.0
- registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-config-reloader:v0.75.0
- registry1.dso.mil/ironbank/opensource/prometheus-operator/prometheus-operator:v0.75.0
- registry1.dso.mil/ironbank/opensource/prometheus/node-exporter:v1.8.1
- registry1.dso.mil/ironbank/opensource/thanos/thanos:v0.35.1
- registry1.dso.mil/ironbank/neuvector/neuvector/controller:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/enforcer:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/manager:5.3.4
- registry1.dso.mil/ironbank/neuvector/neuvector/scanner:5
- registry1.dso.mil/ironbank/neuvector/neuvector/prometheus-exporter:5.3.2
- registry1.dso.mil/ironbank/opensource/grafana/promtail:v3.0.0
- registry1.dso.mil/ironbank/opensource/grafana/tempo:2.5.0
- registry1.dso.mil/ironbank/opensource/grafana/tempo-query:2.5.0
repos:
- https://repo1.dso.mil/big-bang/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
- https://repo1.dso.mil/big-bang/product/packages/[email protected]
actions:
onRemove:
before:
- cmd: ./zarf tools kubectl patch helmrelease -n bigbang bigbang --type=merge -p '{"spec":{"suspend":true}}'
description: Suspend Big Bang HelmReleases to prevent reconciliation during removal.
healthChecks:
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: grafana
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: istio
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: istio-operator
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kiali
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno-policies
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: kyverno-reporter
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: loki
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: monitoring
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: neuvector
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: promtail
- apiVersion: v1
kind: HelmRelease
namespace: bigbang
name: tempo

# YAML keys starting with `x-` are custom keys that are ignored by the Zarf CLI
# The `x-mdx` key is used to render the markdown content for https://docs.zarf.dev/ref/examples
Expand Down
23 changes: 12 additions & 11 deletions src/internal/bigbang/bigbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func Create(ctx context.Context, bbOpts Opts) error {

// Sort so the dependencies are always the same between runs
sort.Slice(hrDependencies, func(i, j int) bool {
return hrDependencies[i].Metadata.Name < hrDependencies[j].Metadata.Name
return hrDependencies[i].metadata.Name < hrDependencies[j].metadata.Name
})

// Add wait actions for each of the helm releases in generally the order they should be deployed.
Expand All @@ -188,15 +188,15 @@ func Create(ctx context.Context, bbOpts Opts) error {
// The check it, we need to look for the existence of APIService instead of the HelmRelease, which
// may not ever be created. See links below for more details.
// https://repo1.dso.mil/big-bang/bigbang/-/blob/1.54.0/chart/templates/metrics-server/helmrelease.yaml
if hr.Metadata.Name == "metrics-server" {
if hr.metadata.Name == "metrics-server" {
continue
}

healthCheck := v1alpha1.NamespacedObjectKindReference{
APIVersion: "v1",
Kind: "HelmRelease",
Name: hr.Metadata.Name,
Namespace: hr.Metadata.Namespace,
Name: hr.metadata.Name,
Namespace: hr.metadata.Namespace,
}

bbComponent.HealthChecks = append(bbComponent.HealthChecks, healthCheck)
Expand All @@ -211,8 +211,8 @@ func Create(ctx context.Context, bbOpts Opts) error {
// Select the images needed to support the repos for this configuration of Big Bang.
if bbOpts.Airgap {
for _, hr := range hrDependencies {
namespacedName := getNamespacedNameFromMeta(hr.Metadata)
gitRepo := gitRepos[hr.NamespacedSource]
namespacedName := getNamespacedNameFromMeta(hr.metadata)
gitRepo := gitRepos[hr.namespacedSource]
values := hrValues[namespacedName]

images, err := findImagesForBBChartRepo(ctx, gitRepo, values)
Expand Down Expand Up @@ -353,10 +353,11 @@ func findBBResources(t string) (map[string]string, []HelmReleaseDependency, map[
srcNamespacedName := getNamespacedNameFromStr(h.Spec.Chart.Spec.SourceRef.Namespace, h.Spec.Chart.Spec.SourceRef.Name)

helmReleaseDeps = append(helmReleaseDeps, HelmReleaseDependency{
Metadata: h.ObjectMeta,
NamespacedDependencies: deps,
NamespacedSource: srcNamespacedName,
ValuesFrom: h.Spec.ValuesFrom,
typeMeta: h.TypeMeta,
metadata: h.ObjectMeta,
namespacedDependencies: deps,
namespacedSource: srcNamespacedName,
valuesFrom: h.Spec.ValuesFrom,
})

case fluxSrcCtrl.GitRepositoryKind:
Expand Down Expand Up @@ -403,7 +404,7 @@ func findBBResources(t string) (map[string]string, []HelmReleaseDependency, map[
}

for _, hr := range helmReleaseDeps {
namespacedName := getNamespacedNameFromMeta(hr.Metadata)
namespacedName := getNamespacedNameFromMeta(hr.metadata)
values, err := composeValues(hr, secrets, configMaps)
if err != nil {
return nil, nil, nil, err
Expand Down
12 changes: 8 additions & 4 deletions src/internal/bigbang/bigbang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ func TestFindBBResources(t *testing.T) {
},
expectedHelmReleaseDeps: []HelmReleaseDependency{
{
Metadata: metav1.ObjectMeta{
typeMeta: metav1.TypeMeta{
Kind: "HelmRelease",
APIVersion: "helm.toolkit.fluxcd.io/v2beta1",
},
metadata: metav1.ObjectMeta{
Name: "my-helm-release",
Namespace: "default",
},
NamespacedDependencies: []string{"istio.another-helm-release"},
NamespacedSource: "default.my-git-repo",
ValuesFrom: []fluxv2.ValuesReference{
namespacedDependencies: []string{"istio.another-helm-release"},
namespacedSource: "default.my-git-repo",
valuesFrom: []fluxv2.ValuesReference{
{
Kind: "ConfigMap",
Name: "my-configmap",
Expand Down
15 changes: 8 additions & 7 deletions src/internal/bigbang/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (

// HelmReleaseDependency is a struct that represents a Flux Helm Release from an HR DependsOn list.
type HelmReleaseDependency struct {
Metadata metav1.ObjectMeta
NamespacedDependencies []string
NamespacedSource string
ValuesFrom []fluxHelmCtrl.ValuesReference
typeMeta metav1.TypeMeta
metadata metav1.ObjectMeta
namespacedDependencies []string
namespacedSource string
valuesFrom []fluxHelmCtrl.ValuesReference
}

// readFluxImages finds the images Flux needs to deploy
Expand Down Expand Up @@ -70,9 +71,9 @@ func readFluxImages(fluxFilePath string) (images []string, err error) {
func composeValues(hr HelmReleaseDependency, secrets map[string]corev1.Secret, configMaps map[string]corev1.ConfigMap) (valuesMap chartutil.Values, err error) {
valuesMap = chartutil.Values{}

for _, v := range hr.ValuesFrom {
for _, v := range hr.valuesFrom {
var valuesData string
namespacedName := getNamespacedNameFromStr(hr.Metadata.Namespace, v.Name)
namespacedName := getNamespacedNameFromStr(hr.metadata.Namespace, v.Name)

switch v.Kind {
case "ConfigMap":
Expand Down Expand Up @@ -101,7 +102,7 @@ func composeValues(hr HelmReleaseDependency, secrets map[string]corev1.Secret, c

values, err := chartutil.ReadValues([]byte(valuesData))
if err != nil {
return nil, fmt.Errorf("unable to read values from key '%s' in %s '%s': %w", v.GetValuesKey(), v.Kind, hr.Metadata.Name, err)
return nil, fmt.Errorf("unable to read values from key '%s' in %s '%s': %w", v.GetValuesKey(), v.Kind, hr.metadata.Name, err)
}

valuesMap = helpers.MergeMapRecursive(valuesMap, values)
Expand Down

0 comments on commit 7be99b9

Please sign in to comment.