Skip to content

Commit da1279f

Browse files
committed
feature: zalando.org/forward-backend annotation support to enable migration to eks
Usage: ``` apiVersion: zalando.org/v1 kind: StackSet metadata: annotations: zalando.org/forward-backend: eks migration .. ``` This will execute the migration preparation, such that the next traffic switch will send the traffic to the forward backend. Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
1 parent 6b37d32 commit da1279f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/core/stackset.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const (
1717
StackVersionLabelKey = "stack-version"
1818

1919
ingressTrafficAuthoritativeAnnotation = "zalando.org/traffic-authoritative"
20+
forwardBackendAnnotation = "zalando.org/forward-backend"
21+
forwardBackendName = "fwd"
2022
)
2123

2224
var (
@@ -50,8 +52,25 @@ func sanitizeServicePorts(service *zv1.StackServiceSpec) *zv1.StackServiceSpec {
5052
return service
5153
}
5254

55+
func patchForwardBackend(rg *zv1.RouteGroupSpec) {
56+
rg.AdditionalBackends = []rgv1.RouteGroupBackend{
57+
{
58+
Name: forwardBackendName,
59+
Type: rgv1.ForwardRouteGroupBackend,
60+
},
61+
}
62+
for _, route := range rg.Routes {
63+
route.Backends = []rgv1.RouteGroupBackendReference{
64+
{
65+
BackendName: forwardBackendName,
66+
},
67+
}
68+
}
69+
}
70+
5371
// NewStack returns an (optional) stack that should be created
5472
func (ssc *StackSetContainer) NewStack() (*StackContainer, string) {
73+
_, forwardMigration := ssc.StackSet.ObjectMeta.Annotations[forwardBackendAnnotation]
5574
observedStackVersion := ssc.StackSet.Status.ObservedStackVersion
5675
stackVersion := currentStackVersion(ssc.StackSet)
5776
stackName := generateStackName(ssc.StackSet, stackVersion)
@@ -70,6 +89,9 @@ func (ssc *StackSetContainer) NewStack() (*StackContainer, string) {
7089

7190
if ssc.StackSet.Spec.Ingress != nil {
7291
spec.Ingress = ssc.StackSet.Spec.Ingress.DeepCopy()
92+
if forwardMigration {
93+
spec.Ingress.EmbeddedObjectMetaWithAnnotations.Annotations["zalando.org/skipper-backend"] = "forward"
94+
}
7395
}
7496

7597
if ssc.StackSet.Spec.ExternalIngress != nil {
@@ -78,6 +100,9 @@ func (ssc *StackSetContainer) NewStack() (*StackContainer, string) {
78100

79101
if ssc.StackSet.Spec.RouteGroup != nil {
80102
spec.RouteGroup = ssc.StackSet.Spec.RouteGroup.DeepCopy()
103+
if forwardMigration {
104+
patchForwardBackend(spec.RouteGroup)
105+
}
81106
}
82107

83108
return &StackContainer{

0 commit comments

Comments
 (0)