Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 35849c3

Browse files
committed
feat: support use of pxeurls in machine provisioning
This PR will add a new field to packetmachine that allows for the passing of a pxe url string. If present, we check that the OS is also set to "custom_ipxe" so that we can fail early. Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
1 parent 620918f commit 35849c3

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

api/v1alpha3/packetmachine_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ type PacketMachineSpec struct {
3838
MachineType string `json:"machineType"`
3939
SshKeys []string `json:"sshKeys,omitempty"`
4040

41+
// IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider.
42+
// Note that OS should also be set to "custom_ipxe" if using this value.
43+
// +optional
44+
IPXEUrl string `json:"ipxeURL,omitempty"`
45+
4146
// HardwareReservationID is the unique device hardware reservation ID or `next-available` to
4247
// automatically let the Packet api determine one.
4348
// +optional

config/resources/crd/bases/infrastructure.cluster.x-k8s.io_packetmachines.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ spec:
6868
ID or `next-available` to automatically let the Packet api determine
6969
one.
7070
type: string
71+
ipxeURL:
72+
description: IPXEUrl can be used to set the pxe boot url when using
73+
custom OSes with this provider. Note that OS should also be set to
74+
"custom_ipxe" if using this value.
75+
type: string
7176
machineType:
7277
type: string
7378
providerID:

config/resources/crd/bases/infrastructure.cluster.x-k8s.io_packetmachinetemplates.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ spec:
5454
reservation ID or `next-available` to automatically let the
5555
Packet api determine one.
5656
type: string
57+
ipxeURL:
58+
description: IPXEUrl can be used to set the pxe boot url when
59+
using custom OSes with this provider. Note that OS should
60+
also be set to "custom_ipxe" if using this value.
61+
type: string
5762
machineType:
5863
type: string
5964
providerID:

pkg/cloud/packet/client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
const (
3535
apiTokenVarName = "PACKET_API_KEY"
3636
clientName = "CAPP-v1alpha3"
37+
pxeOS = "custom_ipxe"
3738
)
3839

3940
var ErrControlPlanEndpointNotFound = errors.New("contorl plane not found")
@@ -104,6 +105,15 @@ func (p *PacketClient) NewDevice(machineScope *scope.MachineScope, extraTags []s
104105
UserData: userData,
105106
}
106107

108+
// Update server options to pass pxe url if specified
109+
if machineScope.PacketMachine.Spec.IPXEUrl != "" {
110+
// Error if pxe url and OS conflict
111+
if machineScope.PacketMachine.Spec.OS != pxeOS {
112+
return nil, fmt.Errorf("os should be set to custom_pxe when using pxe urls")
113+
}
114+
serverCreateOpts.IPXEScriptURL = machineScope.PacketMachine.Spec.IPXEUrl
115+
}
116+
107117
dev, _, err := p.Client.Devices.Create(serverCreateOpts)
108118
return dev, err
109119
}

0 commit comments

Comments
 (0)