From 4ca552c3e0b2a722f6b69fc3712011209c8d91f4 Mon Sep 17 00:00:00 2001 From: Matthew Long <61910737+thatmattlong@users.noreply.github.com> Date: Tue, 23 Jun 2020 16:42:00 -0700 Subject: [PATCH 1/2] Move scaling items into scaler, change scope to namespaced --- nodenetworkconfig/Makefile | 8 +- .../api/v1alpha/nodenetworkconfig.go | 15 ++- .../api/v1alpha/zz_generated.deepcopy.go | 16 +++ .../acn.azure.com_nodenetworkconfigs.yaml | 104 ++++++++++++++++++ 4 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml diff --git a/nodenetworkconfig/Makefile b/nodenetworkconfig/Makefile index c7487b0d77..cae9e12aae 100644 --- a/nodenetworkconfig/Makefile +++ b/nodenetworkconfig/Makefile @@ -7,4 +7,10 @@ generate: $(GOFILES) controller-gen .PHONY: controller-gen controller-gen: - @(cd && GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0) \ No newline at end of file + @(cd && GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0) + +.PHONY: manifests + +manifests: controller-gen + mkdir -p manifests + controller-gen crd:trivialVersions=true paths="./..." output:crd:artifacts:config=manifests/ \ No newline at end of file diff --git a/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go b/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go index 8b45b50f80..d381ae1125 100644 --- a/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go +++ b/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go @@ -25,7 +25,7 @@ import ( // +kubebuilder:object:root=true // NodeNetworkConfig is the Schema for the nodenetworkconfigs API -// +kubebuilder:resource:scope=Cluster +// +kubebuilder:resource:scope=Namespaced // +kubebuilder:subresource:status type NodeNetworkConfig struct { metav1.TypeMeta `json:",inline"` @@ -52,10 +52,15 @@ type NodeNetworkConfigSpec struct { // NodeNetworkConfigStatus defines the observed state of NetworkConfig type NodeNetworkConfigStatus struct { - BatchSize int64 `json:"batchSize,omitempty"` - ReleaseThresholdPercent int64 `json:"releaseThresholdPercent,omitempty"` - RequestThresholdPercent int64 `json:"requestThresholdPercent,omitempty"` - NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"` + Scaler Scaler `json:"scaler,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"` } // NetworkContainer defines the structure of a Network Container as found in NetworkConfigStatus diff --git a/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go b/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go index 34c23c9ffa..8e13e4a11d 100644 --- a/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go +++ b/nodenetworkconfig/api/v1alpha/zz_generated.deepcopy.go @@ -141,6 +141,7 @@ func (in *NodeNetworkConfigSpec) DeepCopy() *NodeNetworkConfigSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeNetworkConfigStatus) DeepCopyInto(out *NodeNetworkConfigStatus) { *out = *in + out.Scaler = in.Scaler if in.NetworkContainers != nil { in, out := &in.NetworkContainers, &out.NetworkContainers *out = make([]NetworkContainer, len(*in)) @@ -159,3 +160,18 @@ func (in *NodeNetworkConfigStatus) DeepCopy() *NodeNetworkConfigStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Scaler) DeepCopyInto(out *Scaler) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scaler. +func (in *Scaler) DeepCopy() *Scaler { + if in == nil { + return nil + } + out := new(Scaler) + in.DeepCopyInto(out) + return out +} diff --git a/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml b/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml new file mode 100644 index 0000000000..61624ed58b --- /dev/null +++ b/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml @@ -0,0 +1,104 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: nodenetworkconfigs.acn.azure.com +spec: + group: acn.azure.com + names: + kind: NodeNetworkConfig + listKind: NodeNetworkConfigList + plural: nodenetworkconfigs + singular: nodenetworkconfig + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: NodeNetworkConfig is the Schema for the nodenetworkconfigs API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: NodeNetworkConfigSpec defines the desired state of NetworkConfig + properties: + iPsNotInUse: + items: + type: string + type: array + requestedIPCount: + format: int64 + type: integer + type: object + status: + description: NodeNetworkConfigStatus defines the observed state of NetworkConfig + properties: + networkContainers: + items: + description: NetworkContainer defines the structure of a Network Container + as found in NetworkConfigStatus + properties: + defaultGateway: + type: string + iPAssignments: + items: + description: IPAssignment groups an IP address and Name. Name + is a UUID set by the the IP address assigner. + properties: + iP: + type: string + name: + type: string + type: object + type: array + id: + type: string + netmask: + description: Netmask for the subnet represented by this NC's SubnetID + type: string + primaryIP: + type: string + subnetID: + type: string + type: object + type: array + scaler: + description: Scaler groups IP request params together + properties: + batchSize: + format: int64 + type: integer + releaseThresholdPercent: + format: int64 + type: integer + requestThresholdPercent: + format: int64 + type: integer + type: object + type: object + type: object + version: v1alpha + versions: + - name: v1alpha + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] From 165ed7c06db7fd9f4840fdb133ef3c61e3907b72 Mon Sep 17 00:00:00 2001 From: Matthew Long <61910737+thatmattlong@users.noreply.github.com> Date: Wed, 24 Jun 2020 08:55:04 -0700 Subject: [PATCH 2/2] added short name nnc --- nodenetworkconfig/api/v1alpha/nodenetworkconfig.go | 1 + .../manifests/acn.azure.com_nodenetworkconfigs.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go b/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go index d381ae1125..c46a645e47 100644 --- a/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go +++ b/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go @@ -26,6 +26,7 @@ import ( // NodeNetworkConfig is the Schema for the nodenetworkconfigs API // +kubebuilder:resource:scope=Namespaced +// +kubebuilder:resource:shortName=nnc // +kubebuilder:subresource:status type NodeNetworkConfig struct { metav1.TypeMeta `json:",inline"` diff --git a/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml b/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml index 61624ed58b..879b61e0c1 100644 --- a/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml +++ b/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml @@ -13,6 +13,8 @@ spec: kind: NodeNetworkConfig listKind: NodeNetworkConfigList plural: nodenetworkconfigs + shortNames: + - nnc singular: nodenetworkconfig scope: Namespaced subresources: