Skip to content

Commit afcbfd0

Browse files
authored
Introduce ReclaimPolicy for ephemeral VirtualIP (#1222)
* introduce reclaim policy for ephemerally created virtualIP * introduce reclaim policy for ephemerally created virtualIP * add `ValidateDelete` method in` virtualIPStrategy` to prevent vip deletion * address review comments
1 parent 7b8d2b9 commit afcbfd0

20 files changed

+625
-99
lines changed

api/networking/v1alpha1/virtualip_types.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010
)
1111

12-
// VirtualIPSpec defines the desired state of VirtualIP
12+
// VirtualIPSpec defines the desired state of a VirtualIP
1313
type VirtualIPSpec struct {
1414
// Type is the type of VirtualIP.
1515
Type VirtualIPType `json:"type"`
@@ -28,6 +28,16 @@ const (
2828
VirtualIPTypePublic VirtualIPType = "Public"
2929
)
3030

31+
// ReclaimPolicyType is the ironcore ReclaimPolicy of a VirtualIP.
32+
type ReclaimPolicyType string
33+
34+
const (
35+
// ReclaimPolicyTypeRetain is used for any VirtualIP that is retained when the claim of VirtualIP is released.
36+
ReclaimPolicyTypeRetain ReclaimPolicyType = "Retain"
37+
// ReclaimPolicyTypeDelete is used for any VirtualIP that is deleted when the claim of VirtualIP is released.
38+
ReclaimPolicyTypeDelete ReclaimPolicyType = "Delete"
39+
)
40+
3141
// VirtualIPStatus defines the observed state of VirtualIP
3242
type VirtualIPStatus struct {
3343
// IP is the allocated IP, if any.
@@ -55,8 +65,15 @@ type VirtualIPList struct {
5565
Items []VirtualIP `json:"items"`
5666
}
5767

68+
type EphemeralVirtualIPSpec struct {
69+
// VirtualIPSpec defines the desired state of a VirtualIP
70+
VirtualIPSpec `json:",inline"`
71+
// ReclaimPolicy is the ReclaimPolicyType of virtualIP
72+
ReclaimPolicy ReclaimPolicyType `json:"reclaimPolicy,omitempty"`
73+
}
74+
5875
// VirtualIPTemplateSpec is the specification of a VirtualIP template.
5976
type VirtualIPTemplateSpec struct {
6077
metav1.ObjectMeta `json:"metadata,omitempty"`
61-
Spec VirtualIPSpec `json:"spec,omitempty"`
78+
Spec EphemeralVirtualIPSpec `json:"spec,omitempty"`
6279
}

api/networking/v1alpha1/zz_generated.deepcopy.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/internal/internal.go

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/networking/v1alpha1/ephemeralvirtualipspec.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/networking/v1alpha1/virtualiptemplatespec.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/applyconfigurations/utils.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-go/openapi/zz_generated.openapi.go

Lines changed: 49 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)