You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ The following annotations on services of type `LoadBalancer` are supported:
13
13
-`linkyard.ch/slb-controller-id`: this service must be processed by a controller with the given id
14
14
-`linkyard.ch/existing-floating-ip`: use the already existing floating IP on cloudscale.ch for this
15
15
service; note that no additional checks (e.g. port collisions) are performed
16
+
-`linkyard.ch/preserve-floating-ip`: don't delete the floating IP on cloudscale.ch when the service is deleted (or otherwise changed in a way that the IP no longer belongs to it). Default is `false`
// do not delete the ip, because the user has chosen so
91
+
log.Infof("load balancer ip for %v/%v (%v) was not deleted, because the preserve annotation has been set", svc.Namespace, svc.Name, getServiceLbIp(svc))
94
92
processor.emitEvent(
95
-
"Warning",
96
-
"FailedToDeleteFloatingIP",
97
-
fmt.Sprintf("Failed to delete IP %v: %v", getServiceLbIp(svc), err.Error()),
98
-
"delete-ip-failed",
93
+
"Normal",
94
+
"FloatingIPPreserved",
95
+
"FloatingIP preserved (put back to pool)",
96
+
"preserved",
99
97
getServiceLbIp(svc),
100
98
svc)
101
-
returnerr
102
99
} else {
103
-
log.Infof("successfully deleted ip %v for service %v/%v", getServiceLbIp(svc), svc.Namespace, svc.Name)
104
-
if!wasDeleted {
105
-
err=processor.updateLoadBalancerIngress(svc, "")
106
-
iferr!=nil {
107
-
log.WithFields(log.Fields{
108
-
"svc": getKey(svc),
109
-
"action": "DeleteIp",
110
-
"error": err,
111
-
}).Error("unable to update load balancer ip")
112
-
processor.emitEvent(
113
-
"Warning",
114
-
"DeleteLoadBalancerIpFailed",
115
-
fmt.Sprintf("Failed to update load balancer IP: %v", err),
116
-
"delete-lb-ip-failed",
117
-
getServiceLbIp(svc),
118
-
svc)
119
-
returnerr
120
-
} else {
121
-
log.Infof("load balancer ingress for service %v/%v updated successfully", svc.Namespace, svc.Name)
122
-
processor.emitEvent(
123
-
"Normal",
124
-
"FloatingIPDeleted",
125
-
"FloatingIP deleted",
126
-
"deleted",
127
-
getServiceLbIp(svc),
128
-
svc)
129
-
returnnil
130
-
}
100
+
// delete the ip (from cloudscale)
101
+
err:=processor.deleteIp(svc)
102
+
iferr!=nil {
103
+
log.WithFields(log.Fields{
104
+
"svc": getKey(svc),
105
+
"action": "DeleteIp",
106
+
"error": err,
107
+
}).Error("unable to delete ip")
108
+
processor.emitEvent(
109
+
"Warning",
110
+
"FailedToDeleteFloatingIP",
111
+
fmt.Sprintf("Failed to delete IP %v: %v", getServiceLbIp(svc), err.Error()),
112
+
"delete-ip-failed",
113
+
getServiceLbIp(svc),
114
+
svc)
115
+
returnerr
116
+
} else {
117
+
log.Infof("successfully deleted ip %v for service %v/%v", getServiceLbIp(svc), svc.Namespace, svc.Name)
118
+
processor.emitEvent(
119
+
"Normal",
120
+
"FloatingIPDeleted",
121
+
"FloatingIP deleted",
122
+
"deleted",
123
+
getServiceLbIp(svc),
124
+
svc)
125
+
}
126
+
}
127
+
ifwasDeleted {
128
+
//service was deleted, so we don't need to update it
129
+
returnnil
130
+
} else {
131
+
// remove the ip from the service
132
+
err:=processor.updateLoadBalancerIngress(svc, "")
133
+
iferr!=nil {
134
+
log.WithFields(log.Fields{
135
+
"svc": getKey(svc),
136
+
"action": "DeleteIp",
137
+
"error": err,
138
+
}).Error("unable to update load balancer ip")
139
+
processor.emitEvent(
140
+
"Warning",
141
+
"DeleteLoadBalancerIpFailed",
142
+
fmt.Sprintf("Failed to update load balancer IP: %v", err),
143
+
"delete-lb-ip-failed",
144
+
getServiceLbIp(svc),
145
+
svc)
146
+
returnerr
131
147
}
148
+
log.Infof("load balancer ingress for service %v/%v updated successfully", svc.Namespace, svc.Name)
0 commit comments