Skip to content

Commit e84e301

Browse files
authored
Merge pull request #869 from feiskyer/nc-crd
Add NetworkContainer CRD definitions
2 parents d19e04f + f8fd8f5 commit e84e301

File tree

7 files changed

+342
-0
lines changed

7 files changed

+342
-0
lines changed

networkcontainer/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Dependencies for generator
2+
GOFILES = $(wildcard api/*/*.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])
11+
12+
.PHONY: manifests
13+
14+
manifests: controller-gen
15+
mkdir -p manifests
16+
controller-gen crd:trivialVersions=true paths="./..." output:crd:artifacts:config=manifests/

networkcontainer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# NetworkContainer CRDs
2+
3+
This package contains the CRD definitions for NetworkContainer, which would be consumed in CNS.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
// Package v1alpha1 contains API Schema definitions for the networking v1alpha1 API group
17+
// +kubebuilder:object:generate=true
18+
// +groupName=networking.azure.com
19+
package v1alpha1
20+
21+
import (
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
"sigs.k8s.io/controller-runtime/pkg/scheme"
24+
)
25+
26+
var (
27+
// GroupVersion is group version used to register these objects
28+
GroupVersion = schema.GroupVersion{Group: "networking.azure.com", Version: "v1alpha1"}
29+
30+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
32+
33+
// AddToScheme adds the types in this group-version to the given scheme.
34+
AddToScheme = SchemeBuilder.AddToScheme
35+
)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package v1alpha1
17+
18+
import (
19+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
)
21+
22+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
23+
// Important: Run "make" to regenerate code after modifying this file
24+
25+
// NetworkContainerSpec defines the desired state of NetworkContainer
26+
type NetworkContainerSpec struct {
27+
// UUID - network container UUID
28+
UUID string `json:"uuid,omitempty"`
29+
// Network - customer VNet GUID
30+
Network string `json:"network,omitempty"`
31+
// Subnet - customer subnet name
32+
Subnet string `json:"subnet,omitempty"`
33+
// Node - kubernetes node name
34+
Node string `json:"node,omitempty"`
35+
// InterfaceName - the interface name for consuming Pod
36+
InterfaceName string `json:"interfaceName,omitempty"`
37+
// ReservationID - reservation ID for allocating IP
38+
ReservationID string `json:"reservationID,omitempty"`
39+
}
40+
41+
// NetworkContainerStatus defines the observed state of NetworkContainer
42+
type NetworkContainerStatus struct {
43+
// The IP address
44+
IP string `json:"ip,omitempty"`
45+
// The gateway IP address
46+
Gateway string `json:"gateway,omitempty"`
47+
// The state of network container
48+
State string `json:"state,omitempty"`
49+
// The subnet CIDR
50+
IPSubnet string `json:"ipSubnet,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:subresource:status
55+
56+
// NetworkContainer is the Schema for the networkcontainers API
57+
type NetworkContainer struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ObjectMeta `json:"metadata,omitempty"`
60+
61+
Spec NetworkContainerSpec `json:"spec,omitempty"`
62+
Status NetworkContainerStatus `json:"status,omitempty"`
63+
}
64+
65+
// +kubebuilder:object:root=true
66+
67+
// NetworkContainerList contains a list of NetworkContainer
68+
type NetworkContainerList struct {
69+
metav1.TypeMeta `json:",inline"`
70+
metav1.ListMeta `json:"metadata,omitempty"`
71+
Items []NetworkContainer `json:"items"`
72+
}
73+
74+
func init() {
75+
SchemeBuilder.Register(&NetworkContainer{}, &NetworkContainerList{})
76+
}

networkcontainer/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
2+
---
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.3.0
8+
creationTimestamp: null
9+
name: networkcontainers.networking.azure.com
10+
spec:
11+
group: networking.azure.com
12+
names:
13+
kind: NetworkContainer
14+
listKind: NetworkContainerList
15+
plural: networkcontainers
16+
singular: networkcontainer
17+
scope: Namespaced
18+
subresources:
19+
status: {}
20+
validation:
21+
openAPIV3Schema:
22+
description: NetworkContainer is the Schema for the networkcontainers API
23+
properties:
24+
apiVersion:
25+
description: 'APIVersion defines the versioned schema of this representation
26+
of an object. Servers should convert recognized schemas to the latest
27+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28+
type: string
29+
kind:
30+
description: 'Kind is a string value representing the REST resource this
31+
object represents. Servers may infer this from the endpoint the client
32+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33+
type: string
34+
metadata:
35+
type: object
36+
spec:
37+
description: NetworkContainerSpec defines the desired state of NetworkContainer
38+
properties:
39+
interfaceName:
40+
description: InterfaceName - the interface name for consuming Pod
41+
type: string
42+
network:
43+
description: Network - customer VNet GUID
44+
type: string
45+
node:
46+
description: Node - kubernetes node name
47+
type: string
48+
reservationID:
49+
description: ReservationID - reservation ID for allocating IP
50+
type: string
51+
subnet:
52+
description: Subnet - customer subnet name
53+
type: string
54+
uuid:
55+
description: UUID - network container UUID
56+
type: string
57+
type: object
58+
status:
59+
description: NetworkContainerStatus defines the observed state of NetworkContainer
60+
properties:
61+
gateway:
62+
description: The gateway IP address
63+
type: string
64+
ip:
65+
description: The IP address
66+
type: string
67+
ipSubnet:
68+
description: The subnet CIDR
69+
type: string
70+
state:
71+
description: The state of network container
72+
type: string
73+
type: object
74+
type: object
75+
version: v1alpha1
76+
versions:
77+
- name: v1alpha1
78+
served: true
79+
storage: true
80+
status:
81+
acceptedNames:
82+
kind: ""
83+
plural: ""
84+
conditions: []
85+
storedVersions: []

0 commit comments

Comments
 (0)