Skip to content

Commit 6cf77d9

Browse files
committed
feat(controller): add metric runner
1 parent 3ab9575 commit 6cf77d9

18 files changed

Lines changed: 259 additions & 75 deletions

charts/controller/templates/_helpers.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,24 @@ env:
180180
value: api.routers.DefaultReplicaRouter
181181
{{- end }}
182182

183+
{{- define "controller-api.envs" }}
184+
{{- include "controller.envs" . }}
185+
- name: DRYCC_CONTROLLER_RUNNER
186+
value: api
187+
{{- end }}
188+
189+
{{- define "controller-metric.envs" }}
190+
{{- include "controller.envs" . }}
191+
- name: DRYCC_CONTROLLER_RUNNER
192+
value: metric
193+
{{- end }}
194+
195+
{{- define "controller-mutate.envs" }}
196+
{{- include "controller.envs" . }}
197+
- name: DRYCC_CONTROLLER_RUNNER
198+
value: mutate
199+
{{- end }}
200+
183201
{{/* Generate controller config default limit specs */}}
184202
{{ define "controller.config.defaultLimitSpecs" }}
185203
- model: api.limitspec

charts/controller/templates/controller-api-deployment.yaml renamed to charts/controller/templates/api/controller-api-deployment.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: drycc-controller
4+
name: drycc-controller-api
55
labels:
66
heritage: drycc
77
annotations:
88
component.drycc.cc/version: {{ .Values.imageTag }}
99
spec:
10-
replicas: {{ .Values.apiReplicas }}
10+
replicas: {{ .Values.api.replicas }}
1111
strategy:
1212
rollingUpdate:
1313
maxSurge: 1
1414
maxUnavailable: 0
1515
type: RollingUpdate
1616
selector:
1717
matchLabels:
18-
app: drycc-controller-api
18+
app: drycc-controller
19+
component: drycc-controller-api
1920
template:
2021
metadata:
2122
labels: {{- include "common.labels.standard" . | nindent 8 }}
22-
app: drycc-controller-api
23+
app: drycc-controller
24+
component: drycc-controller-api
2325
spec:
2426
affinity:
2527
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.api.podAffinityPreset.type "component" "" "extraMatchLabels" .Values.api.podAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}
2628
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.api.podAntiAffinityPreset.type "component" "" "extraMatchLabels" .Values.api.podAntiAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}
2729
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.api.nodeAffinityPreset.type "key" .Values.api.nodeAffinityPreset.key "values" .Values.api.nodeAffinityPreset.values ) | nindent 10 }}
2830
serviceAccount: drycc-controller
2931
initContainers:
30-
- name: drycc-controller-init
32+
- name: drycc-controller-api-init
3133
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/python-dev:latest
3234
imagePullPolicy: {{.Values.imagePullPolicy}}
3335
args:
3436
- netcat
3537
- -v
3638
- -u
3739
- $(DRYCC_DATABASE_URL),$(DRYCC_VALKEY_URL),$(DRYCC_DATABASE_REPLICA_URL)
38-
{{- include "controller.envs" . | indent 8 }}
40+
{{- include "controller-api.envs" . | indent 8 }}
3941
containers:
40-
- name: drycc-controller
42+
- name: drycc-controller-api
4143
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/controller:{{.Values.imageTag}}
4244
imagePullPolicy: {{.Values.imagePullPolicy}}
4345
{{- if .Values.diagnosticMode.enabled }}
@@ -74,7 +76,7 @@ spec:
7476
resources:
7577
{{- toYaml . | nindent 10 }}
7678
{{- end }}
77-
{{- include "controller.envs" . | indent 8 }}
79+
{{- include "controller-api.envs" . | indent 8 }}
7880
volumeMounts:
7981
- name: controller-config
8082
readOnly: false

charts/controller/templates/controller-api-service.yaml renamed to charts/controller/templates/api/controller-api-service.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ metadata:
77
{{- toYaml . | nindent 4 }}
88
{{- end }}
99
labels:
10+
app: drycc-controller
1011
heritage: drycc
12+
component: drycc-controller-api
1113
spec:
1214
ports:
1315
- name: http
1416
port: 80
1517
targetPort: 8000
1618
selector:
17-
app: drycc-controller-api
19+
app: drycc-controller
20+
component: drycc-controller-api

charts/controller/templates/controller-celery-deloyment.yaml renamed to charts/controller/templates/celery/controller-celery-deloyment.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ metadata:
77
annotations:
88
component.drycc.cc/version: {{ .Values.imageTag }}
99
spec:
10-
replicas: {{ .Values.celeryReplicas }}
10+
replicas: {{ .Values.celery.replicas }}
1111
strategy:
1212
rollingUpdate:
1313
maxSurge: 1
1414
maxUnavailable: 0
1515
type: RollingUpdate
1616
selector:
1717
matchLabels:
18-
app: drycc-controller-celery
18+
app: drycc-controller
19+
component: drycc-controller-celery
1920
template:
2021
metadata:
2122
labels: {{- include "common.labels.standard" . | nindent 8 }}
22-
app: drycc-controller-celery
23+
app: drycc-controller
24+
component: drycc-controller-celery
2325
spec:
2426
affinity:
2527
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.celery.podAffinityPreset.type "component" "" "extraMatchLabels" .Values.celery.podAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}

charts/controller/templates/controller-cronjob-daily.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ spec:
1717
template:
1818
metadata:
1919
labels: {{- include "common.labels.standard" . | nindent 12 }}
20-
app: drycc-controller-conjob
20+
app: drycc-controller
21+
component: drycc-controller-conjob-daily
2122
spec:
2223
restartPolicy: OnFailure
2324
serviceAccount: drycc-controller

charts/controller/templates/controller-cronjob-hourly.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ spec:
1717
template:
1818
metadata:
1919
labels: {{- include "common.labels.standard" . | nindent 12 }}
20-
app: drycc-controller-conjob
20+
app: drycc-controller
21+
component: drycc-controller-conjob-hourly
2122
spec:
2223
restartPolicy: OnFailure
2324
serviceAccount: drycc-controller

charts/controller/templates/controller-mutate-service.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: drycc-controller-metric
5+
labels:
6+
heritage: drycc
7+
annotations:
8+
component.drycc.cc/version: {{ .Values.imageTag }}
9+
spec:
10+
replicas: {{ .Values.metric.replicas }}
11+
strategy:
12+
rollingUpdate:
13+
maxSurge: 1
14+
maxUnavailable: 0
15+
type: RollingUpdate
16+
selector:
17+
matchLabels:
18+
app: drycc-controller
19+
component: drycc-controller-metric
20+
template:
21+
metadata:
22+
labels: {{- include "common.labels.standard" . | nindent 8 }}
23+
app: drycc-controller
24+
component: drycc-controller-metric
25+
spec:
26+
affinity:
27+
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.metric.podAffinityPreset.type "component" "" "extraMatchLabels" .Values.metric.podAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}
28+
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.metric.podAntiAffinityPreset.type "component" "" "extraMatchLabels" .Values.metric.podAntiAffinityPreset.extraMatchLabels "topologyKey" "" "context" $) | nindent 10 }}
29+
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.metric.nodeAffinityPreset.type "key" .Values.metric.nodeAffinityPreset.key "values" .Values.metric.nodeAffinityPreset.values ) | nindent 10 }}
30+
serviceAccount: drycc-controller
31+
initContainers:
32+
- name: drycc-controller-metric-init
33+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/python-dev:latest
34+
imagePullPolicy: {{.Values.imagePullPolicy}}
35+
args:
36+
- netcat
37+
- -v
38+
- -u
39+
- $(DRYCC_DATABASE_URL),$(DRYCC_VALKEY_URL),$(DRYCC_DATABASE_REPLICA_URL)
40+
{{- include "controller-metric.envs" . | indent 8 }}
41+
containers:
42+
- name: drycc-controller-metric
43+
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/controller:{{.Values.imageTag}}
44+
imagePullPolicy: {{.Values.imagePullPolicy}}
45+
{{- if .Values.diagnosticMode.enabled }}
46+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 10 }}
47+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 10 }}
48+
{{- end }}
49+
{{- if not .Values.diagnosticMode.enabled }}
50+
startupProbe:
51+
tcpSocket:
52+
port: 8000
53+
initialDelaySeconds: 30
54+
periodSeconds: 60
55+
timeoutSeconds: 1
56+
successThreshold: 1
57+
failureThreshold: 10
58+
livenessProbe:
59+
httpGet:
60+
path: /healthz
61+
port: 8000
62+
initialDelaySeconds: 30
63+
timeoutSeconds: 10
64+
readinessProbe:
65+
httpGet:
66+
path: /readiness
67+
port: 8000
68+
initialDelaySeconds: 30
69+
timeoutSeconds: 10
70+
periodSeconds: 5
71+
{{- end }}
72+
ports:
73+
- containerPort: 8000
74+
name: http
75+
{{- with index .Values "metric" "resources" }}
76+
resources:
77+
{{- toYaml . | nindent 10 }}
78+
{{- end }}
79+
{{- include "controller-metric.envs" . | indent 8 }}
80+
volumeMounts:
81+
- name: controller-config
82+
readOnly: false
83+
mountPath: /etc/controller
84+
volumes:
85+
- name: controller-config
86+
configMap:
87+
name: controller-config
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: drycc-controller-metric
5+
spec:
6+
podSelector:
7+
matchLabels:
8+
app: drycc-controller
9+
component: drycc-controller-metric
10+
policyTypes:
11+
- Ingress
12+
ingress:
13+
- from:
14+
- namespaceSelector:
15+
matchLabels:
16+
kubernetes.io/metadata.name: {{.Release.Namespace}}
17+
podSelector:
18+
matchLabels:
19+
app: drycc-victoriametrics
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: drycc-controller-metric
5+
annotations:
6+
{{- with .Values.service.annotations }}
7+
{{- toYaml . | nindent 4 }}
8+
{{- end }}
9+
labels:
10+
app: drycc-controller
11+
heritage: drycc
12+
component: drycc-controller-metric
13+
spec:
14+
clusterIP: None
15+
ports:
16+
- name: http
17+
port: 80
18+
targetPort: 8000
19+
selector:
20+
app: drycc-controller
21+
component: drycc-controller-metric

0 commit comments

Comments
 (0)