-
Notifications
You must be signed in to change notification settings - Fork 228
/
nodenetworkconfig.go
90 lines (75 loc) · 3.51 KB
/
nodenetworkconfig.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package v1alpha
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Important: Run "make" to regenerate code after modifying this file
// +kubebuilder:object:root=true
// NodeNetworkConfig is the Schema for the nodenetworkconfigs API
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:resource:shortName=nnc
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
// +kubebuilder:printcolumn:name="Requested IPs",type=string,JSONPath=`.spec.requestedIPCount`
// +kubebuilder:printcolumn:name="Assigned IPs",type=string,JSONPath=`.status.assignedIPCount`
// +kubebuilder:printcolumn:name="Subnet",type=string,JSONPath=`.status.networkContainers[*].subnetName`
// +kubebuilder:printcolumn:name="Subnet CIDR",type=string,JSONPath=`.status.networkContainers[*].subnetAddressSpace`
// +kubebuilder:printcolumn:name="NC ID",type=string,JSONPath=`.status.networkContainers[*].id`
// +kubebuilder:printcolumn:name="NC Version",type=string,JSONPath=`.status.networkContainers[*].version`
type NodeNetworkConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodeNetworkConfigSpec `json:"spec,omitempty"`
Status NodeNetworkConfigStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// NodeNetworkConfigList contains a list of NetworkConfig
type NodeNetworkConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NodeNetworkConfig `json:"items"`
}
// NodeNetworkConfigSpec defines the desired state of NetworkConfig
type NodeNetworkConfigSpec struct {
RequestedIPCount int64 `json:"requestedIPCount,omitempty"`
IPsNotInUse []string `json:"ipsNotInUse,omitempty"`
}
// NodeNetworkConfigStatus defines the observed state of NetworkConfig
type NodeNetworkConfigStatus struct {
AssignedIPCount int `json:"assignedIPCount,omitempty"`
Scaler Scaler `json:"scaler,omitempty"`
Status Status `json:"status,omitempty"`
NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"`
}
// Scaler groups IP request params together
type Scaler struct {
BatchSize int64 `json:"batchSize,omitempty"`
ReleaseThresholdPercent int64 `json:"releaseThresholdPercent,omitempty"`
RequestThresholdPercent int64 `json:"requestThresholdPercent,omitempty"`
MaxIPCount int64 `json:"maxIPCount,omitempty"`
}
// Status indicates the NNC reconcile status
// +kubebuilder:validation:Enum=Updating;Update;Error
type Status string
const (
Updating Status = "Updating"
Updated Status = "Updated"
Error Status = "Error"
)
// NetworkContainer defines the structure of a Network Container as found in NetworkConfigStatus
type NetworkContainer struct {
ID string `json:"id,omitempty"`
PrimaryIP string `json:"primaryIP,omitempty"`
SubnetName string `json:"subnetName,omitempty"`
IPAssignments []IPAssignment `json:"ipAssignments,omitempty"`
DefaultGateway string `json:"defaultGateway,omitempty"`
SubnetAddressSpace string `json:"subnetAddressSpace,omitempty"`
Version int64 `json:"version,omitempty"`
}
// IPAssignment groups an IP address and Name. Name is a UUID set by the the IP address assigner.
type IPAssignment struct {
Name string `json:"name,omitempty"`
IP string `json:"ip,omitempty"`
}
func init() {
SchemeBuilder.Register(&NodeNetworkConfig{}, &NodeNetworkConfigList{})
}