Skip to content
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
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ require (
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
google.golang.org/appengine v1.6.5 // indirect
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/client-go v0.18.0
k8s.io/api v0.18.2
k8s.io/apimachinery v0.18.2
k8s.io/client-go v0.18.2
sigs.k8s.io/controller-runtime v0.6.0
)
203 changes: 203 additions & 0 deletions go.sum

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions nodenetworkconfig/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dependencies for generator
GOFILES = $(wildcard api/v1/*.go)

generate: $(GOFILES) controller-gen
controller-gen object:headerFile="boilerplate.go.txt" paths="./..."

.PHONY: controller-gen

controller-gen:
@(cd && GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0)
36 changes: 36 additions & 0 deletions nodenetworkconfig/api/v1alpha/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha contains API Schema definitions for the acn v1alpha API group
// +kubebuilder:object:generate=true
// +groupName=acn.azure.com
package v1alpha

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "acn.azure.com", Version: "v1alpha"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
80 changes: 80 additions & 0 deletions nodenetworkconfig/api/v1alpha/nodenetworkconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

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=Cluster
// +kubebuilder:subresource:status
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 {
BatchSize int64 `json:"batchSize,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these batchSize, Release and Request threshold in some other struct for code readiblity? Also, In case we need to extend it, it wont change the main struct

ReleaseThresholdPercent int64 `json:"releaseThresholdPercent,omitempty"`
RequestThresholdPercent int64 `json:"requestThresholdPercent,omitempty"`
NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give an example if why we'd have multiple network containers on a single node? i

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would a single node have different different primary ips and different subnets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we are planning one NC per node and thus one primary IP and one subnet. However, this imposes a limit on the number of IPs, so we want to support multiple NCs in the future. It will be easier to add multi-NC support when we can support it on the other tooling if the CRD already supports it.

}

// 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"`
SubnetID string `json:"subnetID,omitempty"`
IPAssignments []IPAssignment `json:"iPAssignments,omitempty"`
DefaultGateway string `json:"defaultGateway,omitempty"`
// Netmask for the subnet represented by this NC's SubnetID
Netmask string `json:"netmask,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{})
}
161 changes: 161 additions & 0 deletions nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions nodenetworkconfig/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/