Skip to content

Commit 4073c74

Browse files
authored
feat: update CRDs to accomodate multiple pod nics (#2717)
* feat: update CRDs to accomodate multiple pod nics * fix: device type in mtpnc status, rename device types * fix: change podnetworks to podnetworkconfigs
1 parent 72d50cf commit 4073c74

7 files changed

+203
-54
lines changed

crd/multitenancy/api/v1alpha1/multitenantpodnetworkconfig.go

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ import (
1919
// +kubebuilder:printcolumn:name="PodNetworkInstance",type=string,JSONPath=`.spec.podNetworkInstance`
2020
// +kubebuilder:printcolumn:name="PodNetwork",type=string,JSONPath=`.spec.podNetwork`
2121
// +kubebuilder:printcolumn:name="PodName",type=string,JSONPath=`.spec.podName`
22-
// +kubebuilder:printcolumn:name="NCID",type=string,JSONPath=`.status.ncID`
23-
// +kubebuilder:printcolumn:name="PrimaryIP",type=string,JSONPath=`.status.primaryIP`
24-
// +kubebuilder:printcolumn:name="MacAddress",type=string,JSONPath=`.status.macAddress`
25-
// +kubebuilder:printcolumn:name="GatewayIP",type=string,JSONPath=`.status.gatewayIP`
2622
type MultitenantPodNetworkConfig struct {
2723
metav1.TypeMeta `json:",inline"`
2824
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -51,16 +47,38 @@ type MultitenantPodNetworkConfigSpec struct {
5147
PodName string `json:"podName,omitempty"`
5248
}
5349

50+
type InterfaceInfo struct {
51+
// NCID is the network container id
52+
NCID string `json:"ncID,omitempty"`
53+
// PrimaryIP is the ip allocated to the network container
54+
// +kubebuilder:validation:Optional
55+
PrimaryIP string `json:"primaryIP,omitempty"`
56+
// MacAddress is the MAC Address of the VM's NIC which this network container was created for
57+
MacAddress string `json:"macAddress,omitempty"`
58+
// GatewayIP is the gateway ip of the injected subnet
59+
// +kubebuilder:validation:Optional
60+
GatewayIP string `json:"gatewayIP,omitempty"`
61+
// DeviceType is the device type that this NC was created for
62+
DeviceType DeviceType `json:"deviceType,omitempty"`
63+
}
64+
5465
// MultitenantPodNetworkConfigStatus defines the observed state of PodNetworkConfig
5566
type MultitenantPodNetworkConfigStatus struct {
56-
// network container id
67+
// Deprecated - use InterfaceInfos
68+
// +kubebuilder:validation:Optional
5769
NCID string `json:"ncID,omitempty"`
58-
// ip allocated to the network container
70+
// Deprecated - use InterfaceInfos
71+
// +kubebuilder:validation:Optional
5972
PrimaryIP string `json:"primaryIP,omitempty"`
60-
// maps to the NIC to be injected for the network container
73+
// Deprecated - use InterfaceInfos
74+
// +kubebuilder:validation:Optional
6175
MacAddress string `json:"macAddress,omitempty"`
62-
// Gateway IP
76+
// Deprecated - use InterfaceInfos
77+
// +kubebuilder:validation:Optional
6378
GatewayIP string `json:"gatewayIP,omitempty"`
79+
// InterfaceInfos describes all of the network container goal state for this Pod
80+
// +kubebuilder:validation:Optional
81+
InterfaceInfos []InterfaceInfo `json:"interfaceInfos,omitempty"`
6482
}
6583

6684
func init() {

crd/multitenancy/api/v1alpha1/podnetwork.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
// +kubebuilder:subresource:status
1717
// +kubebuilder:printcolumn:name="Status",type=string,priority=1,JSONPath=`.status.status`
1818
// +kubebuilder:printcolumn:name="Address Prefixes",type=string,priority=1,JSONPath=`.status.addressPrefixes`
19-
// +kubebuilder:printcolumn:name="Network",type=string,priority=1,JSONPath=`.spec.vnetGUID`
19+
// +kubebuilder:printcolumn:name="Network",type=string,priority=1,JSONPath=`.spec.networkID`
2020
// +kubebuilder:printcolumn:name="Subnet",type=string,priority=1,JSONPath=`.spec.subnetResourceID`
2121
// +kubebuilder:printcolumn:name="SubnetGUID",type=string,priority=1,JSONPath=`.spec.subnetGUID`
22+
// +kubebuilder:printcolumn:name="DeviceType",type=string,priority=1,JSONPath=`.spec.subnetGUID`
2223
type PodNetwork struct {
2324
metav1.TypeMeta `json:",inline"`
2425
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -36,15 +37,31 @@ type PodNetworkList struct {
3637
Items []PodNetwork `json:"items"`
3738
}
3839

40+
// +kubebuilder:validation:Enum=acn.azure.com/vnet-nic;acn.azure.com/infiniband-nic
41+
type DeviceType string
42+
43+
const (
44+
DeviceTypeVnetNIC DeviceType = "acn.azure.com/vnet-nic"
45+
DeviceTypeInfiniBandNIC DeviceType = "acn.azure.com/infiniband-nic"
46+
)
47+
3948
// PodNetworkSpec defines the desired state of PodNetwork
4049
type PodNetworkSpec struct {
50+
// NetworkID is the identifier for the network, e.g. vnet guid or IB network ID
4151
// +kubebuilder:validation:Optional
42-
// customer vnet guid
43-
VnetGUID string `json:"vnetGUID,omitempty"`
52+
NetworkID string `json:"networkID,omitempty"`
53+
// DeviceType is the device type that is required by this network
54+
// +kubebuilder:validation:Optional
55+
DeviceType DeviceType `json:"deviceType,omitempty"`
4456
// customer subnet id
57+
// +kubebuilder:validation:Optional
4558
SubnetResourceID string `json:"subnetResourceID,omitempty"`
4659
// customer subnet guid
60+
// +kubebuilder:validation:Optional
4761
SubnetGUID string `json:"subnetGUID,omitempty"`
62+
// Deprecated - Use NetworkID
63+
// +kubebuilder:validation:Optional
64+
VnetGUID string `json:"vnetGUID,omitempty"`
4865
}
4966

5067
// Status indicates the status of PN

crd/multitenancy/api/v1alpha1/podnetworkinstance.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import (
1616
// +kubebuilder:subresource:status
1717
// +kubebuilder:metadata:labels=managed=
1818
// +kubebuilder:metadata:labels=owner=
19-
// +kubebuilder:printcolumn:name="Pod IPs",type=string,priority=1,JSONPath=`.status.podIPAddresses`
20-
// +kubebuilder:printcolumn:name="PodNetwork",type=string,priority=1,JSONPath=`.spec.podNetwork`
21-
// +kubebuilder:printcolumn:name="PodIPReservationSize",type=string,priority=1,JSONPath=`.spec.podIPReservationSize`
19+
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
20+
// +kubebuilder:printcolumn:name="PodNetworks",priority=1,type=string,JSONPath=`.spec.podNetworks`
2221
type PodNetworkInstance struct {
2322
metav1.TypeMeta `json:",inline"`
2423
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -36,19 +35,35 @@ type PodNetworkInstanceList struct {
3635
Items []PodNetworkInstance `json:"items"`
3736
}
3837

38+
// PodNetworkConfig describes a template for how to attach a PodNetwork to a Pod
39+
type PodNetworkConfig struct {
40+
// PodNetwork is the name of a PodNetwork resource
41+
PodNetwork string `json:"podNetwork"`
42+
// PodIPReservationSize is the number of IP address to statically reserve
43+
// +kubebuilder:default=0
44+
PodIPReservationSize int `json:"podIPReservationSize,omitempty"`
45+
}
46+
3947
// PodNetworkInstanceSpec defines the desired state of PodNetworkInstance
4048
type PodNetworkInstanceSpec struct {
41-
// pod network resource object name
42-
PodNetwork string `json:"podnetwork"`
43-
// number of backend IP address to reserve for running pods
49+
// Deprecated - use PodNetworks
50+
// +kubebuilder:validation:Optional
51+
PodNetwork string `json:"podnetwork,omitempty"`
52+
// Deprecated - use PodNetworks
4453
// +kubebuilder:default=0
45-
PodIPReservationSize int `json:"podIPReservationSize"`
54+
PodIPReservationSize int `json:"podIPReservationSize,omitempty"`
55+
// PodNetworkConfigs describes each PodNetwork to attach to a single Pod
56+
// optional for now in case orchestrator uses the deprecated fields
57+
// +kubebuilder:validation:Optional
58+
PodNetworkConfigs []PodNetworkConfig `json:"podNetworkConfigs"`
4659
}
4760

4861
// PodNetworkInstanceStatus defines the observed state of PodNetworkInstance
4962
type PodNetworkInstanceStatus struct {
50-
PodIPAddresses []string `json:"podIPAddresses,omitempty"`
51-
Status PNIStatus `json:"status,omitempty"`
63+
// +kubebuilder:validation:Optional
64+
PodIPAddresses []string `json:"podIPAddresses,omitempty"`
65+
Status PNIStatus `json:"status,omitempty"`
66+
PodNetworkStatuses map[string]PNIStatus `json:"podNetworkStatuses,omitempty"`
5267
}
5368

5469
// PNIStatus indicates the status of PNI

crd/multitenancy/api/v1alpha1/zz_generated.deepcopy.go

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

crd/multitenancy/manifests/multitenancy.acn.azure.com_multitenantpodnetworkconfigs.yaml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ spec:
2929
- jsonPath: .spec.podName
3030
name: PodName
3131
type: string
32-
- jsonPath: .status.ncID
33-
name: NCID
34-
type: string
35-
- jsonPath: .status.primaryIP
36-
name: PrimaryIP
37-
type: string
38-
- jsonPath: .status.macAddress
39-
name: MacAddress
40-
type: string
41-
- jsonPath: .status.gatewayIP
42-
name: GatewayIP
43-
type: string
4432
name: v1alpha1
4533
schema:
4634
openAPIV3Schema:
@@ -80,16 +68,43 @@ spec:
8068
of PodNetworkConfig
8169
properties:
8270
gatewayIP:
83-
description: Gateway IP
71+
description: Deprecated - use InterfaceInfos
8472
type: string
73+
interfaceInfos:
74+
description: InterfaceInfos describes all of the network container
75+
goal state for this Pod
76+
items:
77+
properties:
78+
deviceType:
79+
description: DeviceType is the device type that this NC was
80+
created for
81+
enum:
82+
- acn.azure.com/vnet-nic
83+
- acn.azure.com/infiniband-nic
84+
type: string
85+
gatewayIP:
86+
description: GatewayIP is the gateway ip of the injected subnet
87+
type: string
88+
macAddress:
89+
description: MacAddress is the MAC Address of the VM's NIC which
90+
this network container was created for
91+
type: string
92+
ncID:
93+
description: NCID is the network container id
94+
type: string
95+
primaryIP:
96+
description: PrimaryIP is the ip allocated to the network container
97+
type: string
98+
type: object
99+
type: array
85100
macAddress:
86-
description: maps to the NIC to be injected for the network container
101+
description: Deprecated - use InterfaceInfos
87102
type: string
88103
ncID:
89-
description: network container id
104+
description: Deprecated - use InterfaceInfos
90105
type: string
91106
primaryIP:
92-
description: ip allocated to the network container
107+
description: Deprecated - use InterfaceInfos
93108
type: string
94109
type: object
95110
type: object

crd/multitenancy/manifests/multitenancy.acn.azure.com_podnetworkinstances.yaml

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@ spec:
2020
scope: Namespaced
2121
versions:
2222
- additionalPrinterColumns:
23-
- jsonPath: .status.podIPAddresses
24-
name: Pod IPs
25-
priority: 1
26-
type: string
27-
- jsonPath: .spec.podNetwork
28-
name: PodNetwork
29-
priority: 1
23+
- jsonPath: .status.status
24+
name: Status
3025
type: string
31-
- jsonPath: .spec.podIPReservationSize
32-
name: PodIPReservationSize
26+
- jsonPath: .spec.podNetworks
27+
name: PodNetworks
3328
priority: 1
3429
type: string
3530
name: v1alpha1
@@ -55,14 +50,31 @@ spec:
5550
properties:
5651
podIPReservationSize:
5752
default: 0
58-
description: number of backend IP address to reserve for running pods
53+
description: Deprecated - use PodNetworks
5954
type: integer
55+
podNetworkConfigs:
56+
description: PodNetworkConfigs describes each PodNetwork to attach
57+
to a single Pod optional for now in case orchestrator uses the deprecated
58+
fields
59+
items:
60+
description: PodNetworkConfig describes a template for how to attach
61+
a PodNetwork to a Pod
62+
properties:
63+
podIPReservationSize:
64+
default: 0
65+
description: PodIPReservationSize is the number of IP address
66+
to statically reserve
67+
type: integer
68+
podNetwork:
69+
description: PodNetwork is the name of a PodNetwork resource
70+
type: string
71+
required:
72+
- podNetwork
73+
type: object
74+
type: array
6075
podnetwork:
61-
description: pod network resource object name
76+
description: Deprecated - use PodNetworks
6277
type: string
63-
required:
64-
- podIPReservationSize
65-
- podnetwork
6678
type: object
6779
status:
6880
description: PodNetworkInstanceStatus defines the observed state of PodNetworkInstance
@@ -71,6 +83,16 @@ spec:
7183
items:
7284
type: string
7385
type: array
86+
podNetworkStatuses:
87+
additionalProperties:
88+
description: PNIStatus indicates the status of PNI
89+
enum:
90+
- Ready
91+
- CreateReservationSetError
92+
- PodNetworkNotReady
93+
- InsufficientIPAddressesOnSubnet
94+
type: string
95+
type: object
7496
status:
7597
description: PNIStatus indicates the status of PNI
7698
enum:

0 commit comments

Comments
 (0)