Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CustomScript = `` /* 139-byte string literal not displayed */
CustomScript is the template for the custom script. It will either chain to a URL or execute an iPXE script.
var HookScript = `#!ipxe
` + syslogScript + `
echo Loading the Tinkerbell Hook iPXE script...
{{- if .TraceID }}
echo Debug TraceID: {{ .TraceID }}
{{- end }}
set arch {{ .Arch }}
set download-url {{ .DownloadURL }}
set kernel {{ if .KernelName }}{{ .KernelName }}{{ else }}vmlinuz-${arch}{{ end }}
set initrd {{ if .InitrdName }}{{ .InitrdName }}{{ else }}initramfs-${arch}{{ end }}
set retries:int32 {{ .Retries }}
set retry_delay:int32 {{ .RetryDelay }}
set idx:int32 0
:retry_kernel
kernel ${download-url}/${kernel} {{- if ne .VLANID "" }} vlan_id={{ .VLANID }} {{- end }} \
facility={{ .Facility }} syslog_host={{ .SelectedSyslogHost }} grpc_authority={{ .TinkGRPCAuthority }} tinkerbell_tls={{ .TinkerbellTLS }} tinkerbell_insecure_tls={{ .TinkerbellInsecureTLS }} worker_id={{ .WorkerID }} hw_addr={{ .HWAddr }} \
modules=loop,squashfs,sd-mod,usb-storage intel_iommu=on iommu=pt initrd=${initrd} console=tty0 console=ttyS1,115200 {{- range .ExtraKernelParams}} {{.}} {{- end}} && goto download_initrd || iseq ${idx} ${retries} && goto kernel-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_kernel
:download_initrd
set idx:int32 0
:retry_initrd
initrd ${download-url}/${initrd} && goto {{ if .BootstrapURL }}download_bootstrap{{ else }}boot{{ end }} || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd
{{- if .BootstrapURL }}
:download_bootstrap
# The bootstrap initrd is a relative path only: iPXE fetches it from the server that served this script.
set idx:int32 0
:retry_bootstrap
initrd {{ .BootstrapURL }} && goto boot || iseq ${idx} ${retries} && goto bootstrap-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_bootstrap
{{- end }}
:boot
set idx:int32 0
:retry_boot
boot || iseq ${idx} ${retries} && goto boot-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_boot
:kernel-error
echo Failed to load kernel
imgfree
exit
:initrd-error
echo Failed to load initrd
imgfree
exit
{{- if .BootstrapURL }}
:bootstrap-error
echo Failed to load bootstrap data
imgfree
exit
{{- end }}
:boot-error
echo Failed to boot
imgfree
exit
`
HookScript is the default iPXE script for loading Hook.
var StaticScript = `#!ipxe
` + syslogScript + `echo Loading the static Tinkerbell iPXE script...
set arch ${buildarch}
# Tinkerbell only supports 64 bit architectures.
# The build architecture does not necessarily represent the architecture of the machine on which iPXE is running.
# https://ipxe.org/cfg/buildarch
iseq ${arch} i386 && set arch x86_64 ||
iseq ${arch} arm32 && set arch aarch64 ||
iseq ${arch} arm64 && set arch aarch64 ||
set kernel {{ if .KernelName }}{{ .KernelName }}-${arch}{{ else }}vmlinuz-${arch}{{ end }}
set initrd {{ if .InitrdName }}{{ .InitrdName }}-${arch}{{ else }}initramfs-${arch}{{ end }}
set download-url {{ .DownloadURL }}
set retries:int32 {{ .Retries }}
set retry_delay:int32 {{ .RetryDelay }}
set worker_id ${mac}
set grpc_authority {{ .TinkGRPCAuthority }}
set syslog_host {{ .SelectedSyslogHost }}
set tinkerbell_tls {{ .TinkerbellTLS }}
echo worker_id=${mac}
echo grpc_authority={{ .TinkGRPCAuthority }}
echo syslog_host={{ .SelectedSyslogHost }}
echo tinkerbell_tls={{ .TinkerbellTLS }}
set idx:int32 0
:retry_kernel
kernel ${download-url}/${kernel} \
syslog_host=${syslog_host} grpc_authority=${grpc_authority} tinkerbell_tls=${tinkerbell_tls} worker_id=${worker_id} hw_addr=${mac} \
console=tty1 console=tty2 console=ttyAMA0,115200 console=ttyAMA1,115200 console=ttyS0,115200 console=ttyS1,115200 \
intel_iommu=on iommu=pt {{- range .ExtraKernelParams}} {{.}} {{- end}} initrd=${initrd} && goto download_initrd || iseq ${idx} ${retries} && goto kernel-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_kernel
:download_initrd
set idx:int32 0
:retry_initrd
initrd ${download-url}/${initrd} && goto boot || iseq ${idx} ${retries} && goto initrd-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_initrd
:boot
set idx:int32 0
:retry_boot
boot || iseq ${idx} ${retries} && goto boot-error || inc idx && echo retry in ${retry_delay} seconds ; sleep ${retry_delay} ; goto retry_boot
:kernel-error
echo Failed to load kernel
imgfree
exit
:initrd-error
echo Failed to load initrd
imgfree
exit
:boot-error
echo Failed to boot
imgfree
exit
`
StaticScript is the iPXE script used when in the auto-proxy mode. It is built to be generic enough for all hardware to use.
Functions ¶
Types ¶
type Custom ¶
Custom holds either a URL to chain to or a script to execute. There is no validation of the script.
type Handler ¶
type Handler struct {
Logger logr.Logger
Backend hardware.BackendReader
OSIEURL string
OSIEURLv6 string
ExtraKernelParams []string
ExtraKernelParamsV6 []string
PublicSyslogFQDN string
PublicSyslogFQDNV6 string
TinkServerTLS bool
TinkServerInsecureTLS bool
TinkServerGRPCAddr string
TinkServerGRPCAddrV6 string
IPXEScriptRetries int
IPXEScriptRetryDelay int
StaticIPXEEnabled bool
StaticIPXEV6Enabled bool
KernelName string // name of the kernel file
InitrdName string // name of the initrd file
// BootstrapPath is the route per-host configuration archives are served
// under on this server, e.g. "/bootstrap/". Empty disables delivery.
BootstrapPath string
}
func (*Handler) HandlerFunc ¶
func (h *Handler) HandlerFunc() http.HandlerFunc
HandlerFunc returns a http.HandlerFunc that serves the ipxe script. It is expected that the request path is /<mac address>/auto.ipxe or /<mac address>/auto6.ipxe.
type Hook ¶
type Hook struct {
AddressFamily addressFamily // selected from the requested boot script
Arch string // example x86_64
Console string // example ttyS1,115200
DownloadURL string // example https://location:8080/to/kernel/and/initrd
ExtraKernelParams []string // example tink_worker_image=quay.io/tinkerbell/tink-worker:v0.8.0
Facility string
HWAddr string // example 3c:ec:ef:4c:4f:54
SyslogHost string
SyslogHostV6 string // used only by the DHCPv6 boot script
TinkerbellTLS bool
TinkerbellInsecureTLS bool
TinkGRPCAuthority string // example 192.168.2.111:42113
TraceID string
VLANID string // string number between 1-4095
WorkerID string // example 3c:ec:ef:4c:4f:54 or worker1
Retries int // number of retries to attempt when fetching kernel and initrd files
RetryDelay int // number of seconds to wait between retries
KernelName string // name of the kernel file
InitrdName string // name of the initrd file
// BootstrapURL is the per-host configuration archive, loaded as an
// additional initrd. It must come after the OS initramfs: the kernel
// applies archives in order, so an earlier one would be overwritten.
// Empty omits the whole stanza.
BootstrapURL string
}
Hook holds the values used to generate the iPXE script that loads the Hook OS.
func (Hook) SelectedSyslogHost ¶ added in v0.26.0
SelectedSyslogHost returns the host for the boot script's address family.