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

Commit 44ca7d9

Browse files
moadqassemcprivitere
authored andcommitted
add support for metros
Signed-off-by: Moath Qasim <[email protected]>
1 parent 774b297 commit 44ca7d9

11 files changed

+55
-2
lines changed

api/v1alpha3/packetcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ type PacketClusterSpec struct {
3232
// Facility represents the Packet facility for this cluster
3333
Facility string `json:"facility,omitempty"`
3434

35+
// Metro represents the Packet metro for this cluster
36+
// +optional
37+
Metro string `json:"metro,omitempty"`
38+
3539
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
3640
// +optional
3741
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

api/v1alpha3/packetmachine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ type PacketMachineSpec struct {
4040
// +optional
4141
Facility string `json:"facility,omitempty"`
4242

43+
// Metro represents the Packet metro for this cluster
44+
// +optional
45+
Metro string `json:"metro,omitempty"`
46+
4347
// IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider.
4448
// Note that OS should also be set to "custom_ipxe" if using this value.
4549
// +optional

api/v1alpha3/zz_generated.conversion.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/packetcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ type PacketClusterSpec struct {
3737
// Facility represents the Packet facility for this cluster
3838
Facility string `json:"facility,omitempty"`
3939

40+
// Metro represents the Packet metro for this cluster
41+
// +optional
42+
Metro string `json:"metro,omitempty"`
43+
4044
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
4145
// +optional
4246
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`

api/v1beta1/packetcluster_webhook.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ func (c *PacketCluster) ValidateUpdate(oldRaw runtime.Object) error {
7171
)
7272
}
7373

74+
if !reflect.DeepEqual(c.Spec.Metro, old.Spec.Metro) {
75+
allErrs = append(allErrs,
76+
field.Invalid(field.NewPath("spec", "Metro"),
77+
c.Spec.Metro, "field is immutable"),
78+
)
79+
}
80+
7481
if !reflect.DeepEqual(c.Spec.VIPManager, old.Spec.VIPManager) {
7582
allErrs = append(allErrs,
7683
field.Invalid(field.NewPath("spec", "VIPManager"),

api/v1beta1/packetmachine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ type PacketMachineSpec struct {
6363
// +optional
6464
Facility string `json:"facility,omitempty"`
6565

66+
// Metro represents the Packet metro for this cluster
67+
// +optional
68+
Metro string `json:"metro,omitempty"`
69+
6670
// IPXEUrl can be used to set the pxe boot url when using custom OSes with this provider.
6771
// Note that OS should also be set to "custom_ipxe" if using this value.
6872
// +optional

config/crd/bases/infrastructure.cluster.x-k8s.io_packetclusters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ spec:
6464
facility:
6565
description: Facility represents the Packet facility for this cluster
6666
type: string
67+
metro:
68+
description: Metro represents the Packet metro for this cluster
69+
type: string
6770
projectID:
6871
description: ProjectID represents the Packet Project where this cluster
6972
will be placed into
@@ -139,6 +142,9 @@ spec:
139142
facility:
140143
description: Facility represents the Packet facility for this cluster
141144
type: string
145+
metro:
146+
description: Metro represents the Packet metro for this cluster
147+
type: string
142148
projectID:
143149
description: ProjectID represents the Packet Project where this cluster
144150
will be placed into

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ spec:
7878
type: string
7979
machineType:
8080
type: string
81+
metro:
82+
description: Metro represents the Packet metro for this cluster
83+
type: string
8184
providerID:
8285
description: ProviderID is the unique identifier as specified by the
8386
cloud provider.
@@ -209,6 +212,9 @@ spec:
209212
type: string
210213
machineType:
211214
type: string
215+
metro:
216+
description: Metro represents the Packet metro for this cluster
217+
type: string
212218
os:
213219
type: string
214220
providerID:

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ spec:
6767
type: string
6868
machineType:
6969
type: string
70+
metro:
71+
description: Metro represents the Packet metro for this cluster
72+
type: string
7073
providerID:
7174
description: ProviderID is the unique identifier as specified
7275
by the cloud provider.
@@ -143,6 +146,9 @@ spec:
143146
type: string
144147
machineType:
145148
type: string
149+
metro:
150+
description: Metro represents the Packet metro for this cluster
151+
type: string
146152
os:
147153
type: string
148154
providerID:

controllers/packetcluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *PacketClusterReconciler) reconcileNormal(ctx context.Context, clusterSc
117117
switch {
118118
case errors.Is(err, packet.ErrControlPlanEndpointNotFound):
119119
// There is not an ElasticIP with the right tags, at this point we can create one
120-
ip, err := r.PacketClient.CreateIP(clusterScope.Namespace(), clusterScope.Name(), packetCluster.Spec.ProjectID, packetCluster.Spec.Facility)
120+
ip, err := r.PacketClient.CreateIP(clusterScope.Namespace(), clusterScope.Name(), packetCluster.Spec.ProjectID, packetCluster.Spec.Facility, packetCluster.Spec.Metro)
121121
if err != nil {
122122
log.Error(err, "error reserving an ip")
123123
return ctrl.Result{}, err

0 commit comments

Comments
 (0)