Skip to content

Commit 7f99e91

Browse files
[feat] - implement AddressSet CRD and support in firewall controller (#583)
* implement AddressSet CRD and support in firewall controller * address review comments
1 parent d949f08 commit 7f99e91

29 files changed

+1029
-86
lines changed

PROJECT

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ resources:
9898
path: github.com/linode/cluster-api-provider-linode/api/v1alpha2
9999
version: v1alpha2
100100
webhooks:
101-
validation: true
102101
defaulting: true
102+
validation: true
103103
webhookVersion: v1
104104
- api:
105105
crdVersion: v1
@@ -113,4 +113,12 @@ resources:
113113
webhooks:
114114
validation: true
115115
webhookVersion: v1
116+
- api:
117+
crdVersion: v1
118+
namespaced: true
119+
domain: cluster.x-k8s.io
120+
group: infrastructure
121+
kind: AddressSet
122+
path: github.com/linode/cluster-api-provider-linode/api/v1alpha2
123+
version: v1alpha2
116124
version: "3"

Tiltfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ if os.getenv("INSTALL_RKE2_PROVIDER", "false") == "true":
9999
)
100100
capl_resources = [
101101
"capl-system:namespace",
102+
"addresssets.infrastructure.cluster.x-k8s.io:customresourcedefinition",
102103
"linodeclusters.infrastructure.cluster.x-k8s.io:customresourcedefinition",
103104
"linodemachines.infrastructure.cluster.x-k8s.io:customresourcedefinition",
104105
"linodeclustertemplates.infrastructure.cluster.x-k8s.io:customresourcedefinition",

api/v1alpha2/addressset_types.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright 2023 Akamai Technologies, 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 v1alpha2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// AddressSetSpec defines the desired state of AddressSet
24+
type AddressSetSpec struct {
25+
IPv4 *[]string `json:"ipv4,omitempty"`
26+
IPv6 *[]string `json:"ipv6,omitempty"`
27+
}
28+
29+
// AddressSetStatus defines the observed state of AddressSet
30+
type AddressSetStatus struct {
31+
}
32+
33+
// +kubebuilder:object:root=true
34+
// +kubebuilder:subresource:status
35+
// +kubebuilder:resource:path=addressset,scope=Namespaced,categories=cluster-api,shortName=addrset
36+
// +kubebuilder:metadata:labels="clusterctl.cluster.x-k8s.io/move-hierarchy=true"
37+
38+
// AddressSet is the Schema for the addresssets API
39+
type AddressSet struct {
40+
metav1.TypeMeta `json:",inline"`
41+
metav1.ObjectMeta `json:"metadata,omitempty"`
42+
43+
Spec AddressSetSpec `json:"spec,omitempty"`
44+
Status AddressSetStatus `json:"status,omitempty"`
45+
}
46+
47+
//+kubebuilder:object:root=true
48+
49+
// AddressSetList contains a list of AddressSet
50+
type AddressSetList struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ListMeta `json:"metadata,omitempty"`
53+
Items []AddressSet `json:"items"`
54+
}
55+
56+
func init() {
57+
SchemeBuilder.Register(&AddressSet{}, &AddressSetList{})
58+
}

api/v1alpha2/linodefirewall_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ type FirewallRule struct {
6969
Ports string `json:"ports,omitempty"`
7070
// +kubebuilder:validation:Enum=TCP;UDP;ICMP;IPENCAP
7171
Protocol linodego.NetworkProtocol `json:"protocol"`
72-
Addresses *NetworkAddresses `json:"addresses"`
72+
Addresses *NetworkAddresses `json:"addresses,omitempty"`
73+
// AddressSetRefs is a list of references to AddressSets as an alternative to
74+
// using Addresses but can be used in conjunction with it
75+
AddressSetRefs []*corev1.ObjectReference `json:"addressSetRefs,omitempty"`
7376
}
7477

7578
// NetworkAddresses holds a list of IPv4 and IPv6 addresses

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
labels:
8+
clusterctl.cluster.x-k8s.io/move-hierarchy: "true"
9+
name: addressset.infrastructure.cluster.x-k8s.io
10+
spec:
11+
group: infrastructure.cluster.x-k8s.io
12+
names:
13+
categories:
14+
- cluster-api
15+
kind: AddressSet
16+
listKind: AddressSetList
17+
plural: addressset
18+
shortNames:
19+
- addrset
20+
singular: addressset
21+
scope: Namespaced
22+
versions:
23+
- name: v1alpha2
24+
schema:
25+
openAPIV3Schema:
26+
description: AddressSet is the Schema for the addresssets API
27+
properties:
28+
apiVersion:
29+
description: |-
30+
APIVersion defines the versioned schema of this representation of an object.
31+
Servers should convert recognized schemas to the latest internal value, and
32+
may reject unrecognized values.
33+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
34+
type: string
35+
kind:
36+
description: |-
37+
Kind is a string value representing the REST resource this object represents.
38+
Servers may infer this from the endpoint the client submits requests to.
39+
Cannot be updated.
40+
In CamelCase.
41+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
42+
type: string
43+
metadata:
44+
type: object
45+
spec:
46+
description: AddressSetSpec defines the desired state of AddressSet
47+
properties:
48+
ipv4:
49+
items:
50+
type: string
51+
type: array
52+
ipv6:
53+
items:
54+
type: string
55+
type: array
56+
type: object
57+
status:
58+
description: AddressSetStatus defines the observed state of AddressSet
59+
type: object
60+
type: object
61+
served: true
62+
storage: true
63+
subresources:
64+
status: {}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
name: addresssets.infrastructure.cluster.x-k8s.io
8+
spec:
9+
group: infrastructure.cluster.x-k8s.io
10+
names:
11+
kind: AddressSet
12+
listKind: AddressSetList
13+
plural: addresssets
14+
singular: addressset
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha2
18+
schema:
19+
openAPIV3Schema:
20+
description: AddressSet is the Schema for the addresssets API
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: AddressSetSpec defines the desired state of AddressSet
41+
properties:
42+
ipv4:
43+
items:
44+
type: string
45+
type: array
46+
ipv6:
47+
items:
48+
type: string
49+
type: array
50+
type: object
51+
status:
52+
description: AddressSetStatus defines the observed state of AddressSet
53+
type: object
54+
type: object
55+
served: true
56+
storage: true
57+
subresources:
58+
status: {}

0 commit comments

Comments
 (0)