Skip to content

Commit

Permalink
feat: HPA (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
silimarius authored Jun 12, 2024
1 parent e69d962 commit 5b9643a
Show file tree
Hide file tree
Showing 29 changed files with 803 additions and 39 deletions.
72 changes: 36 additions & 36 deletions .pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,25 @@ yarn aleo:deploy-leaderboard
> It's normal for the script to take a while to complete.
If you wish to re-deploy the leaderboard you will have to update its name in the `.env` before re-running the deploy script. Aleo uses program names as identifiers, thus 2 programs with the same name cannot co-exist on the same network.

### Deploy HPA

Create `monitoring` namespace:

```sh
kubectl create namespace monitoring
```

Deploy Prometheus:

```sh
kubectl apply -f deployment/templates/prometheus/
```

Deploy Prometheus adapter:

```sh
kubectl apply -f deployment/templates/prometheus-adapter/
```

You may need to restart the Prometheus adapter pod.
19 changes: 19 additions & 0 deletions deployment/base/autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: bot-busters
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: bot-busters
minReplicas: 1
maxReplicas: 10
metrics:
- type: Pods
pods:
metric:
name: active_connections_total
target:
type: AverageValue
averageValue: "4000"
4 changes: 4 additions & 0 deletions deployment/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ spec:
metadata:
labels:
app: bot-busters
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "3000"
spec:
containers:
- name: bot-busters
Expand Down
2 changes: 1 addition & 1 deletion deployment/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resources:
- deployment.yaml
- postgres.yaml
- service.yaml
- postgres-service.yaml
- autoscaling.yaml
generatorOptions:
disableNameSuffixHash: true
3 changes: 2 additions & 1 deletion deployment/local/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ spec:
value: ws://bot-busters.localhost
- name: PLAYERS_PER_MATCH
value: "2"
- name: ALEO_NETWORK_URL
- name: ALEO_NETWORK_URL # TODO: update to either minikube.internal or obscura URL
value: http://localhost:3030
- name: ALEO_PRIVATE_KEY
value: APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH # not a real account
- name: AWS_INFERENCE_URL
value: https://nez5g29b86.execute-api.eu-central-1.amazonaws.com/staging/generate
# missing secrets: AWS_ACCESS_KEY, AWS_SECRET, LAMBDA_TOKEN, OBSCURA_API_KEY (not mandatory for now)
1 change: 1 addition & 0 deletions deployment/local/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- namespace.yaml
- ingress.yaml
- secrets.yaml
- postgres.yaml
patchesStrategicMerge:
- deployment.yaml
namespace: bot-busters-local
57 changes: 57 additions & 0 deletions deployment/local/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
labels:
app: postgres
spec:
replicas: 1
selector:
matchLabels:
app: postgres
serviceName: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: ankane/pgvector:latest
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: backend-secrets
key: db_password
- name: PGDATA
value: /data/pgdata
volumeMounts:
- name: postgres-data
mountPath: /data
ports:
- containerPort: 5432
name: http
protocol: TCP

- name: adminer
image: adminer
ports:
- containerPort: 8080
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeClaimTemplates:
- metadata:
name: postgres-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
1 change: 1 addition & 0 deletions deployment/staging/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resources:
- namespace.yaml
- ingress.yaml
- secrets.yaml
- postgres.yaml
patchesStrategicMerge:
- deployment.yaml
namespace: bot-busters-staging
File renamed without changes.
14 changes: 14 additions & 0 deletions deployment/templates/prometheus-adapter/adapter.apiservice.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.custom.metrics.k8s.io
spec:
group: custom.metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: prometheus-adapter
namespace: monitoring
port: 443
version: v1beta1
versionPriority: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
name: v1beta1.metrics.k8s.io
spec:
group: metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: prometheus-adapter
namespace: monitoring
version: v1beta1
versionPriority: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
name: prometheus-adapter
rules:
- apiGroups:
- ""
resources:
- nodes
- namespaces
- pods
- services
verbs:
- get
- list
- watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
name: system:aggregated-metrics-reader
rules:
- apiGroups:
- metrics.k8s.io
resources:
- pods
- nodes
verbs:
- get
- list
- watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
name: prometheus-adapter
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-adapter
subjects:
- kind: ServiceAccount
name: prometheus-adapter
namespace: monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
name: resource-metrics:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: prometheus-adapter
namespace: monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/component: metrics-adapter
app.kubernetes.io/name: prometheus-adapter
app.kubernetes.io/part-of: kube-prometheus
app.kubernetes.io/version: 0.12.0
name: resource-metrics-server-resources
rules:
- apiGroups:
- metrics.k8s.io
resources:
- '*'
verbs:
- '*'
Loading

0 comments on commit 5b9643a

Please sign in to comment.