-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(meshloadbalancingstrategy): deprecate SourceIP and use Connection (…
…#12111) Signed-off-by: Lukasz Dziedziak <[email protected]> Co-authored-by: Bart Smykla <[email protected]>
- Loading branch information
1 parent
4fa5da8
commit 7a5db23
Showing
22 changed files
with
187 additions
and
3 deletions.
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
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
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
37 changes: 36 additions & 1 deletion
37
pkg/plugins/policies/meshloadbalancingstrategy/api/v1alpha1/deprecated.go
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 |
---|---|---|
@@ -1,9 +1,44 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/kumahq/kuma/pkg/plugins/policies/core/jsonpatch/validators" | ||
) | ||
|
||
func (t *MeshLoadBalancingStrategyResource) Deprecations() []string { | ||
return validators.TopLevelTargetRefDeprecations(t.Spec.TargetRef) | ||
deprecations := validateHashPoliciesType(t.Spec.To) | ||
deprecations = append(deprecations, validators.TopLevelTargetRefDeprecations(t.Spec.TargetRef)...) | ||
return deprecations | ||
} | ||
|
||
func validateHashPoliciesType(confs []To) []string { | ||
deprecations := []string{} | ||
for ruleIdx, conf := range confs { | ||
if conf.Default.LoadBalancer == nil { | ||
continue | ||
} | ||
|
||
switch conf.Default.LoadBalancer.Type { | ||
case RingHashType: | ||
if conf.Default.LoadBalancer.RingHash == nil || conf.Default.LoadBalancer.RingHash.HashPolicies == nil { | ||
continue | ||
} | ||
for lbIdx, lbConf := range *conf.Default.LoadBalancer.RingHash.HashPolicies { | ||
if lbConf.Type == SourceIPType { | ||
deprecations = append(deprecations, fmt.Sprintf("%s type for 'spec.to[%d].default.loadBalancer.ringHash.hashPolicies[%d].type' is deprecated, use %s instead", SourceIPType, ruleIdx, lbIdx, ConnectionType)) | ||
} | ||
} | ||
case MaglevType: | ||
if conf.Default.LoadBalancer.Maglev == nil || conf.Default.LoadBalancer.Maglev.HashPolicies == nil { | ||
continue | ||
} | ||
for lbIdx, lbConf := range *conf.Default.LoadBalancer.Maglev.HashPolicies { | ||
if lbConf.Type == SourceIPType { | ||
deprecations = append(deprecations, fmt.Sprintf("%s type for 'spec.to[%d].default.loadBalancer.maglev.hashPolicies[%d].type' is deprecated, use %s instead", SourceIPType, ruleIdx, lbIdx, ConnectionType)) | ||
} | ||
} | ||
} | ||
} | ||
return deprecations | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
...gins/runtime/k8s/webhooks/testdata/validation/cli-user_create_mtlbs.federated.golden.yaml
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,15 @@ | ||
Patches: null | ||
allowed: false | ||
status: | ||
code: 403 | ||
details: | ||
causes: | ||
- field: metadata.labels[kuma.io/origin] | ||
message: cannot be empty | ||
reason: FieldValueInvalid | ||
message: Operation not allowed. Applying policies on Zone CP requires 'kuma.io/origin' | ||
label to be set to 'zone'. | ||
metadata: {} | ||
reason: Forbidden | ||
status: Failure | ||
uid: "12345" |
11 changes: 11 additions & 0 deletions
11
...plugins/runtime/k8s/webhooks/testdata/validation/cli-user_create_mtlbs.global.golden.yaml
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,11 @@ | ||
Patches: null | ||
allowed: true | ||
status: | ||
code: 200 | ||
metadata: {} | ||
uid: "12345" | ||
warnings: | ||
- SourceIP type for 'spec.to[0].default.loadBalancer.ringHash.hashPolicies[0].type' | ||
is deprecated, use Connection instead | ||
- MeshService value for 'targetRef.kind' is deprecated, use MeshSubset with 'kuma.io/service' | ||
tag instead |
23 changes: 23 additions & 0 deletions
23
pkg/plugins/runtime/k8s/webhooks/testdata/validation/cli-user_create_mtlbs.input.yaml
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,23 @@ | ||
# user=cli-user,operation=CREATE,namespace=kuma-system | ||
apiVersion: kuma.io/v1alpha1 | ||
kind: MeshLoadBalancingStrategy | ||
metadata: | ||
name: mlbs-deprecated | ||
labels: | ||
kuma.io/mesh: default | ||
spec: | ||
targetRef: | ||
kind: MeshService | ||
name: frontend | ||
to: | ||
- targetRef: | ||
kind: MeshService | ||
name: backend | ||
default: | ||
loadBalancer: | ||
type: RingHash | ||
ringHash: | ||
hashPolicies: | ||
- type: SourceIP | ||
connection: | ||
sourceIP: true |
11 changes: 11 additions & 0 deletions
11
.../runtime/k8s/webhooks/testdata/validation/cli-user_create_mtlbs.non-federated.golden.yaml
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,11 @@ | ||
Patches: null | ||
allowed: true | ||
status: | ||
code: 200 | ||
metadata: {} | ||
uid: "12345" | ||
warnings: | ||
- SourceIP type for 'spec.to[0].default.loadBalancer.ringHash.hashPolicies[0].type' | ||
is deprecated, use Connection instead | ||
- MeshService value for 'targetRef.kind' is deprecated, use MeshSubset with 'kuma.io/service' | ||
tag instead |
11 changes: 11 additions & 0 deletions
11
...lugins/runtime/k8s/webhooks/testdata/validation/cp-user_create_mlbs.federated.golden.yaml
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,11 @@ | ||
Patches: null | ||
allowed: true | ||
status: | ||
code: 200 | ||
metadata: {} | ||
uid: "12345" | ||
warnings: | ||
- SourceIP type for 'spec.to[0].default.loadBalancer.ringHash.hashPolicies[0].type' | ||
is deprecated, use Connection instead | ||
- MeshService value for 'targetRef.kind' is deprecated, use MeshSubset with 'kuma.io/service' | ||
tag instead |
11 changes: 11 additions & 0 deletions
11
pkg/plugins/runtime/k8s/webhooks/testdata/validation/cp-user_create_mlbs.global.golden.yaml
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,11 @@ | ||
Patches: null | ||
allowed: true | ||
status: | ||
code: 200 | ||
metadata: {} | ||
uid: "12345" | ||
warnings: | ||
- SourceIP type for 'spec.to[0].default.loadBalancer.ringHash.hashPolicies[0].type' | ||
is deprecated, use Connection instead | ||
- MeshService value for 'targetRef.kind' is deprecated, use MeshSubset with 'kuma.io/service' | ||
tag instead |
24 changes: 24 additions & 0 deletions
24
pkg/plugins/runtime/k8s/webhooks/testdata/validation/cp-user_create_mlbs.input.yaml
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,24 @@ | ||
# user=system:serviceaccount:kuma-system:kuma-control-plane,operation=CREATE | ||
kind: MeshLoadBalancingStrategy | ||
apiVersion: kuma.io/v1alpha1 | ||
metadata: | ||
name: ring-hash | ||
namespace: kuma-system | ||
labels: | ||
kuma.io/mesh: default | ||
spec: | ||
targetRef: | ||
kind: MeshService | ||
name: frontend | ||
to: | ||
- targetRef: | ||
kind: MeshService | ||
name: backend | ||
default: | ||
loadBalancer: | ||
type: RingHash | ||
ringHash: | ||
hashPolicies: | ||
- type: SourceIP | ||
connection: | ||
sourceIP: true |
11 changes: 11 additions & 0 deletions
11
...ns/runtime/k8s/webhooks/testdata/validation/cp-user_create_mlbs.non-federated.golden.yaml
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,11 @@ | ||
Patches: null | ||
allowed: true | ||
status: | ||
code: 200 | ||
metadata: {} | ||
uid: "12345" | ||
warnings: | ||
- SourceIP type for 'spec.to[0].default.loadBalancer.ringHash.hashPolicies[0].type' | ||
is deprecated, use Connection instead | ||
- MeshService value for 'targetRef.kind' is deprecated, use MeshSubset with 'kuma.io/service' | ||
tag instead |