diff --git a/manifests/function/bootstrap/kustomization.yaml b/manifests/function/bootstrap/kustomization.yaml new file mode 100644 index 000000000..b1e944410 --- /dev/null +++ b/manifests/function/bootstrap/kustomization.yaml @@ -0,0 +1,2 @@ +generators: + - template.yaml diff --git a/manifests/function/bootstrap/replacements/kustomization.yaml b/manifests/function/bootstrap/replacements/kustomization.yaml new file mode 100644 index 000000000..59d5ea989 --- /dev/null +++ b/manifests/function/bootstrap/replacements/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - remotedirect-vars.yaml diff --git a/manifests/function/bootstrap/replacements/remotedirect-vars.yaml b/manifests/function/bootstrap/replacements/remotedirect-vars.yaml new file mode 100644 index 000000000..a42c84f55 --- /dev/null +++ b/manifests/function/bootstrap/replacements/remotedirect-vars.yaml @@ -0,0 +1,27 @@ +apiVersion: airshipit.org/v1alpha1 +kind: ReplacementTransformer +metadata: + name: versions-remotedirect-replacement + annotations: + config.kubernetes.io/function: |- + container: + image: quay.io/airshipit/replacement-transformer:v2 +replacements: +- source: + objref: + name: versions-remotedirect + fieldref: spec.remotedirect.isoURL + target: + objref: + kind: BaremetalManager + name: RemoteDirectEphemeral + fieldrefs: ["spec.operationOptions.remoteDirect.isoURL%ISO_URL%"] +- source: + objref: + name: versions-remotedirect + fieldref: spec.remotedirect.node + target: + objref: + kind: BaremetalManager + name: RemoteDirectEphemeral + fieldrefs: ["spec.hostSelector.name%EPHEMERAL_NODE%"] diff --git a/manifests/function/bootstrap/template.yaml b/manifests/function/bootstrap/template.yaml new file mode 100644 index 000000000..611e9a313 --- /dev/null +++ b/manifests/function/bootstrap/template.yaml @@ -0,0 +1,28 @@ +apiVersion: airshipit.org/v1alpha1 +kind: Templater +metadata: + name: iso-patch-template + annotations: + config.kubernetes.io/function: | + container: + image: quay.io/airshipit/templater:latest + envs: + - AIRSHIPCTL_EPHEMERAL_ISO_URL +template: | + {{- $isoURL := env "AIRSHIPCTL_EPHEMERAL_ISO_URL" }} + {{- if not (empty $isoURL) }} + apiVersion: builtin + kind: PatchStrategicMergeTransformer + metadata: + name: smp + patches: |- + --- + apiVersion: airshipit.org/v1alpha1 + kind: BaremetalManager + metadata: + name: RemoteDirectEphemeral + spec: + operationOptions: + remoteDirect: + isoURL: {{ $isoURL }} + {{- end }} diff --git a/manifests/phases/executors.yaml b/manifests/phases/executors.yaml index 1a8929465..aeb72b3ac 100644 --- a/manifests/phases/executors.yaml +++ b/manifests/phases/executors.yaml @@ -196,10 +196,10 @@ metadata: spec: operation: remote-direct hostSelector: - name: REPLACE_ME + name: EPHEMERAL_NODE operationOptions: remoteDirect: - isoURL: REPLACE_ME + isoURL: ISO_URL --- apiVersion: airshipit.org/v1alpha1 kind: GenericContainer diff --git a/manifests/phases/kustomization.yaml b/manifests/phases/kustomization.yaml index 1d53edebf..c24b42d19 100644 --- a/manifests/phases/kustomization.yaml +++ b/manifests/phases/kustomization.yaml @@ -9,3 +9,6 @@ patchesStrategicMerge: - clusterctl_init_options.yaml transformers: - ../function/clusterctl/replacements + # NOTE(aostapenko) Consume AIRSHIPCTL_EPHEMERAL_ISO_URL here that will + # have precedence over phase catalogue isoURL value + - ../function/bootstrap diff --git a/manifests/site/test-site/phases/catalogue.yaml b/manifests/site/test-site/phases/catalogue.yaml new file mode 100644 index 000000000..e7feea484 --- /dev/null +++ b/manifests/site/test-site/phases/catalogue.yaml @@ -0,0 +1,10 @@ +apiVersion: airshipit.org/v1alpha1 +kind: VersionsCatalogue +metadata: + name: versions-remotedirect +spec: + remotedirect: + # NOTE(aostapenko) This value will only be used in absense of + # AIRSHIPCTL_EPHEMERAL_ISO_URL environment variable + isoURL: http://localhost:8099/ephemeral.iso + node: node02 diff --git a/manifests/site/test-site/phases/kustomization.yaml b/manifests/site/test-site/phases/kustomization.yaml index ec6686c02..55159500e 100644 --- a/manifests/site/test-site/phases/kustomization.yaml +++ b/manifests/site/test-site/phases/kustomization.yaml @@ -1,6 +1,6 @@ resources: - ../kubeconfig - ../../../phases -## TODO Consider making a catalogue combined with variable substitution instead -patchesStrategicMerge: - - phase-patch.yaml \ No newline at end of file + - catalogue.yaml +transformers: + - ../../../function/bootstrap/replacements diff --git a/manifests/site/test-site/phases/phase-patch.yaml b/manifests/site/test-site/phases/phase-patch.yaml deleted file mode 100644 index 18f031368..000000000 --- a/manifests/site/test-site/phases/phase-patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: airshipit.org/v1alpha1 -kind: BaremetalManager -metadata: - name: RemoteDirectEphemeral -spec: - hostSelector: - name: node02 - operationOptions: - remoteDirect: - isoURL: http://localhost:8099/ephemeral.iso \ No newline at end of file