Skip to content

Commit 05571b9

Browse files
authored
Merge pull request #1763 from elastx/openstack_floating_ip_pool
✨ IPAM provider for floating ips
2 parents f90ddda + 368ff89 commit 05571b9

21 files changed

+1353
-11
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ generate-go: $(MOCKGEN)
257257
paths=./api/... \
258258
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt
259259
$(CONVERSION_GEN) \
260+
--input-dirs=./api/v1alpha1 \
260261
--input-dirs=./api/v1alpha5 \
261262
--input-dirs=./api/v1alpha6 \
262263
--input-dirs=./api/v1alpha7 \

PROJECT

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
1-
version: "2"
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
25
domain: cluster.x-k8s.io
36
repo: sigs.k8s.io/cluster-api-provider-openstack
47
resources:
58
- group: infrastructure
6-
version: v1alpha5
79
kind: OpenStackCluster
8-
- group: infrastructure
910
version: v1alpha5
10-
kind: OpenStackMachine
1111
- group: infrastructure
12+
kind: OpenStackMachine
1213
version: v1alpha5
14+
- group: infrastructure
1315
kind: OpenStackMachineTemplate
16+
version: v1alpha5
1417
- group: infrastructure
1518
kind: OpenStackClusterTemplate
1619
version: v1alpha5
1720
- group: infrastructure
18-
version: v1alpha6
1921
kind: OpenStackCluster
20-
- group: infrastructure
2122
version: v1alpha6
22-
kind: OpenStackMachine
2323
- group: infrastructure
24+
kind: OpenStackMachine
2425
version: v1alpha6
26+
- group: infrastructure
2527
kind: OpenStackMachineTemplate
28+
version: v1alpha6
2629
- group: infrastructure
2730
kind: OpenStackClusterTemplate
2831
version: v1alpha6
2932
- group: infrastructure
30-
version: v1alpha7
3133
kind: OpenStackCluster
32-
- group: infrastructure
3334
version: v1alpha7
34-
kind: OpenStackMachine
3535
- group: infrastructure
36+
kind: OpenStackMachine
3637
version: v1alpha7
38+
- group: infrastructure
3739
kind: OpenStackMachineTemplate
40+
version: v1alpha7
3841
- group: infrastructure
3942
kind: OpenStackClusterTemplate
4043
version: v1alpha7
@@ -50,3 +53,7 @@ resources:
5053
- group: infrastructure
5154
kind: OpenStackClusterTemplate
5255
version: v1alpha8
56+
- group: infrastructure
57+
kind: OpenStackFloatingIPPool
58+
version: v1alpha1
59+
version: "2"

api/v1alpha1/conditions_consts.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
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+
const (
20+
// OpenstackFloatingIPPoolReadyCondition reports on the current status of the floating ip pool. Ready indicates that the pool is ready to be used.
21+
OpenstackFloatingIPPoolReadyCondition = "OpenstackFloatingIPPoolReadyCondition"
22+
)

api/v1alpha1/doc.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
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

api/v1alpha1/groupversion_info.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors.
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 contains API Schema definitions for the infrastructure v1alpha1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=infrastructure.cluster.x-k8s.io
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
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+
"fmt"
21+
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
24+
25+
// We use v1alpha7 here rather than anything newer because as of writing
26+
// it is the newest API version we should no longer be making breaking
27+
// changes to. If we bump this we need to look carefully for resulting
28+
// CRD changes in v1alpha1 to ensure they are compatible.
29+
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
30+
)
31+
32+
const (
33+
// OpenStackFloatingIPPoolFinalizer allows ReconcileOpenStackFloatingIPPool to clean up resources associated with OpenStackFloatingIPPool before
34+
// removing it from the apiserver.
35+
OpenStackFloatingIPPoolFinalizer = "openstackfloatingippool.infrastructure.cluster.x-k8s.io"
36+
37+
OpenStackFloatingIPPoolNameIndex = "spec.poolRef.name"
38+
39+
// OpenStackFloatingIPPoolIP.
40+
DeleteFloatingIPFinalizer = "openstackfloatingippool.infrastructure.cluster.x-k8s.io/delete-floating-ip"
41+
)
42+
43+
// ReclaimPolicy is a string type alias to represent reclaim policies for floating ips.
44+
type ReclaimPolicy string
45+
46+
const (
47+
// ReclaimDelete is the reclaim policy for floating ips.
48+
ReclaimDelete ReclaimPolicy = "Delete"
49+
// ReclaimRetain is the reclaim policy for floating ips.
50+
ReclaimRetain ReclaimPolicy = "Retain"
51+
)
52+
53+
// OpenStackFloatingIPPoolSpec defines the desired state of OpenStackFloatingIPPool.
54+
type OpenStackFloatingIPPoolSpec struct {
55+
// PreAllocatedFloatingIPs is a list of floating IPs precreated in OpenStack that should be used by this pool.
56+
// These are used before allocating new ones and are not deleted from OpenStack when the pool is deleted.
57+
PreAllocatedFloatingIPs []string `json:"preAllocatedFloatingIPs,omitempty"`
58+
59+
// IdentityRef is a reference to a identity to be used when reconciling this pool.
60+
// +optional
61+
IdentityRef *infrav1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"`
62+
63+
// FloatingIPNetwork is the external network to use for floating ips, if there's only one external network it will be used by default
64+
// +optional
65+
FloatingIPNetwork infrav1alpha7.NetworkFilter `json:"floatingIPNetwork"`
66+
67+
// The name of the cloud to use from the clouds secret
68+
// +optional
69+
CloudName string `json:"cloudName"`
70+
71+
// The stratergy to use for reclaiming floating ips when they are released from a machine
72+
// +kubebuilder:validation:Optional
73+
// +kubebuilder:validation:Enum=Retain;Delete
74+
ReclaimPolicy ReclaimPolicy `json:"reclaimPolicy"`
75+
}
76+
77+
// OpenStackFloatingIPPoolStatus defines the observed state of OpenStackFloatingIPPool.
78+
type OpenStackFloatingIPPoolStatus struct {
79+
// +kubebuilder:default={}
80+
// +optional
81+
ClaimedIPs []string `json:"claimedIPs"`
82+
83+
// +kubebuilder:default={}
84+
// +optional
85+
AvailableIPs []string `json:"availableIPs"`
86+
87+
// FailedIPs contains a list of floating ips that failed to be allocated
88+
// +optional
89+
FailedIPs []string `json:"failedIPs,omitempty"`
90+
91+
// floatingIPNetwork contains information about the network used for floating ips
92+
// +optional
93+
FloatingIPNetwork *infrav1alpha7.NetworkStatus `json:"floatingIPNetwork,omitempty"`
94+
95+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
96+
}
97+
98+
//+kubebuilder:object:root=true
99+
// +kubebuilder:storageversion
100+
//+kubebuilder:subresource:status
101+
102+
// OpenStackFloatingIPPool is the Schema for the openstackfloatingippools API.
103+
type OpenStackFloatingIPPool struct {
104+
metav1.TypeMeta `json:",inline"`
105+
metav1.ObjectMeta `json:"metadata,omitempty"`
106+
107+
Spec OpenStackFloatingIPPoolSpec `json:"spec,omitempty"`
108+
Status OpenStackFloatingIPPoolStatus `json:"status,omitempty"`
109+
}
110+
111+
//+kubebuilder:object:root=true
112+
113+
// OpenStackFloatingIPPoolList contains a list of OpenStackFloatingIPPool.
114+
type OpenStackFloatingIPPoolList struct {
115+
metav1.TypeMeta `json:",inline"`
116+
metav1.ListMeta `json:"metadata,omitempty"`
117+
Items []OpenStackFloatingIPPool `json:"items"`
118+
}
119+
120+
// GetConditions returns the observations of the operational state of the OpenStackFloatingIPPool resource.
121+
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1.Conditions {
122+
return r.Status.Conditions
123+
}
124+
125+
// SetConditions sets the underlying service state of the OpenStackFloatingIPPool to the predescribed clusterv1.Conditions.
126+
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1.Conditions) {
127+
r.Status.Conditions = conditions
128+
}
129+
130+
func (r *OpenStackFloatingIPPool) GetFloatingIPTag() string {
131+
return fmt.Sprintf("cluster-api-provider-openstack-fip-pool-%s", r.Name)
132+
}
133+
134+
func init() {
135+
SchemeBuilder.Register(&OpenStackFloatingIPPool{}, &OpenStackFloatingIPPoolList{})
136+
}

0 commit comments

Comments
 (0)