-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ IPAM provider for floating ips #1763
Merged
k8s-ci-robot
merged 1 commit into
kubernetes-sigs:main
from
elastx:openstack_floating_ip_pool
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
const ( | ||
// OpenstackFloatingIPPoolReadyCondition reports on the current status of the floating ip pool. Ready indicates that the pool is ready to be used. | ||
OpenstackFloatingIPPoolReadyCondition = "OpenstackFloatingIPPoolReadyCondition" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// package v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group | ||
// +kubebuilder:object:generate=true | ||
// +groupName=infrastructure.cluster.x-k8s.io | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects. | ||
GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme. | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" | ||
|
||
// We use v1alpha7 here rather than anything newer because as of writing | ||
// it is the newest API version we should no longer be making breaking | ||
// changes to. If we bump this we need to look carefully for resulting | ||
// CRD changes in v1alpha1 to ensure they are compatible. | ||
infrav1alpha7 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7" | ||
) | ||
|
||
const ( | ||
// OpenStackFloatingIPPoolFinalizer allows ReconcileOpenStackFloatingIPPool to clean up resources associated with OpenStackFloatingIPPool before | ||
// removing it from the apiserver. | ||
OpenStackFloatingIPPoolFinalizer = "openstackfloatingippool.infrastructure.cluster.x-k8s.io" | ||
|
||
OpenStackFloatingIPPoolNameIndex = "spec.poolRef.name" | ||
|
||
// OpenStackFloatingIPPoolIP. | ||
DeleteFloatingIPFinalizer = "openstackfloatingippool.infrastructure.cluster.x-k8s.io/delete-floating-ip" | ||
) | ||
|
||
// ReclaimPolicy is a string type alias to represent reclaim policies for floating ips. | ||
type ReclaimPolicy string | ||
|
||
const ( | ||
// ReclaimDelete is the reclaim policy for floating ips. | ||
ReclaimDelete ReclaimPolicy = "Delete" | ||
// ReclaimRetain is the reclaim policy for floating ips. | ||
ReclaimRetain ReclaimPolicy = "Retain" | ||
) | ||
|
||
// OpenStackFloatingIPPoolSpec defines the desired state of OpenStackFloatingIPPool. | ||
type OpenStackFloatingIPPoolSpec struct { | ||
// PreAllocatedFloatingIPs is a list of floating IPs precreated in OpenStack that should be used by this pool. | ||
// These are used before allocating new ones and are not deleted from OpenStack when the pool is deleted. | ||
PreAllocatedFloatingIPs []string `json:"preAllocatedFloatingIPs,omitempty"` | ||
|
||
// IdentityRef is a reference to a identity to be used when reconciling this pool. | ||
// +optional | ||
IdentityRef *infrav1alpha7.OpenStackIdentityReference `json:"identityRef,omitempty"` | ||
|
||
// FloatingIPNetwork is the external network to use for floating ips, if there's only one external network it will be used by default | ||
// +optional | ||
FloatingIPNetwork infrav1alpha7.NetworkFilter `json:"floatingIPNetwork"` | ||
|
||
// The name of the cloud to use from the clouds secret | ||
// +optional | ||
CloudName string `json:"cloudName"` | ||
|
||
// The stratergy to use for reclaiming floating ips when they are released from a machine | ||
// +kubebuilder:validation:Optional | ||
// +kubebuilder:validation:Enum=Retain;Delete | ||
ReclaimPolicy ReclaimPolicy `json:"reclaimPolicy"` | ||
} | ||
|
||
// OpenStackFloatingIPPoolStatus defines the observed state of OpenStackFloatingIPPool. | ||
type OpenStackFloatingIPPoolStatus struct { | ||
// +kubebuilder:default={} | ||
// +optional | ||
ClaimedIPs []string `json:"claimedIPs"` | ||
|
||
// +kubebuilder:default={} | ||
// +optional | ||
AvailableIPs []string `json:"availableIPs"` | ||
|
||
// FailedIPs contains a list of floating ips that failed to be allocated | ||
// +optional | ||
FailedIPs []string `json:"failedIPs,omitempty"` | ||
|
||
// floatingIPNetwork contains information about the network used for floating ips | ||
// +optional | ||
FloatingIPNetwork *infrav1alpha7.NetworkStatus `json:"floatingIPNetwork,omitempty"` | ||
|
||
Conditions clusterv1.Conditions `json:"conditions,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
// +kubebuilder:storageversion | ||
//+kubebuilder:subresource:status | ||
|
||
// OpenStackFloatingIPPool is the Schema for the openstackfloatingippools API. | ||
type OpenStackFloatingIPPool struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec OpenStackFloatingIPPoolSpec `json:"spec,omitempty"` | ||
Status OpenStackFloatingIPPoolStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// OpenStackFloatingIPPoolList contains a list of OpenStackFloatingIPPool. | ||
type OpenStackFloatingIPPoolList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []OpenStackFloatingIPPool `json:"items"` | ||
} | ||
|
||
// GetConditions returns the observations of the operational state of the OpenStackFloatingIPPool resource. | ||
func (r *OpenStackFloatingIPPool) GetConditions() clusterv1.Conditions { | ||
return r.Status.Conditions | ||
} | ||
|
||
// SetConditions sets the underlying service state of the OpenStackFloatingIPPool to the predescribed clusterv1.Conditions. | ||
func (r *OpenStackFloatingIPPool) SetConditions(conditions clusterv1.Conditions) { | ||
r.Status.Conditions = conditions | ||
} | ||
|
||
func (r *OpenStackFloatingIPPool) GetFloatingIPTag() string { | ||
return fmt.Sprintf("cluster-api-provider-openstack-fip-pool-%s", r.Name) | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&OpenStackFloatingIPPool{}, &OpenStackFloatingIPPoolList{}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a doc string for this as well? I know it is fairly self explanatory, but it is still nice to have descriptions for all fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little formatting fixes, plus I think this should have
+optional
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dulek FYI I've been recommending against
+optional
s because they're already the default. I don't have a strong position on it, though. Is there specific guidance somewhere I'm ignoring?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so just the formatting fixes! :)