Skip to content

Commit 1ed84f4

Browse files
jiangpengchengfreeznet
authored andcommitted
Add default anti affinity (#810)
* [feat] Add default affinities to ensure pods: 1. prefer to be in different zones (soft rule) 2. must not be scheduled on the same node * add test * fix npe * fix vulnerabilities * fix unittest * fix unittest * fix ci * increase kind nodes in ci * fix ci * fix ci * Add a `DisableDefaultAffinity` field to PodPolicy * Update doc
1 parent c1708c3 commit 1ed84f4

20 files changed

+80
-6
lines changed

.ci/tests/integration/cases/global-and-namespaced-config/manifests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
- persistent://public/default/input-java-topic
1717
typeClassName: java.lang.String
1818
pod:
19+
disableDefaultAffinity: true
1920
env:
2021
- name: "podenv"
2122
value: "podvalue"

.ci/tests/integration/cases/python-function/manifests.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ spec:
88
className: exclamation_function.ExclamationFunction
99
forwardSourceMessageProperty: true
1010
maxPendingAsyncRequests: 1000
11-
replicas: 1
12-
maxReplicas: 1
11+
replicas: 3
1312
logTopic: persistent://public/default/py-function-logs
1413
input:
1514
topics:

.ci/tests/kind.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ nodes:
3131
listenAddress: "127.0.0.1"
3232
# optional: set the protocol to one of TCP, UDP, SCTP.
3333
# TCP is the default
34-
protocol: TCP
34+
protocol: TCP
35+
36+
- role: worker
37+
image: kindest/node:v1.23.17
38+
39+
- role: worker
40+
image: kindest/node:v1.23.17

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test-ginkgo: generate fmt vet manifests envtest
7272

7373
.PHONY: envtest
7474
envtest:
75-
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/[email protected]20240320141353-395cfc7486e6
75+
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/[email protected]20250630142431-4c2e9cec2954
7676

7777
# Build manager binary
7878
manager: generate fmt vet

api/compute/v1alpha1/common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ type PodPolicy struct {
227227
Env []corev1.EnvVar `json:"env,omitempty"`
228228

229229
Liveness *Liveness `json:"liveness,omitempty"`
230+
231+
DisableDefaultAffinity bool `json:"disableDefaultAffinity,omitempty"`
230232
}
231233

232234
type Runtime struct {

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ spec:
828828
items:
829829
type: string
830830
type: array
831+
disableDefaultAffinity:
832+
type: boolean
831833
env:
832834
items:
833835
properties:

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,8 @@ spec:
11271127
items:
11281128
type: string
11291129
type: array
1130+
disableDefaultAffinity:
1131+
type: boolean
11301132
env:
11311133
items:
11321134
properties:
@@ -5004,6 +5006,8 @@ spec:
50045006
items:
50055007
type: string
50065008
type: array
5009+
disableDefaultAffinity:
5010+
type: boolean
50075011
env:
50085012
items:
50095013
properties:
@@ -8662,6 +8666,8 @@ spec:
86628666
items:
86638667
type: string
86648668
type: array
8669+
disableDefaultAffinity:
8670+
type: boolean
86658671
env:
86668672
items:
86678673
properties:

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,8 @@ spec:
11461146
items:
11471147
type: string
11481148
type: array
1149+
disableDefaultAffinity:
1150+
type: boolean
11491151
env:
11501152
items:
11511153
properties:

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,8 @@ spec:
10671067
items:
10681068
type: string
10691069
type: array
1070+
disableDefaultAffinity:
1071+
type: boolean
10701072
env:
10711073
items:
10721074
properties:

charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,8 @@ spec:
10621062
items:
10631063
type: string
10641064
type: array
1065+
disableDefaultAffinity:
1066+
type: boolean
10651067
env:
10661068
items:
10671069
properties:

0 commit comments

Comments
 (0)