Skip to content

Commit 0a6255d

Browse files
committed
chore(charts): add config to values.yaml
1 parent cf62df9 commit 0a6255d

3 files changed

Lines changed: 87 additions & 79 deletions

File tree

charts/controller/templates/_helpers.tpl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,74 @@ resources:
221221
{{- end }}
222222
{{- end }}
223223
{{- end }}
224+
225+
{{/* Generate controller config default limit specs */}}
226+
{{ define "controller.config.defaultLimitSpecs" }}
227+
- model: api.limitspec
228+
pk: std1
229+
fields:
230+
cpu:
231+
name: Unknown CPU
232+
cores: 32
233+
clock: 3100MHZ
234+
boost: 3700MHZ
235+
threads: 64
236+
memory:
237+
size: 64GB
238+
type: DDR4-ECC
239+
features:
240+
gpu:
241+
name: Unknown Integrated GPU
242+
tmus: 1
243+
rops: 1
244+
cores: 128
245+
memory:
246+
size: shared
247+
type: shared
248+
network: 10G
249+
keywords:
250+
- unknown
251+
disabled: false
252+
created: {{ now | date "2006-01-02T15:04:05.000Z" }}
253+
updated: {{ now | date "2006-01-02T15:04:05.000Z" }}
254+
{{- end }}
255+
256+
{{/* Generate controller config default limit plans */}}
257+
{{ define "controller.config.defaultLimitPlans" }}
258+
{{- $index := 0 }}
259+
{{- $cpus := tuple 1 2 4 8 16 32 }}
260+
{{- $scales := tuple 1 2 4 8 }}
261+
{{- range $cpu := $cpus }}
262+
{{- range $scale := $scales }}
263+
{{- $memory := mul $cpu $scale }}
264+
- model: api.limitplan
265+
pk: std1.large.c{{ $cpu }}m{{ $memory }}
266+
fields:
267+
spec_id: std1
268+
cpu: {{ $cpu }}
269+
memory: {{ $memory }}
270+
features:
271+
gpu: 1
272+
network: 1
273+
disabled: false
274+
priority: {{ add 10000 (mul (add1 $index) 100) }}
275+
limits:
276+
cpu: {{ $cpu }}
277+
memory: {{ $memory }}Gi
278+
ephemeral-storage: 2Gi
279+
requests:
280+
cpu: {{ divf $cpu 4 }}
281+
memory: {{ divf $memory 2 }}Gi
282+
ephemeral-storage: 2Gi
283+
annotations:
284+
kubernetes.io/egress-bandwidth: 100M
285+
kubernetes.io/ingress-bandwidth: 100M
286+
node_selector: {}
287+
pod_security_context: {}
288+
container_security_context: {}
289+
created: {{ now | date "2006-01-02T15:04:05.000Z" }}
290+
updated: {{ now | date "2006-01-02T15:04:05.000Z" }}
291+
{{- $index = (add1 $index) }}
292+
{{- end }}
293+
{{- end }}
294+
{{- end }}

charts/controller/templates/controller-configmap.yaml

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,14 @@ metadata:
66
heritage: drycc
77
data:
88
limit-specs.json: |
9-
[{
10-
"model": "api.limitspec",
11-
"pk": "std1",
12-
"fields": {
13-
"cpu": {
14-
"name": "Unknown CPU",
15-
"cores": 32,
16-
"clock": "3100MHZ",
17-
"boost": "3700MHZ",
18-
"threads": 64
19-
},
20-
"memory": {
21-
"size": "64GB",
22-
"type": "DDR4-ECC"
23-
},
24-
"features": {
25-
"gpu": {
26-
"name": "Unknown Integrated GPU",
27-
"tmus": 1,
28-
"rops": 1,
29-
"cores": 128,
30-
"memory": {
31-
"size": "shared",
32-
"type": "shared"
33-
}
34-
},
35-
"network": "10G"
36-
},
37-
"keywords": ["unknown"],
38-
"disabled": false,
39-
"created": "{{ now | date "2006-01-02T15:04:05.000Z" }}",
40-
"updated": "{{ now | date "2006-01-02T15:04:05.000Z" }}"
41-
}
42-
}]
43-
# Given a name SPEC.NETWORK.PLAN(eg: std1.xlarge.c1m1), increment the:
44-
# * SPEC different specification families can be selected based on business and usage scenarios.
45-
# * NETWORK
46-
# * PLAN Specific CPU configuration, such as c1m1 representing one CPU and 1GB of memory.
9+
{{- if .Values.config.limitSpecs }}
10+
{{- (tpl .Values.config.limitSpecs $) | nindent 4 }}
11+
{{- else}}
12+
{{- include "controller.config.defaultLimitSpecs" . | fromYamlArray | toPrettyJson | nindent 4 }}
13+
{{- end }}
4714
limit-plans.json: |
48-
[
49-
{{- $items := tuple "1/1/10" "1/2/10" "1/4/20" "2/2/20" "2/4/30" "2/8/30" }}
50-
{{- range $index, $item := $items }}
51-
{{- $cpu := index (splitList "/" $item) 0 }}
52-
{{- $memory := index (splitList "/" $item) 1 }}
53-
{{- $network := index (splitList "/" $item) 2 }}
54-
{
55-
"model": "api.limitplan",
56-
"pk": "std1.large.c{{ $cpu }}m{{ $memory }}",
57-
"fields": {
58-
"spec_id": "std1",
59-
"cpu": {{ $cpu }},
60-
"memory": {{ $memory }},
61-
"features": {
62-
"gpu": 1,
63-
"network": 1
64-
},
65-
"disabled": false,
66-
"priority": {{ add 100 $index }},
67-
"limits": {
68-
"cpu": {{ $cpu }},
69-
"memory": "{{ $memory }}Gi",
70-
"ephemeral-storage": "2Gi"
71-
},
72-
"requests": {
73-
"cpu": {{ divf $cpu 2 }},
74-
"memory": "{{ divf $memory 2 }}Gi",
75-
"ephemeral-storage": "2Gi"
76-
},
77-
"annotations": {
78-
"kubernetes.io/egress-bandwidth": "{{ $network }}M",
79-
"kubernetes.io/ingress-bandwidth": "{{ $network }}M"
80-
},
81-
"node_selector": {},
82-
"pod_security_context": {},
83-
"container_security_context": {},
84-
"created": "{{ now | date "2006-01-02T15:04:05.000Z" }}",
85-
"updated": "{{ now | date "2006-01-02T15:04:05.000Z" }}"
86-
}
87-
}{{ if not (eq $item ($items|last)) }},{{ end }}
15+
{{- if .Values.config.limitPlans }}
16+
{{- (tpl .Values.config.limitPlans $) | nindent 4 }}
17+
{{- else}}
18+
{{- include "controller.config.defaultLimitPlans" . | fromYamlArray | toPrettyJson | nindent 4 }}
8819
{{- end }}
89-
]

charts/controller/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,17 @@ workflowManagerSecretKey: ""
6565

6666
# Configuring this will no longer use the built-in rabbitmq component
6767
rabbitmqUrl: ""
68+
69+
# limit specs, plans config
70+
config:
71+
limitSpecs: ""
72+
limitPlans: ""
73+
6874
# Service
6975
service:
7076
# Provide any additional service annotations
7177
annotations: {}
78+
7279
# Any custom controller environment variables
7380
# can be specified as key-value pairs under environment
7481
# this is usually a non required setting.

0 commit comments

Comments
 (0)