Skip to content

Commit 9e15490

Browse files
authored
NetworkConfig CRD defintions (#570)
* NetworkConfig CRD defintions * v1 to v1alpha, release/request thresholds, naming * networkconfig to nodnetworkconfig, renaming vars * subnet to subnetID, added comment for netmask * removed counts
1 parent 37eed02 commit 9e15490

File tree

7 files changed

+509
-3
lines changed

7 files changed

+509
-3
lines changed

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ require (
2626
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e
2727
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
2828
google.golang.org/appengine v1.6.5 // indirect
29-
k8s.io/api v0.18.0
30-
k8s.io/apimachinery v0.18.0
31-
k8s.io/client-go v0.18.0
29+
k8s.io/api v0.18.2
30+
k8s.io/apimachinery v0.18.2
31+
k8s.io/client-go v0.18.2
32+
sigs.k8s.io/controller-runtime v0.6.0
3233
)

go.sum

Lines changed: 203 additions & 0 deletions
Large diffs are not rendered by default.

nodenetworkconfig/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dependencies for generator
2+
GOFILES = $(wildcard api/v1/*.go)
3+
4+
generate: $(GOFILES) controller-gen
5+
controller-gen object:headerFile="boilerplate.go.txt" paths="./..."
6+
7+
.PHONY: controller-gen
8+
9+
controller-gen:
10+
@(cd && GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected])
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha contains API Schema definitions for the acn v1alpha API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=acn.azure.com
20+
package v1alpha
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "acn.azure.com", Version: "v1alpha"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// Important: Run "make" to regenerate code after modifying this file
24+
25+
// +kubebuilder:object:root=true
26+
27+
// NodeNetworkConfig is the Schema for the nodenetworkconfigs API
28+
// +kubebuilder:resource:scope=Cluster
29+
// +kubebuilder:subresource:status
30+
type NodeNetworkConfig struct {
31+
metav1.TypeMeta `json:",inline"`
32+
metav1.ObjectMeta `json:"metadata,omitempty"`
33+
34+
Spec NodeNetworkConfigSpec `json:"spec,omitempty"`
35+
Status NodeNetworkConfigStatus `json:"status,omitempty"`
36+
}
37+
38+
// +kubebuilder:object:root=true
39+
40+
// NodeNetworkConfigList contains a list of NetworkConfig
41+
type NodeNetworkConfigList struct {
42+
metav1.TypeMeta `json:",inline"`
43+
metav1.ListMeta `json:"metadata,omitempty"`
44+
Items []NodeNetworkConfig `json:"items"`
45+
}
46+
47+
// NodeNetworkConfigSpec defines the desired state of NetworkConfig
48+
type NodeNetworkConfigSpec struct {
49+
RequestedIPCount int64 `json:"requestedIPCount,omitempty"`
50+
IPsNotInUse []string `json:"iPsNotInUse,omitempty"`
51+
}
52+
53+
// NodeNetworkConfigStatus defines the observed state of NetworkConfig
54+
type NodeNetworkConfigStatus struct {
55+
BatchSize int64 `json:"batchSize,omitempty"`
56+
ReleaseThresholdPercent int64 `json:"releaseThresholdPercent,omitempty"`
57+
RequestThresholdPercent int64 `json:"requestThresholdPercent,omitempty"`
58+
NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"`
59+
}
60+
61+
// NetworkContainer defines the structure of a Network Container as found in NetworkConfigStatus
62+
type NetworkContainer struct {
63+
ID string `json:"id,omitempty"`
64+
PrimaryIP string `json:"primaryIP,omitempty"`
65+
SubnetID string `json:"subnetID,omitempty"`
66+
IPAssignments []IPAssignment `json:"iPAssignments,omitempty"`
67+
DefaultGateway string `json:"defaultGateway,omitempty"`
68+
// Netmask for the subnet represented by this NC's SubnetID
69+
Netmask string `json:"netmask,omitempty"`
70+
}
71+
72+
// IPAssignment groups an IP address and Name. Name is a UUID set by the the IP address assigner.
73+
type IPAssignment struct {
74+
Name string `json:"name,omitempty"`
75+
IP string `json:"iP,omitempty"`
76+
}
77+
78+
func init() {
79+
SchemeBuilder.Register(&NodeNetworkConfig{}, &NodeNetworkConfigList{})
80+
}

nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go

Lines changed: 161 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/

0 commit comments

Comments
 (0)