Skip to content

Commit b70983b

Browse files
committed
The sync function supports auto scaling based on CPU
Signed-off-by: wanjunlei <[email protected]>
1 parent c87f2e3 commit b70983b

File tree

5 files changed

+124
-1
lines changed

5 files changed

+124
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: autoscaler-hpa
5+
namespace: knative-serving
6+
labels:
7+
autoscaling.knative.dev/autoscaler-provider: hpa
8+
app.kubernetes.io/component: autoscaler-hpa
9+
app.kubernetes.io/name: knative-serving
10+
app.kubernetes.io/version: "1.3.2"
11+
serving.knative.dev/release: "v1.3.2"
12+
{{- include "knative-serving.labels" . | nindent 4 }}
13+
spec:
14+
selector:
15+
matchLabels:
16+
app: autoscaler-hpa
17+
{{- include "knative-serving.selectorLabels" . | nindent 6 }}
18+
template:
19+
metadata:
20+
annotations:
21+
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
22+
labels:
23+
app: autoscaler-hpa
24+
app.kubernetes.io/component: autoscaler-hpa
25+
app.kubernetes.io/name: knative-serving
26+
app.kubernetes.io/version: "1.3.2"
27+
serving.knative.dev/release: "v1.3.2"
28+
{{- include "knative-serving.labels" . | nindent 8 }}
29+
spec:
30+
# To avoid node becoming SPOF, spread our replicas to different nodes.
31+
affinity:
32+
podAntiAffinity:
33+
preferredDuringSchedulingIgnoredDuringExecution:
34+
- podAffinityTerm:
35+
labelSelector:
36+
matchLabels:
37+
app: autoscaler-hpa
38+
topologyKey: kubernetes.io/hostname
39+
weight: 100
40+
serviceAccountName: controller
41+
containers:
42+
- name: autoscaler-hpa
43+
# This is the Go import path for the binary that is containerized
44+
# and substituted here.
45+
{{- with .Values.hpa.image }}
46+
image: {{ .repository }}:{{ .tag }}
47+
{{- end }}
48+
resources: {{- toYaml .Values.hpa.resources | nindent 10 }}
49+
env:
50+
- name: SYSTEM_NAMESPACE
51+
valueFrom:
52+
fieldRef:
53+
fieldPath: metadata.namespace
54+
- name: CONFIG_LOGGING_NAME
55+
value: config-logging
56+
- name: CONFIG_OBSERVABILITY_NAME
57+
value: config-observability
58+
- name: METRICS_DOMAIN
59+
value: knative.dev/serving
60+
securityContext:
61+
allowPrivilegeEscalation: false
62+
readOnlyRootFilesystem: true
63+
runAsNonRoot: true
64+
capabilities:
65+
drop:
66+
- all
67+
ports:
68+
- name: metrics
69+
containerPort: 9090
70+
- name: profiling
71+
containerPort: 8008
72+
73+
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: autoscaler-hpa
6+
autoscaling.knative.dev/autoscaler-provider: hpa
7+
app.kubernetes.io/component: autoscaler-hpa
8+
app.kubernetes.io/name: knative-serving
9+
app.kubernetes.io/version: "1.3.2"
10+
serving.knative.dev/release: "v1.3.2"
11+
{{- include "knative-serving.labels" . | nindent 4 }}
12+
name: autoscaler-hpa
13+
namespace: knative-serving
14+
spec:
15+
ports:
16+
# Define metrics and profiling for them to be accessible within service meshes.
17+
- name: http-metrics
18+
port: 9090
19+
targetPort: 9090
20+
- name: http-profiling
21+
port: 8008
22+
targetPort: 8008
23+
selector:
24+
app: autoscaler-hpa
25+
{{- include "knative-serving.selectorLabels" . | nindent 4 }}

knative-serving/values.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,15 @@ webhook:
168168
memory: 500Mi
169169
requests:
170170
cpu: 100m
171-
memory: 100Mi
171+
memory: 100Mi
172+
hpa:
173+
image:
174+
repository: gcr.io/knative-releases/knative.dev/serving/cmd/autoscaler-hpa
175+
tag: v1.3.2
176+
resources:
177+
requests:
178+
cpu: 30m
179+
memory: 40Mi
180+
limits:
181+
cpu: 300m
182+
memory: 400Mi

openfunction/templates/manager-rbac.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ kind: ClusterRole
33
metadata:
44
name: {{ include "openfunction.fullname" . }}-manager-role
55
labels:
6+
rbac.authorization.k8s.io/aggregate-to-admin: "true"
7+
rbac.authorization.k8s.io/aggregate-to-edit: "true"
8+
rbac.authorization.k8s.io/aggregate-to-view: "true"
69
{{- include "openfunction.labels" . | nindent 4 }}
710
rules:
811
- apiGroups:

openfunction/values.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ knative-serving:
157157
requests:
158158
cpu: 100m
159159
memory: 100Mi
160+
hpa:
161+
image:
162+
repository: openfunction/knative.dev-serving-cmd-autoscaler-hpa
163+
tag: v1.3.2
164+
resources:
165+
requests:
166+
cpu: 30m
167+
memory: 40Mi
168+
limits:
169+
cpu: 300m
170+
memory: 400Mi
160171
shipwright-build:
161172
shipwrightBuildController:
162173
shipwrightBuild:

0 commit comments

Comments
 (0)