Skip to content

Commit 28b74cc

Browse files
authored
feat(balius): Enhance Balius chart for external exposure (#200)
Signed-off-by: Ales Verbic <verbotenj@blinklabs.io>
1 parent 111eb02 commit 28b74cc

8 files changed

Lines changed: 264 additions & 1 deletion

File tree

charts/balius/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: balius
33
description: Balius server
4-
version: 0.0.4
4+
version: 0.0.5
55
appVersion: "0.0.1"
66

77
sources:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.proxyCertificate.enabled }}
2+
apiVersion: cert-manager.io/v1
3+
kind: Certificate
4+
metadata:
5+
name: {{ .Values.proxyCertificate.secretName }}
6+
namespace: {{ .Release.Namespace }}
7+
spec:
8+
dnsNames: {{ .Values.proxyCertificate.dnsNames | toYaml | nindent 4 }}
9+
issuerRef:
10+
kind: {{ .Values.proxyCertificate.issuerKind }}
11+
name: {{ .Values.proxyCertificate.issuerName }}
12+
secretName: {{ .Values.proxyCertificate.secretName }}
13+
{{- end }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.dnsEndpoint.enabled }}
2+
apiVersion: externaldns.k8s.io/v1alpha1
3+
kind: DNSEndpoint
4+
metadata:
5+
name: {{ .Values.dnsEndpoint.name }}
6+
namespace: {{ .Values.dnsEndpoint.namespace }}
7+
spec:
8+
endpoints:
9+
{{- range .Values.dnsEndpoint.endpoints }}
10+
- dnsName: {{ .dnsName }}
11+
recordType: {{ .recordType }}
12+
targets:
13+
{{- range .targets }}
14+
- {{ . }}
15+
{{- end }}
16+
providerSpecific:
17+
{{- range .providerSpecific }}
18+
- name: {{ .name }}
19+
value: {{ .value | quote }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: proxy-{{ .Values.balius.network }}-config
5+
namespace: {{ .Release.Namespace }}
6+
data:
7+
tiers.toml: |
8+
{{- range $tier := .Values.proxy.tiers }}
9+
[[tiers]]
10+
name = "{{ $tier.name }}"
11+
{{- range $rate := $tier.rates }}
12+
[[tiers.rates]]
13+
interval = "{{ $rate.interval }}"
14+
limit = {{ div $rate.limitPerReplica $.Values.balius.replicas }}
15+
{{- end }}
16+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if .Values.proxy.podMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: PodMonitor
4+
metadata:
5+
name: {{ include "balius.fullname" . }}-proxy
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- with .Values.proxy.podMonitor.labels }}
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
11+
spec:
12+
selector:
13+
matchLabels:
14+
role: {{ .Values.proxy.role }}
15+
podMetricsEndpoints:
16+
- port: metrics
17+
path: /metrics
18+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.proxyService.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ .Values.proxyService.name | replace "_" "-" }}
6+
namespace: {{ .Values.proxyService.namespace | default .Release.Namespace }}
7+
{{- with .Values.proxyService.labels }}
8+
labels: {{ toYaml . | nindent 4 }}
9+
{{- end }}
10+
{{- with .Values.proxyService.annotations }}
11+
annotations: {{ toYaml . | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
{{ toYaml .Values.proxyService.spec | nindent 2 }}
15+
{{- end }}

charts/balius/templates/proxy.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "balius.fullname" . }}-proxy
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
role: {{ .Values.proxy.role }}
8+
spec:
9+
replicas: {{ .Values.proxy.replicas }}
10+
selector:
11+
matchLabels:
12+
role: {{ .Values.proxy.role }}
13+
template:
14+
metadata:
15+
name: {{ include "balius.fullname" . }}-proxy
16+
labels:
17+
role: {{ .Values.proxy.role }}
18+
spec:
19+
serviceAccountName: {{ .Values.proxy.serviceAccountName | default .Values.balius.serviceAccount.name }}
20+
containers:
21+
- name: main
22+
image: "{{ .Values.proxy.image.repository }}:{{ .Values.proxy.image.tag }}"
23+
imagePullPolicy: {{ .Values.proxy.image.pullPolicy }}
24+
resources: {{ toYaml .Values.proxy.resources | nindent 12 }}
25+
ports:
26+
- name: metrics
27+
containerPort: {{ .Values.proxy.ports.metrics }}
28+
protocol: TCP
29+
- name: proxy
30+
containerPort: {{ .Values.proxy.ports.proxy }}
31+
protocol: TCP
32+
env:
33+
- name: PROXY_NAMESPACE
34+
value: {{ .Values.proxy.namespace | quote }}
35+
- name: PROXY_ADDR
36+
value: {{ .Values.proxy.proxyAddr | quote }}
37+
- name: PROMETHEUS_ADDR
38+
value: {{ .Values.proxy.prometheusAddr | quote }}
39+
- name: BALIUS_PORT
40+
value: {{ .Values.proxy.baliusPort | quote }}
41+
- name: BALIUS_DNS
42+
value: {{ .Values.proxy.baliusDns | quote }}
43+
- name: DEFAULT_BALIUS_VERSION
44+
value: {{ .Values.proxy.defaultBaliusVersion | quote }}
45+
- name: SSL_CRT_PATH
46+
value: /certs/tls.crt
47+
- name: SSL_KEY_PATH
48+
value: /certs/tls.key
49+
- name: PROXY_TIERS_PATH
50+
value: /configs/tiers.toml
51+
volumeMounts:
52+
- name: certs
53+
mountPath: /certs
54+
- name: configs
55+
mountPath: /configs
56+
volumes:
57+
- name: certs
58+
secret:
59+
secretName: {{ .Values.proxyCertificate.secretName }}
60+
- name: configs
61+
configMap:
62+
name: proxy-{{ .Values.balius.network }}-config
63+
{{- with .Values.proxy.tolerations }}
64+
tolerations: {{ toYaml . | nindent 8 }}
65+
{{- end }}
66+
{{- with .Values.proxy.affinity }}
67+
affinity: {{ toYaml . | nindent 8 }}
68+
{{- end }}

charts/balius/values.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,114 @@ vault:
7777
token: "vault-token-placeholder"
7878
vault_token_renew_interval: "24h"
7979
vault_token_renew_seconds: "600"
80+
81+
# --- Proxy Configuration ---
82+
# Proxy is used to limit the number of requests per second
83+
# and to provide a single entry point for the Balius network
84+
proxy:
85+
namespace: balius
86+
role: balius-proxy
87+
replicas: 1
88+
89+
serviceAccountName: "balius"
90+
91+
image:
92+
repository: ghcr.io/demeter-run/ext-balius-proxy
93+
tag: "86aa2dbfc2202fe4eeafd961064567255b33daf7"
94+
pullPolicy: IfNotPresent
95+
96+
resources:
97+
limits:
98+
cpu: "1"
99+
memory: "1Gi"
100+
requests:
101+
cpu: "200m"
102+
memory: "256Mi"
103+
104+
ports:
105+
metrics: 8080
106+
proxy: 9090
107+
108+
tolerations: []
109+
110+
proxyAddr: "0.0.0.0:9090"
111+
prometheusAddr: "0.0.0.0:8080"
112+
baliusPort: "80"
113+
baliusDns: "balius-preview.balius.svc.cluster.local"
114+
defaultBaliusVersion: "v2"
115+
116+
podMonitor:
117+
enabled: false
118+
labels: {}
119+
120+
# Proxy Config
121+
tiers:
122+
- name: "0"
123+
rates:
124+
- interval: "1m"
125+
limitPerReplica: 1 # per second
126+
- interval: "1d"
127+
limitPerReplica: 80000
128+
- name: "1"
129+
rates:
130+
- interval: "1m"
131+
limitPerReplica: 5
132+
- interval: "1d"
133+
limitPerReplica: 400000
134+
- name: "2"
135+
rates:
136+
- interval: "1m"
137+
limitPerReplica: 40
138+
- interval: "1d"
139+
limitPerReplica: 2000000
140+
- name: "3"
141+
rates:
142+
- interval: "1m"
143+
limitPerReplica: 80
144+
- interval: "1d"
145+
limitPerReplica: 4000000
146+
147+
proxyCertificate:
148+
enabled: false
149+
secretName: balius-tls
150+
dnsNames:
151+
- "example.balius.example.com"
152+
- "*.example.balius.blinklabs.cloud"
153+
issuerKind: ClusterIssuer
154+
issuerName: letsencrypt-example-com
155+
156+
# Proxy service configuration LoadBalancer
157+
proxyService:
158+
enabled: false
159+
name: balius-proxy
160+
namespace: balius
161+
labels: {}
162+
# Google Cloud Load Balancer labels
163+
# cloud.google.com/load-balancer-type: Internal
164+
annotations: {}
165+
# Google Cloud Load Balancer annotations
166+
# cloud.google.com/l4-rbs: enabled
167+
# external-dns.alpha.kubernetes.io/hostname: proxy.balius.example.com
168+
spec:
169+
type: LoadBalancer
170+
ports:
171+
- name: proxy
172+
port: 443
173+
targetPort: 9090
174+
selector:
175+
role: balius-proxy
176+
177+
# Rely on external DNS to create the DNS records
178+
dnsEndpoint:
179+
enabled: false
180+
name: balius-cname-preview
181+
namespace: kube-system
182+
endpoints:
183+
- dnsName: my.balius.example.com
184+
recordType: CNAME
185+
targets:
186+
- proxy.balius.example.com
187+
providerSpecific: {}
188+
# Cloudflare specific annotation
189+
# - name: external-dns.alpha.kubernetes.io/cloudflare-proxied
190+
# value: "false"

0 commit comments

Comments
 (0)