Skip to content

feat(): layer2 support for CAPP #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
05cbc0c
API and CRD changes for adding layer2 support
rahulii Aug 22, 2024
15aaba7
json tag fix
rahulii Aug 22, 2024
ebfddac
change ipAddressReservation to address
rahulii Aug 29, 2024
1d2b71e
make changes to the api as per design doc changes
rahulii Sep 17, 2024
e1a19b5
minor change
rahulii Sep 17, 2024
cdf7155
api changes and user-data implementation
rahulii Sep 25, 2024
4cfb7b8
add IPAddressManagement Service
rahulii Sep 26, 2024
f762e5b
merge bootstrap and layer2 cloud configs
rahulii Oct 8, 2024
a452289
add unit test cases
rahulii Oct 8, 2024
5f33a86
ipam support
vardhaman-surana Oct 8, 2024
aad4223
added rbac
vardhaman-surana Oct 8, 2024
25510bd
minor fix
rahulii Oct 9, 2024
16fdf8d
reconcile port settings for layer2 and bonded port
rahulii Oct 10, 2024
b7e1120
minor fix
rahulii Oct 11, 2024
fcfcaac
refactor code and add static routes
rahulii Oct 11, 2024
b7e871a
bug fix
rahulii Oct 11, 2024
ddf37d9
Merge pull request #1 from rahulii/ipam
rahulii Oct 11, 2024
d901fe6
delete unused code
rahulii Oct 11, 2024
c55ea3f
minor fix
rahulii Oct 14, 2024
4c64c5d
minor fix
rahulii Oct 14, 2024
d4d4b25
change failure to failed in state
rahulii Oct 14, 2024
4d30dcc
added ipaddress claim deletion
vardhaman-surana Oct 14, 2024
4f9c8fc
Merge pull request #2 from vardhaman-surana/ipaddressclaim-deletion
rahulii Oct 14, 2024
4efbfd8
add logs
rahulii Oct 14, 2024
07516df
add routes at network file and change user-data to make them persistent
rahulii Oct 15, 2024
6207973
fix a bug where multiple vxlans are involved
rahulii Oct 16, 2024
7e68faf
update design docs
rahulii Oct 21, 2024
475365c
update design docs
rahulii Oct 22, 2024
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
26 changes: 26 additions & 0 deletions api/v1beta1/packetcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const (
KUBEVIPID = "KUBE_VIP"
)

// AssignmentType describes the component responsible for allocating IP addresses to the machines.
type AssignmentType string

const (
AssignmentClusterAPI AssignmentType = "cluster-api"
AssignmentDHCP AssignmentType = "dhcp"
)

// VIPManagerType describes if the VIP will be managed by CPEM or kube-vip or Equinix Metal Load Balancer.
type VIPManagerType string

Expand All @@ -60,6 +68,24 @@ type PacketClusterSpec struct {
// +kubebuilder:validation:Enum=CPEM;KUBE_VIP;EMLB
// +kubebuilder:default:=CPEM
VIPManager VIPManagerType `json:"vipManager"`

// Networks is a list of network configurations for the PacketCluster
Networks []NetworkSpec `json:"networks,omitempty"`
}

// NetworkSpec defines the network configuration for a PacketCluster.
type NetworkSpec struct {
// Name of the network, e.g. "storage VLAN", is optional
// +optional
Name string `json:"name,omitempty"`
// Description of the network, e.g. "Storage network", is optional
// +optional
Description string `json:"description,omitempty"`
// AddressRange for the cluster network for eg: VRF IP Ranges
Addresses []string `json:"addresses,omitempty"`
// Assignment is component responsible for allocating IP addresses to the machines, either cluster-api or dhcp
// +kubebuilder:validation:Enum=cluster-api;dhcp
Assignment AssignmentType `json:"assignment,omitempty"`
}

// PacketClusterStatus defines the observed state of PacketCluster.
Expand Down
71 changes: 71 additions & 0 deletions api/v1beta1/packetmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const (
// MachineFinalizer allows ReconcilePacketMachine to clean up Packet resources before
// removing it from the apiserver.
MachineFinalizer = "packetmachine.infrastructure.cluster.x-k8s.io"
// IPAddressClaimFinalizer allows the reconciler to prevent deletion of an
// IPAddressClaim that is in use.
IPAddressClaimFinalizer = "packetmachine.infrastructure.cluster.x-k8s.io/ip-claim-protection"
)

const (
Expand All @@ -50,6 +53,32 @@ const (
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"
// WaitingForBootstrapDataReason used when machine is waiting for bootstrap data to be ready before proceeding.
WaitingForBootstrapDataReason = "WaitingForBootstrapData"

Layer2NetworkConfigurationConditionSuccess = "Layer2NetworkConfigurationSuccess"
Layer2NetworkConfigurationConditionFailed = "Layer2NetworkConfigurationFailed"

)

const (
// IPAddressClaimedCondition documents the status of claiming an IP address
// from an IPAM provider.
IPAddressClaimedCondition clusterv1.ConditionType = "IPAddressClaimed"

// IPAddressClaimsBeingCreatedReason (Severity=Info) documents that claims for the
// IP addresses required by the PacketMachine are being created.
IPAddressClaimsBeingCreatedReason = "IPAddressClaimsBeingCreated"

// WaitingForIPAddressReason (Severity=Info) documents that the PacketMachine is
// currently waiting for an IP address to be provisioned.
WaitingForIPAddressReason = "WaitingForIPAddress"

// IPAddressInvalidReason (Severity=Error) documents that the IP address
// provided by the IPAM provider is not valid.
IPAddressInvalidReason = "IPAddressInvalid"

// IPAddressClaimNotFoundReason (Severity=Error) documents that the IPAddressClaim
// cannot be found.
IPAddressClaimNotFoundReason = "IPAddressClaimNotFound"
)

// PacketMachineSpec defines the desired state of PacketMachine.
Expand Down Expand Up @@ -86,6 +115,48 @@ type PacketMachineSpec struct {
// Tags is an optional set of tags to add to Packet resources managed by the Packet provider.
// +optional
Tags Tags `json:"tags,omitempty"`

// NetworkPorts is an optional set of configurations for configuring layer2 seetings in a machine.
// +optional
NetworkPorts []*Port `json:"ports,omitempty"`
}

// Port defines the Layer2(VLAN) Configuration that needs to be done on a port (eg: bond0).
type Port struct {
// name of the port e.g bond0,eth0 and eth1 for 2 NIC servers.
Name string `json:"name"`
// port bonded or not.
Bonded bool `json:"bonded,omitempty"`
// convert port to layer 2. is false by default on new devices. changes result in /ports/id/convert/layer-[2|3] API calls
Layer2 bool `json:"layer2,omitempty"`
// Network configurations for the port
Networks []Network `json:"networks"`
}

// Network defines the network configuration for a port.
type Network struct {
// VLANs for EM API to find by vxlan, project, and metro match then attach to device. OS userdata template will also configure this VLAN on the bond device
VXLAN int `json:"vxlan,omitempty"`
// VLAN ID for the VLAN created on the EM Console
VLANID string `json:"vlanID,omitempty"`
// Netmask is the netmask for the network.
// eg: 255.255.255.248
Netmask string `json:"netmask,omitempty"`
// AddressFromPool is a reference of IPAddressPool that should be assigned to IPAddressClaim.
// The machine's cloud-init metadata will be populated with IPAddresse fulfilled by an IPAM provider.
AddressFromPool corev1.TypedLocalObjectReference `json:"addressFromPool,omitempty"`
// AddressType is the type of address to assign to the machine. It can be either Internal or External.
// kubebuilder:validation:Enum=Internal;External
AddressType string `json:"addressType,omitempty"`
// List of Routes to be configured on the Packet Machine
// +optional
Routes []*RouteSpec `json:"routes,omitempty"`
}

// RouteSpec defines the static route configuration for a PacketMachine.
type RouteSpec struct {
Destination string `json:"destination"`
Gateway string `json:"gateway"`
}

// PacketMachineStatus defines the observed state of PacketMachine.
Expand Down
104 changes: 103 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ spec:
metro:
description: Metro represents the Packet metro for this cluster
type: string
networks:
description: Networks is a list of network configurations for the
PacketCluster
items:
description: NetworkSpec defines the network configuration for a
PacketCluster.
properties:
addresses:
description: 'AddressRange for the cluster network for eg: VRF
IP Ranges'
items:
type: string
type: array
assignment:
description: Assignment is component responsible for allocating
IP addresses to the machines, either cluster-api or dhcp
enum:
- cluster-api
- dhcp
type: string
description:
description: Description of the network, e.g. "Storage network",
is optional
type: string
name:
description: Name of the network, e.g. "storage VLAN", is optional
type: string
type: object
type: array
projectID:
description: ProjectID represents the Packet Project where this cluster
will be placed into
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,94 @@ spec:
type: string
os:
type: string
ports:
description: NetworkPorts is an optional set of configurations for
configuring layer2 seetings in a machine.
items:
description: 'Port defines the Layer2(VLAN) Configuration that needs
to be done on a port (eg: bond0).'
properties:
bonded:
description: port bonded or not.
type: boolean
layer2:
description: convert port to layer 2. is false by default on
new devices. changes result in /ports/id/convert/layer-[2|3]
API calls
type: boolean
name:
description: name of the port e.g bond0,eth0 and eth1 for 2
NIC servers.
type: string
networks:
description: Network configurations for the port
items:
description: Network defines the network configuration for
a port.
properties:
addressFromPool:
description: |-
AddressFromPool is a reference of IPAddressPool that should be assigned to IPAddressClaim.
The machine's cloud-init metadata will be populated with IPAddresse fulfilled by an IPAM provider.
properties:
apiGroup:
description: |-
APIGroup is the group for the resource being referenced.
If APIGroup is not specified, the specified Kind must be in the core API group.
For any other third-party types, APIGroup is required.
type: string
kind:
description: Kind is the type of resource being referenced
type: string
name:
description: Name is the name of resource being referenced
type: string
required:
- kind
- name
type: object
x-kubernetes-map-type: atomic
addressType:
description: |-
AddressType is the type of address to assign to the machine. It can be either Internal or External.
kubebuilder:validation:Enum=Internal;External
type: string
netmask:
description: |-
Netmask is the netmask for the network.
eg: 255.255.255.248
type: string
routes:
description: List of Routes to be configured on the Packet
Machine
items:
description: RouteSpec defines the static route configuration
for a PacketMachine.
properties:
destination:
type: string
gateway:
type: string
required:
- destination
- gateway
type: object
type: array
vlanID:
description: VLAN ID for the VLAN created on the EM Console
type: string
vxlan:
description: VLANs for EM API to find by vxlan, project,
and metro match then attach to device. OS userdata template
will also configure this VLAN on the bond device
type: integer
type: object
type: array
required:
- name
- networks
type: object
type: array
providerID:
description: ProviderID is the unique identifier as specified by the
cloud provider.
Expand Down
Loading