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

Commit 115debb

Browse files
authored
Merge pull request #143 from rsmitty/master
feat: support use of pxeurls in machine provisioning
2 parents 8a32813 + ab57ab9 commit 115debb

File tree

5 files changed

+42
-62
lines changed

5 files changed

+42
-62
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_packetclusters.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,18 @@ spec:
2222
description: PacketCluster is the Schema for the packetclusters API
2323
properties:
2424
apiVersion:
25-
description: 'APIVersion defines the versioned schema of this representation
26-
of an object. Servers should convert recognized schemas to the latest
27-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
25+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
2826
type: string
2927
kind:
30-
description: 'Kind is a string value representing the REST resource this
31-
object represents. Servers may infer this from the endpoint the client
32-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
28+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
3329
type: string
3430
metadata:
3531
type: object
3632
spec:
3733
description: PacketClusterSpec defines the desired state of PacketCluster
3834
properties:
3935
controlPlaneEndpoint:
40-
description: ControlPlaneEndpoint represents the endpoint used to communicate
41-
with the control plane.
36+
description: ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
4237
properties:
4338
host:
4439
description: The hostname on which the API server is serving.
@@ -55,8 +50,7 @@ spec:
5550
description: Facility represents the Packet facility for this cluster
5651
type: string
5752
projectID:
58-
description: ProjectID represents the Packet Project where this cluster
59-
will be placed into
53+
description: ProjectID represents the Packet Project where this cluster will be placed into
6054
type: string
6155
required:
6256
- projectID

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

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ spec:
4545
description: PacketMachine is the Schema for the packetmachines API
4646
properties:
4747
apiVersion:
48-
description: 'APIVersion defines the versioned schema of this representation
49-
of an object. Servers should convert recognized schemas to the latest
50-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
48+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
5149
type: string
5250
kind:
53-
description: 'Kind is a string value representing the REST resource this
54-
object represents. Servers may infer this from the endpoint the client
55-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
51+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
5652
type: string
5753
metadata:
5854
type: object
@@ -64,23 +60,22 @@ spec:
6460
billingCycle:
6561
type: string
6662
hardwareReservationID:
67-
description: HardwareReservationID is the unique device hardware reservation
68-
ID or `next-available` to automatically let the Packet api determine
69-
one.
63+
description: HardwareReservationID is the unique device hardware reservation ID or `next-available` to automatically let the Packet api determine one.
64+
type: string
65+
ipxeURL:
66+
description: IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider. Note that OS should also be set to "custom_ipxe" if using this value.
7067
type: string
7168
machineType:
7269
type: string
7370
providerID:
74-
description: ProviderID is the unique identifier as specified by the
75-
cloud provider.
71+
description: ProviderID is the unique identifier as specified by the cloud provider.
7672
type: string
7773
sshKeys:
7874
items:
7975
type: string
8076
type: array
8177
tags:
82-
description: Tags is an optional set of tags to add to Packet resources
83-
managed by the Packet provider.
78+
description: Tags is an optional set of tags to add to Packet resources managed by the Packet provider.
8479
items:
8580
type: string
8681
type: array
@@ -101,37 +96,21 @@ spec:
10196
description: The node address.
10297
type: string
10398
type:
104-
description: Node address type, one of Hostname, ExternalIP or
105-
InternalIP.
99+
description: Node address type, one of Hostname, ExternalIP or InternalIP.
106100
type: string
107101
required:
108102
- address
109103
- type
110104
type: object
111105
type: array
112106
errorMessage:
113-
description: "ErrorMessage will be set in the event that there is a
114-
terminal problem reconciling the Machine and will contain a more verbose
115-
string suitable for logging and human consumption. \n This field should
116-
not be set for transitive errors that a controller faces that are
117-
expected to be fixed automatically over time (like service outages),
118-
but instead indicate that something is fundamentally wrong with the
119-
Machine's spec or the configuration of the controller, and that manual
120-
intervention is required. Examples of terminal errors would be invalid
121-
combinations of settings in the spec, values that are unsupported
122-
by the controller, or the responsible controller itself being critically
123-
misconfigured. \n Any transient errors that occur during the reconciliation
124-
of Machines can be added as events to the Machine object and/or logged
125-
in the controller's output."
107+
description: "ErrorMessage will be set in the event that there is a terminal problem reconciling the Machine and will contain a more verbose string suitable for logging and human consumption. \n This field should not be set for transitive errors that a controller faces that are expected to be fixed automatically over time (like service outages), but instead indicate that something is fundamentally wrong with the Machine's spec or the configuration of the controller, and that manual intervention is required. Examples of terminal errors would be invalid combinations of settings in the spec, values that are unsupported by the controller, or the responsible controller itself being critically misconfigured. \n Any transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output."
126108
type: string
127109
errorReason:
128-
description: Any transient errors that occur during the reconciliation
129-
of Machines can be added as events to the Machine object and/or logged
130-
in the controller's output.
110+
description: Any transient errors that occur during the reconciliation of Machines can be added as events to the Machine object and/or logged in the controller's output.
131111
type: string
132112
instanceStatus:
133-
description: InstanceStatus is the status of the Packet device instance
134-
for this machine.
113+
description: InstanceStatus is the status of the Packet device instance for this machine.
135114
type: string
136115
ready:
137116
description: Ready is true when the provider resource is ready.

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,46 @@ spec:
1919
scope: Namespaced
2020
validation:
2121
openAPIV3Schema:
22-
description: PacketMachineTemplate is the Schema for the packetmachinetemplates
23-
API
22+
description: PacketMachineTemplate is the Schema for the packetmachinetemplates API
2423
properties:
2524
apiVersion:
26-
description: 'APIVersion defines the versioned schema of this representation
27-
of an object. Servers should convert recognized schemas to the latest
28-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
25+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
2926
type: string
3027
kind:
31-
description: 'Kind is a string value representing the REST resource this
32-
object represents. Servers may infer this from the endpoint the client
33-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
28+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
3429
type: string
3530
metadata:
3631
type: object
3732
spec:
3833
description: PacketMachineTemplateSpec defines the desired state of PacketMachineTemplate
3934
properties:
4035
template:
41-
description: PacketMachineTemplateResource describes the data needed
42-
to create am PacketMachine from a template
36+
description: PacketMachineTemplateResource describes the data needed to create am PacketMachine from a template
4337
properties:
4438
spec:
45-
description: Spec is the specification of the desired behavior of
46-
the machine.
39+
description: Spec is the specification of the desired behavior of the machine.
4740
properties:
4841
OS:
4942
type: string
5043
billingCycle:
5144
type: string
5245
hardwareReservationID:
53-
description: HardwareReservationID is the unique device hardware
54-
reservation ID or `next-available` to automatically let the
55-
Packet api determine one.
46+
description: HardwareReservationID is the unique device hardware reservation ID or `next-available` to automatically let the Packet api determine one.
47+
type: string
48+
ipxeURL:
49+
description: IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider. Note that OS should also be set to "custom_ipxe" if using this value.
5650
type: string
5751
machineType:
5852
type: string
5953
providerID:
60-
description: ProviderID is the unique identifier as specified
61-
by the cloud provider.
54+
description: ProviderID is the unique identifier as specified by the cloud provider.
6255
type: string
6356
sshKeys:
6457
items:
6558
type: string
6659
type: array
6760
tags:
68-
description: Tags is an optional set of tags to add to Packet
69-
resources managed by the Packet provider.
61+
description: Tags is an optional set of tags to add to Packet resources managed by the Packet provider.
7062
items:
7163
type: string
7264
type: array

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+
ipxeOS = "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 != ipxeOS {
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)