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: pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/flink.apache.org/v1beta1/FlinkDeployment/customizations.yaml
+104Lines changed: 104 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,110 @@ spec:
32
32
end
33
33
return observedObj.status.error ~= nil
34
34
end
35
+
componentResource:
36
+
luaScript: >
37
+
local kube = require("kube")
38
+
39
+
local function isempty(s)
40
+
return s == nil or s == ''
41
+
end
42
+
43
+
local function qty(v)
44
+
if v == nil then return nil end
45
+
return kube.getResourceQuantity(v)
46
+
end
47
+
48
+
-- Safe fetch of deeply nested table fields.
49
+
local function get(obj, path)
50
+
local cur = obj
51
+
for i = 1, #path do
52
+
if cur == nil then return nil end
53
+
cur = cur[path[i]]
54
+
end
55
+
return cur
56
+
end
57
+
58
+
-- Normalize possibly-string numbers with a default.
59
+
local function to_num(v, default)
60
+
if v == nil or v == '' then return default end
61
+
local n = tonumber(v)
62
+
return n ~= nil and n or default
63
+
end
64
+
65
+
local function apply_pod_template(pt_spec, requires)
66
+
if pt_spec == nil then return end
67
+
68
+
local nodeSelector = pt_spec.nodeSelector
69
+
local tolerations = pt_spec.tolerations
70
+
local priority = pt_spec.priorityClassName
71
+
72
+
-- Only create nodeClaim if there’s content
73
+
if nodeSelector ~= nil or tolerations ~= nil then
74
+
requires.nodeClaim = requires.nodeClaim or {}
75
+
requires.nodeClaim.nodeSelector = nodeSelector
76
+
requires.nodeClaim.tolerations = tolerations
77
+
end
78
+
79
+
if not isempty(priority) then
80
+
requires.priorityClassName = priority
81
+
end
82
+
end
83
+
84
+
function GetComponents(observedObj)
85
+
local components = {}
86
+
local pt_spec = get(observedObj, {"spec","podTemplate","spec"})
87
+
88
+
-- ===== JobManager =====
89
+
local jm_replicas = to_num(get(observedObj, {"spec","jobManager","replicas"}), 1)
90
+
91
+
local jm_requires = {
92
+
resourceRequest = {},
93
+
}
94
+
95
+
local jm_cpu = get(observedObj, {"spec","jobManager","resource","cpu"})
96
+
local jm_memory = get(observedObj, {"spec","jobManager","resource","memory"})
0 commit comments