Skip to content

Commit edc3ba2

Browse files
Add pod field
1 parent 0d53e8e commit edc3ba2

File tree

8 files changed

+88
-47
lines changed

8 files changed

+88
-47
lines changed

.ci/clusters/global_backend_config.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ spec:
66
env:
77
global1: globalvalue1
88
shared1: fromglobal
9-
liveness:
10-
initialDelaySeconds: 10
11-
periodSeconds: 30
9+
pod:
10+
liveness:
11+
initialDelaySeconds: 10
12+
periodSeconds: 30

.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
env:
88
namespaced1: namespacedvalue1
99
shared1: fromnamespace
10-
liveness:
11-
initialDelaySeconds: 50
12-
periodSeconds: 60
10+
pod:
11+
liveness:
12+
initialDelaySeconds: 50
13+
periodSeconds: 60

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
env:
88
namespaced1: namespacedvalue1
99
shared1: fromnamespace
10-
liveness:
11-
initialDelaySeconds: 30
12-
periodSeconds: 10
10+
pod:
11+
liveness:
12+
initialDelaySeconds: 30
13+
periodSeconds: 10

api/compute/v1alpha1/backendconfig_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ type BackendConfigSpec struct {
3434
// +kubebuilder:validation:Optional
3535
Env map[string]string `json:"env,omitempty"`
3636

37+
// +kubebuilder:validation:Optional
38+
Pod *BackendConfigPodPolicy `json:"pod,omitempty"`
39+
}
40+
41+
// BackendConfigPodPolicy defines the policy for the pod
42+
// TODO: Support more fields from PodPolicy
43+
type BackendConfigPodPolicy struct {
3744
// +kubebuilder:validation:Optional
3845
Liveness *Liveness `json:"liveness,omitempty"`
3946
}

api/compute/v1alpha1/zz_generated.deepcopy.go

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

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,26 @@ spec:
5252
additionalProperties:
5353
type: string
5454
type: object
55-
liveness:
56-
properties:
57-
failureThreshold:
58-
format: int32
59-
type: integer
60-
initialDelaySeconds:
61-
format: int32
62-
type: integer
63-
periodSeconds:
64-
format: int32
65-
type: integer
66-
successThreshold:
67-
format: int32
68-
type: integer
69-
type: object
7055
name:
7156
type: string
57+
pod:
58+
properties:
59+
liveness:
60+
properties:
61+
failureThreshold:
62+
format: int32
63+
type: integer
64+
initialDelaySeconds:
65+
format: int32
66+
type: integer
67+
periodSeconds:
68+
format: int32
69+
type: integer
70+
successThreshold:
71+
format: int32
72+
type: integer
73+
type: object
74+
type: object
7275
type: object
7376
status:
7477
type: object

config/crd/bases/compute.functionmesh.io_backendconfigs.yaml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ spec:
3030
additionalProperties:
3131
type: string
3232
type: object
33-
liveness:
34-
properties:
35-
failureThreshold:
36-
format: int32
37-
type: integer
38-
initialDelaySeconds:
39-
format: int32
40-
type: integer
41-
periodSeconds:
42-
format: int32
43-
type: integer
44-
successThreshold:
45-
format: int32
46-
type: integer
47-
type: object
4833
name:
4934
type: string
35+
pod:
36+
properties:
37+
liveness:
38+
properties:
39+
failureThreshold:
40+
format: int32
41+
type: integer
42+
initialDelaySeconds:
43+
format: int32
44+
type: integer
45+
periodSeconds:
46+
format: int32
47+
type: integer
48+
successThreshold:
49+
format: int32
50+
type: integer
51+
type: object
52+
type: object
5053
type: object
5154
status:
5255
type: object

controllers/spec/common.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package spec
2020
import (
2121
"bytes"
2222
"context"
23+
2324
// used for template
2425
_ "embed"
2526
"encoding/json"
@@ -306,8 +307,10 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string,
306307
for key, val := range globalBackendConfig.Spec.Env {
307308
envData[key] = val
308309
}
309-
if globalBackendConfig.Spec.Liveness != nil {
310-
liveness = globalBackendConfig.Spec.Liveness
310+
if globalBackendConfig.Spec.Pod != nil {
311+
if globalBackendConfig.Spec.Pod.Liveness != nil {
312+
liveness = globalBackendConfig.Spec.Pod.Liveness
313+
}
311314
}
312315
}
313316
}
@@ -329,8 +332,10 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string,
329332
for key, val := range namespacedBackendConfig.Spec.Env {
330333
envData[key] = val
331334
}
332-
if namespacedBackendConfig.Spec.Liveness != nil {
333-
liveness = namespacedBackendConfig.Spec.Liveness
335+
if namespacedBackendConfig.Spec.Pod != nil {
336+
if namespacedBackendConfig.Spec.Pod.Liveness != nil {
337+
liveness = namespacedBackendConfig.Spec.Pod.Liveness
338+
}
334339
}
335340
}
336341
}

0 commit comments

Comments
 (0)