Skip to content

Commit 0093287

Browse files
authored
Release 1.3.0 (#62)
New Features: - Added Nat CRD Bug Fixes: - Memory leak caused by the EventBroadcaster
1 parent 0c9ad45 commit 0093287

35 files changed

+2126
-13
lines changed

PROJECT

+18
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,22 @@ resources:
187187
kind: LinkMeta
188188
path: github.com/netrisai/netris-operator/api/v1alpha1
189189
version: v1alpha1
190+
- api:
191+
crdVersion: v1
192+
namespaced: true
193+
controller: true
194+
domain: netris.ai
195+
group: k8s
196+
kind: Nat
197+
path: github.com/netrisai/netris-operator/api/v1alpha1
198+
version: v1alpha1
199+
- api:
200+
crdVersion: v1
201+
namespaced: true
202+
controller: true
203+
domain: netris.ai
204+
group: k8s
205+
kind: NatMeta
206+
path: github.com/netrisai/netris-operator/api/v1alpha1
207+
version: v1alpha1
190208
version: "3"

api/v1alpha1/nat_types.go

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
Copyright 2021. Netris, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// NatSpec defines the desired state of Nat
27+
type NatSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
31+
Comment string `json:"comment,omitempty"`
32+
33+
// +kubebuilder:validation:Enum=enabled;disabled
34+
State string `json:"state,omitempty"`
35+
Site string `json:"site"`
36+
37+
// +kubebuilder:validation:Enum=dnat;snat;accept_snat;masquerade
38+
Action string `json:"action"`
39+
40+
// +kubebuilder:validation:Enum=all;tcp;udp;icmp
41+
Protocol string `json:"protocol"`
42+
43+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
44+
SrcAddress string `json:"srcAddress"`
45+
46+
SrcPort string `json:"srcPort,omitempty"`
47+
48+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
49+
DstAddress string `json:"dstAddress"`
50+
51+
DstPort string `json:"dstPort,omitempty"`
52+
53+
// +kubebuilder:validation:Pattern=`^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$`
54+
SnatToIP string `json:"snatToIp,omitempty"`
55+
56+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9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)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
57+
SnatToPool string `json:"snatToPool,omitempty"`
58+
59+
// +kubebuilder:validation:Pattern=`(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[12]\d|3[0-2]))?$)|(^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(\/([1-9]|[1-5][0-9]|6[0-4]))?$)`
60+
DnatToIP string `json:"dnatToIp,omitempty"`
61+
62+
// +kubebuilder:validation:Minimum=1
63+
// +kubebuilder:validation:Maximum=65535
64+
DnatToPort int `json:"dnatToPort,omitempty"`
65+
}
66+
67+
// NatStatus defines the observed state of Nat
68+
type NatStatus struct {
69+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
70+
// Important: Run "make" to regenerate code after modifying this file
71+
Status string `json:"status,omitempty"`
72+
Message string `json:"message,omitempty"`
73+
}
74+
75+
//+kubebuilder:object:root=true
76+
//+kubebuilder:subresource:status
77+
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.spec.state`
78+
// +kubebuilder:printcolumn:name="Site",type=string,JSONPath=`.spec.site`
79+
// +kubebuilder:printcolumn:name="Action",type=string,JSONPath=`.spec.action`
80+
// +kubebuilder:printcolumn:name="Protocol",type=string,JSONPath=`.spec.protocol`
81+
// +kubebuilder:printcolumn:name="SrcAddress",type=string,JSONPath=`.spec.srcAddress`
82+
// +kubebuilder:printcolumn:name="SrcPort",type=integer,JSONPath=`.spec.srcPort`
83+
// +kubebuilder:printcolumn:name="DstAddress",type=string,JSONPath=`.spec.dstAddress`
84+
// +kubebuilder:printcolumn:name="DstPort",type=integer,JSONPath=`.spec.dstPort`
85+
// +kubebuilder:printcolumn:name="SNATToIP",type=string,JSONPath=`.spec.snatToIp`,priority=1
86+
// +kubebuilder:printcolumn:name="SNATToPool",type=string,JSONPath=`.spec.snatToPool`,priority=1
87+
// +kubebuilder:printcolumn:name="DNATToIP",type=string,JSONPath=`.spec.dnatToIp`,priority=1
88+
// +kubebuilder:printcolumn:name="DNATToPort",type=integer,JSONPath=`.spec.dnatToPort`,priority=1
89+
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
90+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
91+
92+
// Nat is the Schema for the nats API
93+
type Nat struct {
94+
metav1.TypeMeta `json:",inline"`
95+
metav1.ObjectMeta `json:"metadata,omitempty"`
96+
97+
Spec NatSpec `json:"spec,omitempty"`
98+
Status NatStatus `json:"status,omitempty"`
99+
}
100+
101+
//+kubebuilder:object:root=true
102+
103+
// NatList contains a list of Nat
104+
type NatList struct {
105+
metav1.TypeMeta `json:",inline"`
106+
metav1.ListMeta `json:"metadata,omitempty"`
107+
Items []Nat `json:"items"`
108+
}
109+
110+
func init() {
111+
SchemeBuilder.Register(&Nat{}, &NatList{})
112+
}

api/v1alpha1/natmeta_types.go

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright 2021. Netris, Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// NatMetaSpec defines the desired state of NatMeta
27+
type NatMetaSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
Imported bool `json:"imported"`
31+
Reclaim bool `json:"reclaimPolicy"`
32+
NatCRGeneration int64 `json:"natGeneration"`
33+
ID int `json:"id"`
34+
NatName string `json:"natName"`
35+
36+
Comment string `json:"comment,omitempty"`
37+
State string `json:"state,omitempty"`
38+
SiteID int `json:"siteID"`
39+
Action string `json:"action"`
40+
Protocol string `json:"protocol"`
41+
SrcAddress string `json:"srcAddress"`
42+
SrcPort string `json:"srcPort,omitempty"`
43+
DstAddress string `json:"dstAddress"`
44+
DstPort string `json:"dstPort,omitempty"`
45+
SnatToIP string `json:"snatToIp,omitempty"`
46+
SnatToPool string `json:"snatToPool,omitempty"`
47+
DnatToIP string `json:"dnatToIp,omitempty"`
48+
DnatToPort int `json:"dnatToPort,omitempty"`
49+
}
50+
51+
// NatMetaStatus defines the observed state of NatMeta
52+
type NatMetaStatus struct {
53+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
54+
// Important: Run "make" to regenerate code after modifying this file
55+
}
56+
57+
//+kubebuilder:object:root=true
58+
//+kubebuilder:subresource:status
59+
60+
// NatMeta is the Schema for the natmeta API
61+
type NatMeta struct {
62+
metav1.TypeMeta `json:",inline"`
63+
metav1.ObjectMeta `json:"metadata,omitempty"`
64+
65+
Spec NatMetaSpec `json:"spec,omitempty"`
66+
Status NatMetaStatus `json:"status,omitempty"`
67+
}
68+
69+
//+kubebuilder:object:root=true
70+
71+
// NatMetaList contains a list of NatMeta
72+
type NatMetaList struct {
73+
metav1.TypeMeta `json:",inline"`
74+
metav1.ListMeta `json:"metadata,omitempty"`
75+
Items []NatMeta `json:"items"`
76+
}
77+
78+
func init() {
79+
SchemeBuilder.Register(&NatMeta{}, &NatMetaList{})
80+
}

0 commit comments

Comments
 (0)