Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1alpha3/packetmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ type PacketMachineSpec struct {
MachineType string `json:"machineType"`
SshKeys []string `json:"sshKeys,omitempty"`

// Facility represents the Packet facility for this cluster.
// Override from the PacketCluster spec.
// +optional
Facility string `json:"facility,omitempty"`

// 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.
// +optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand All @@ -20,23 +22,18 @@ spec:
description: PacketCluster is the Schema for the packetclusters API
properties:
apiVersion:
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'
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'
type: string
kind:
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'
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'
type: string
metadata:
type: object
spec:
description: PacketClusterSpec defines the desired state of PacketCluster
properties:
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
description: ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
properties:
host:
description: The hostname on which the API server is serving.
Expand All @@ -53,8 +50,7 @@ spec:
description: Facility represents the Packet facility for this cluster
type: string
projectID:
description: ProjectID represents the Packet Project where this cluster
will be placed into
description: ProjectID represents the Packet Project where this cluster will be placed into
type: string
required:
- projectID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down Expand Up @@ -43,14 +45,10 @@ spec:
description: PacketMachine is the Schema for the packetmachines API
properties:
apiVersion:
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'
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'
type: string
kind:
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'
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'
type: string
metadata:
type: object
Expand All @@ -61,29 +59,26 @@ spec:
type: string
billingCycle:
type: string
facility:
description: Facility represents the Packet facility for this cluster. Override from the PacketCluster spec.
type: string
hardwareReservationID:
description: HardwareReservationID is the unique device hardware reservation
ID or `next-available` to automatically let the Packet api determine
one.
description: HardwareReservationID is the unique device hardware reservation ID or `next-available` to automatically let the Packet api determine one.
type: string
ipxeURL:
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.
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.
type: string
machineType:
type: string
providerID:
description: ProviderID is the unique identifier as specified by the
cloud provider.
description: ProviderID is the unique identifier as specified by the cloud provider.
type: string
sshKeys:
items:
type: string
type: array
tags:
description: Tags is an optional set of tags to add to Packet resources
managed by the Packet provider.
description: Tags is an optional set of tags to add to Packet resources managed by the Packet provider.
items:
type: string
type: array
Expand All @@ -104,37 +99,21 @@ spec:
description: The node address.
type: string
type:
description: Node address type, one of Hostname, ExternalIP
or InternalIP.
description: Node address type, one of Hostname, ExternalIP or InternalIP.
type: string
required:
- address
- type
type: object
type: array
errorMessage:
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."
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."
type: string
errorReason:
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.
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.
type: string
instanceStatus:
description: InstanceStatus is the status of the Packet device instance
for this machine.
description: InstanceStatus is the status of the Packet device instance for this machine.
type: string
ready:
description: Ready is true when the provider resource is ready.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand All @@ -19,59 +21,49 @@ spec:
- name: v1alpha3
schema:
openAPIV3Schema:
description: PacketMachineTemplate is the Schema for the packetmachinetemplates
API
description: PacketMachineTemplate is the Schema for the packetmachinetemplates API
properties:
apiVersion:
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'
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'
type: string
kind:
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'
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'
type: string
metadata:
type: object
spec:
description: PacketMachineTemplateSpec defines the desired state of PacketMachineTemplate
properties:
template:
description: PacketMachineTemplateResource describes the data needed
to create am PacketMachine from a template
description: PacketMachineTemplateResource describes the data needed to create am PacketMachine from a template
properties:
spec:
description: Spec is the specification of the desired behavior
of the machine.
description: Spec is the specification of the desired behavior of the machine.
properties:
OS:
type: string
billingCycle:
type: string
facility:
description: Facility represents the Packet facility for this cluster. Override from the PacketCluster spec.
type: string
hardwareReservationID:
description: HardwareReservationID is the unique device hardware
reservation ID or `next-available` to automatically let
the Packet api determine one.
description: HardwareReservationID is the unique device hardware reservation ID or `next-available` to automatically let the Packet api determine one.
type: string
ipxeURL:
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.
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.
type: string
machineType:
type: string
providerID:
description: ProviderID is the unique identifier as specified
by the cloud provider.
description: ProviderID is the unique identifier as specified by the cloud provider.
type: string
sshKeys:
items:
type: string
type: array
tags:
description: Tags is an optional set of tags to add to Packet
resources managed by the Packet provider.
description: Tags is an optional set of tags to add to Packet resources managed by the Packet provider.
items:
type: string
type: array
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down
8 changes: 7 additions & 1 deletion pkg/cloud/packet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ func (p *PacketClient) NewDevice(req CreateDeviceRequest) (*packngo.Device, erro

userData = stringWriter.String()

// Allow to override the facility for each PacketMachineTemplate
var facility = req.MachineScope.PacketCluster.Spec.Facility
if req.MachineScope.PacketMachine.Spec.Facility != "" {
facility = req.MachineScope.PacketMachine.Spec.Facility
}

serverCreateOpts := &packngo.DeviceCreateRequest{
Hostname: req.MachineScope.Name(),
ProjectID: req.MachineScope.PacketCluster.Spec.ProjectID,
Facility: []string{req.MachineScope.PacketCluster.Spec.Facility},
Facility: []string{facility},
BillingCycle: req.MachineScope.PacketMachine.Spec.BillingCycle,
HardwareReservationID: req.MachineScope.PacketMachine.Spec.HardwareReservationID,
Plan: req.MachineScope.PacketMachine.Spec.MachineType,
Expand Down