Add CRD Controller for Network
[ovn4nfv-k8s-plugin.git] / pkg / apis / k8s / v1alpha1 / network_types.go
1 package v1alpha1
2
3 import (
4         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5 )
6
7 // EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
8 // NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.
9
10 // NetworkSpec defines the desired state of Network
11 // +k8s:openapi-gen=true
12 type NetworkSpec struct {
13         // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
14         // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
15         // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
16         CniType     string     `json:"cniType"`
17         Ipv4Subnets []IpSubnet `json:"ipv4Subnets"`
18         Ipv6Subnets []IpSubnet `json:"ipv6Subnets,omitempty"`
19         DNS         DnsSpec    `json:"dns,omitempty"`
20         Routes      []Route    `json:"routes,omitempty"`
21 }
22
23 type IpSubnet struct {
24         Name       string `json:"name"`
25         Subnet     string `json:"subnet"`
26         Gateway    string `json:"gateway,omitempty"`
27         ExcludeIps string `json:"excludeIps,omitempty"`
28 }
29
30 type Route struct {
31         Dst string `json:"dst"`
32         GW  string `json:"gw,omitempty"`
33 }
34
35 type DnsSpec struct {
36         Nameservers []string `json:"nameservers,omitempty"`
37         Domain      string   `json:"domain,omitempty"`
38         Search      []string `json:"search,omitempty"`
39         Options     []string `json:"options,omitempty"`
40 }
41
42 const (
43         //Created indicates the status of success
44         Created = "Created"
45         //CreateInternalError indicates create internal irrecoverable Error
46         CreateInternalError = "CreateInternalError"
47         //DeleteInternalError indicates delete internal irrecoverable Error
48         DeleteInternalError = "DeleteInternalError"
49 )
50
51 // NetworkStatus defines the observed state of Network
52 // +k8s:openapi-gen=true
53 type NetworkStatus struct {
54         // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
55         // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
56         // Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
57         State string `json:"state"` // Indicates if Network is in "created" state
58 }
59
60 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
61
62 // Network is the Schema for the networks API
63 // +k8s:openapi-gen=true
64 // +kubebuilder:subresource:status
65 type Network struct {
66         metav1.TypeMeta   `json:",inline"`
67         metav1.ObjectMeta `json:"metadata,omitempty"`
68
69         Spec   NetworkSpec   `json:"spec,omitempty"`
70         Status NetworkStatus `json:"status,omitempty"`
71 }
72
73 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
74
75 // NetworkList contains a list of Network
76 type NetworkList struct {
77         metav1.TypeMeta `json:",inline"`
78         metav1.ListMeta `json:"metadata,omitempty"`
79         Items           []Network `json:"items"`
80 }
81
82 func init() {
83         SchemeBuilder.Register(&Network{}, &NetworkList{})
84 }