diff --git a/networkcontainer/Makefile b/networkcontainer/Makefile new file mode 100644 index 0000000000..e2fad08ad5 --- /dev/null +++ b/networkcontainer/Makefile @@ -0,0 +1,16 @@ +# Dependencies for generator +GOFILES = $(wildcard api/*/*.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) + +.PHONY: manifests + +manifests: controller-gen + mkdir -p manifests + controller-gen crd:trivialVersions=true paths="./..." output:crd:artifacts:config=manifests/ diff --git a/networkcontainer/README.md b/networkcontainer/README.md new file mode 100644 index 0000000000..178d5a0a4a --- /dev/null +++ b/networkcontainer/README.md @@ -0,0 +1,3 @@ +# NetworkContainer CRDs + +This package contains the CRD definitions for NetworkContainer, which would be consumed in CNS. diff --git a/networkcontainer/api/v1alpha1/groupversion_info.go b/networkcontainer/api/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..05a6a3c687 --- /dev/null +++ b/networkcontainer/api/v1alpha1/groupversion_info.go @@ -0,0 +1,35 @@ +/* + +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 v1alpha1 contains API Schema definitions for the networking v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=networking.azure.com +package v1alpha1 + +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: "networking.azure.com", Version: "v1alpha1"} + + // 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 +) diff --git a/networkcontainer/api/v1alpha1/networkcontainer_types.go b/networkcontainer/api/v1alpha1/networkcontainer_types.go new file mode 100644 index 0000000000..c94c47d3dd --- /dev/null +++ b/networkcontainer/api/v1alpha1/networkcontainer_types.go @@ -0,0 +1,76 @@ +/* + +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. +// Important: Run "make" to regenerate code after modifying this file + +// NetworkContainerSpec defines the desired state of NetworkContainer +type NetworkContainerSpec struct { + // UUID - network container UUID + UUID string `json:"uuid,omitempty"` + // Network - customer VNet GUID + Network string `json:"network,omitempty"` + // Subnet - customer subnet name + Subnet string `json:"subnet,omitempty"` + // Node - kubernetes node name + Node string `json:"node,omitempty"` + // InterfaceName - the interface name for consuming Pod + InterfaceName string `json:"interfaceName,omitempty"` + // ReservationID - reservation ID for allocating IP + ReservationID string `json:"reservationID,omitempty"` +} + +// NetworkContainerStatus defines the observed state of NetworkContainer +type NetworkContainerStatus struct { + // The IP address + IP string `json:"ip,omitempty"` + // The gateway IP address + Gateway string `json:"gateway,omitempty"` + // The state of network container + State string `json:"state,omitempty"` + // The subnet CIDR + IPSubnet string `json:"ipSubnet,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// NetworkContainer is the Schema for the networkcontainers API +type NetworkContainer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NetworkContainerSpec `json:"spec,omitempty"` + Status NetworkContainerStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// NetworkContainerList contains a list of NetworkContainer +type NetworkContainerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NetworkContainer `json:"items"` +} + +func init() { + SchemeBuilder.Register(&NetworkContainer{}, &NetworkContainerList{}) +} diff --git a/networkcontainer/api/v1alpha1/zz_generated.deepcopy.go b/networkcontainer/api/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..45ba222baf --- /dev/null +++ b/networkcontainer/api/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,113 @@ +// +build !ignore_autogenerated + +/* + +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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkContainer) DeepCopyInto(out *NetworkContainer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkContainer. +func (in *NetworkContainer) DeepCopy() *NetworkContainer { + if in == nil { + return nil + } + out := new(NetworkContainer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkContainer) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkContainerList) DeepCopyInto(out *NetworkContainerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NetworkContainer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkContainerList. +func (in *NetworkContainerList) DeepCopy() *NetworkContainerList { + if in == nil { + return nil + } + out := new(NetworkContainerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NetworkContainerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkContainerSpec) DeepCopyInto(out *NetworkContainerSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkContainerSpec. +func (in *NetworkContainerSpec) DeepCopy() *NetworkContainerSpec { + if in == nil { + return nil + } + out := new(NetworkContainerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkContainerStatus) DeepCopyInto(out *NetworkContainerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkContainerStatus. +func (in *NetworkContainerStatus) DeepCopy() *NetworkContainerStatus { + if in == nil { + return nil + } + out := new(NetworkContainerStatus) + in.DeepCopyInto(out) + return out +} diff --git a/networkcontainer/boilerplate.go.txt b/networkcontainer/boilerplate.go.txt new file mode 100644 index 0000000000..b92001fb4e --- /dev/null +++ b/networkcontainer/boilerplate.go.txt @@ -0,0 +1,14 @@ +/* + +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. +*/ \ No newline at end of file diff --git a/networkcontainer/manifests/networking.azure.com_networkcontainers.yaml b/networkcontainer/manifests/networking.azure.com_networkcontainers.yaml new file mode 100644 index 0000000000..18f0fdc495 --- /dev/null +++ b/networkcontainer/manifests/networking.azure.com_networkcontainers.yaml @@ -0,0 +1,85 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: networkcontainers.networking.azure.com +spec: + group: networking.azure.com + names: + kind: NetworkContainer + listKind: NetworkContainerList + plural: networkcontainers + singular: networkcontainer + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: NetworkContainer is the Schema for the networkcontainers 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: NetworkContainerSpec defines the desired state of NetworkContainer + properties: + interfaceName: + description: InterfaceName - the interface name for consuming Pod + type: string + network: + description: Network - customer VNet GUID + type: string + node: + description: Node - kubernetes node name + type: string + reservationID: + description: ReservationID - reservation ID for allocating IP + type: string + subnet: + description: Subnet - customer subnet name + type: string + uuid: + description: UUID - network container UUID + type: string + type: object + status: + description: NetworkContainerStatus defines the observed state of NetworkContainer + properties: + gateway: + description: The gateway IP address + type: string + ip: + description: The IP address + type: string + ipSubnet: + description: The subnet CIDR + type: string + state: + description: The state of network container + type: string + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: []