aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/apis/k8s/v1alpha1/network_types.go
blob: a606dbbbdb8cb4e32c8e634120a81b83be6696a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.

// NetworkSpec defines the desired state of Network
// +k8s:openapi-gen=true
type NetworkSpec struct {
	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
	// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
	// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
	CniType     string     `json:"cniType"`
	Ipv4Subnets []IpSubnet `json:"ipv4Subnets"`
	Ipv6Subnets []IpSubnet `json:"ipv6Subnets,omitempty"`
	DNS         DnsSpec    `json:"dns,omitempty"`
	Routes      []Route    `json:"routes,omitempty"`
}

type IpSubnet struct {
	Name       string `json:"name"`
	Subnet     string `json:"subnet"`
	Gateway    string `json:"gateway,omitempty"`
	ExcludeIps string `json:"excludeIps,omitempty"`
}

type Route struct {
	Dst string `json:"dst"`
	GW  string `json:"gw,omitempty"`
}

type DnsSpec struct {
	Nameservers []string `json:"nameservers,omitempty"`
	Domain      string   `json:"domain,omitempty"`
	Search      []string `json:"search,omitempty"`
	Options     []string `json:"options,omitempty"`
}

const (
	//Created indicates the status of success
	Created = "Created"
	//CreateInternalError indicates create internal irrecoverable Error
	CreateInternalError = "CreateInternalError"
	//DeleteInternalError indicates delete internal irrecoverable Error
	DeleteInternalError = "DeleteInternalError"
)

// NetworkStatus defines the observed state of Network
// +k8s:openapi-gen=true
type NetworkStatus struct {
	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
	// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
	// Add custom validation using kubebuilder tags: https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
	State string `json:"state"` // Indicates if Network is in "created" state
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Network is the Schema for the networks API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
type Network struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   NetworkSpec   `json:"spec,omitempty"`
	Status NetworkStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NetworkList contains a list of Network
type NetworkList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Network `json:"items"`
}

func init() {
	SchemeBuilder.Register(&Network{}, &NetworkList{})
}