Merge "Add hardware profile / firmware plumbing"

This commit is contained in:
Zuul 2020-08-11 12:01:34 +00:00 committed by Gerrit Code Review
commit 2260e0bac8
9 changed files with 76 additions and 1 deletions

View File

@ -0,0 +1,13 @@
Function: hardwareprofile-example
=================================
This function defines a hardware profile that can be consumed by the
hostgenerator-m3 function, and which has the same values as the default
profile defined in that function. It serves as an example for how other
hardware profile functions can be created and consumed.
The `/replacements` kustomization contains a substution rule that injects
the profile into the hostgenerator BMH template. Please see the
`manifests/type/gating` type and `manifests/type/test-site`
kustomization.yamls to see how a hardwareprofile function can be wired in.

View File

@ -0,0 +1,10 @@
apiVersion: airshipit.org/v1alpha1
kind: VariableCatalogue
metadata:
# NOTE: change this when copying this example
name: hardwareprofile-example
hardwareProfile:
firmware:
sriovEnabled: false
virtualizationDisabled: false
simultaneousMultithreadingDisabled: false

View File

@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- hardwareprofile.yaml

View File

@ -0,0 +1,19 @@
# These rules inject host-specific information from the `host-catalogue`
# into the hostgenerator-m3 function's Template plugin config.
apiVersion: airshipit.org/v1alpha1
kind: ReplacementTransformer
metadata:
# NOTE: change this when copying this example
name: hardwareprofile-example-replacements
replacements:
- source:
objref:
# NOTE: change this to match your hardwareProfile's metadata.name
name: hardwareprofile-example
fieldref: hardwareProfile
target:
objref:
kind: Templater
name: m3-host-template
# NOTE: change "example" below when copying this example
fieldrefs: [values.hardwareProfiles.example]

View File

@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- hosts.yaml

View File

@ -3,7 +3,7 @@ kind: Templater
metadata:
name: m3-host-template
# values:
values:
# hosts:
# (filled in from the comprehensive site-wide host-catalogue)
# hostsToGenerate:
@ -11,11 +11,23 @@ metadata:
# commonNetworking:
# (filled in with the type-specific common-networking-catalogue)
# Additional hardwareProfiles can be defined within their own functions,
# and then substituted into the stanza below.
# See function/hardwareprofile-example for an example of how to do this.
hardwareProfiles:
default:
# Reference: https://github.com/metal3-io/metal3-docs/blob/master/design/baremetal-operator/bios-config.md
firmware:
sriovEnabled: false
virtualizationDisabled: false
simultaneousMultithreadingDisabled: false
template: |
{{- $envAll := . }}
{{- range .hostsToGenerate }}
{{- $hostName := . }}
{{- $host := index $envAll.hosts $hostName }}
{{- $hardwareProfile := index $envAll.hardwareProfiles $host.hardwareProfile }}
---
apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
@ -33,6 +45,9 @@ template: |
bmc:
address: {{ $host.bmcAddress }}
credentialsName: {{ $hostName }}-bmc-secret
firmware:
{{ toYaml $hardwareProfile.firmware | indent 4 }}
---
apiVersion: v1
kind: Secret

View File

@ -1,9 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# TODO: these two should move up to type level in the future
- ../../../../../function/hostgenerator-m3
- ../../../../../function/hardwareprofile-example
- ../../../shared/catalogues/
- host-generation.yaml
transformers:
# TODO: these two should move up to type level in the future
- ../../../../../function/hostgenerator-m3/replacements
- ../../../../../function/hardwareprofile-example/replacements

View File

@ -1,9 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# TODO: these two should move up to type level in the future
- ../../../../../function/hostgenerator-m3
- ../../../../../function/hardwareprofile-example
- ../../../shared/catalogues/
- host-generation.yaml
transformers:
# TODO: these two should move up to type level in the future
- ../../../../../function/hostgenerator-m3/replacements
- ../../../../../function/hardwareprofile-example/replacements

View File

@ -18,6 +18,7 @@ hosts:
oam: 52:54:00:9b:27:4c
pxe: 52:54:00:b6:ed:31
bootMode: legacy
hardwareProfile: default # defined in the hostgenerator-m3 function
node02:
macAddress: 52:54:00:b6:ed:02
bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2
@ -29,3 +30,4 @@ hosts:
macAddresses:
oam: 52:54:00:9b:27:02
pxe: 52:54:00:b6:ed:02
hardwareProfile: example # defined in the hardwareprofile-example function