Skip to content

Commit 828b108

Browse files
authored
feat: add draft of k8s support (#92)
initial support for k8s
1 parent 0c12f37 commit 828b108

File tree

14 files changed

+540
-0
lines changed

14 files changed

+540
-0
lines changed

k8s/commit-boost/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

k8s/commit-boost/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
name: commit-boost
3+
description: A Helm chart for Kubernetes
4+
type: application
5+
version: 0.0.1
6+
appVersion: "v0.0.1-beta0"
7+
maintainers:
8+
- name: mxs
9+

k8s/commit-boost/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# commit-boost
2+
3+
![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.0.1-beta0](https://img.shields.io/badge/AppVersion-v0.0.1--beta0-informational?style=flat-square)
4+
5+
A Helm chart for Kubernetes
6+
7+
## Maintainers
8+
9+
| Name | Email | Url |
10+
| ---- | ------ | --- |
11+
| mxs | <[email protected]> | |
12+
13+
## Values
14+
15+
| Key | Type | Default | Description |
16+
|-----|------|---------|-------------|
17+
| affinity | object | `{}` | |
18+
| autoscaling.enabled | bool | `false` | |
19+
| autoscaling.maxReplicas | int | `100` | |
20+
| autoscaling.minReplicas | int | `1` | |
21+
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
22+
| commitBoost.pbs.config | string | `"chain = \"Holesky\"\n\n[pbs]\nport = 18550\n\n[[relays]]\nurl = \"https://0xafa4c6985aa049fb79dd37010438cfebeb0f2bd42b115b89dd678dab0670c1de38da0c4e9138c9290a398ecd9a0b3110@boost-relay-holesky.flashbots.net\"\n\n[metrics]\nprometheus_config = \"/config/prometheus.yaml\""` | |
23+
| commitBoost.pbs.enable | bool | `true` | |
24+
| fullnameOverride | string | `""` | |
25+
| image.pullPolicy | string | `"IfNotPresent"` | |
26+
| image.repository | string | `"ghcr.io/kilnfi/commit-boost-pbs"` | |
27+
| image.tag | string | `"55cdb"` | |
28+
| imagePullSecrets | list | `[]` | |
29+
| ingress.annotations | object | `{}` | |
30+
| ingress.className | string | `""` | |
31+
| ingress.enabled | bool | `false` | |
32+
| ingress.hosts[0].host | string | `"chart-example.local"` | |
33+
| ingress.hosts[0].paths[0].path | string | `"/"` | |
34+
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
35+
| ingress.tls | list | `[]` | |
36+
| nameOverride | string | `""` | |
37+
| nodeSelector | object | `{}` | |
38+
| podAnnotations | object | `{}` | |
39+
| podLabels | object | `{}` | |
40+
| podSecurityContext | object | `{}` | |
41+
| replicaCount | int | `1` | |
42+
| resources | object | `{}` | |
43+
| securityContext | object | `{}` | |
44+
| service.metrics_port | int | `10000` | |
45+
| service.port | int | `18550` | |
46+
| service.type | string | `"ClusterIP"` | |
47+
| serviceAccount.annotations | object | `{}` | |
48+
| serviceAccount.automount | bool | `true` | |
49+
| serviceAccount.create | bool | `true` | |
50+
| serviceAccount.name | string | `""` | |
51+
| tolerations | list | `[]` | |
52+
| volumeMounts | list | `[]` | |
53+
| volumes | list | `[]` | |
54+
55+
----------------------------------------------
56+
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)

k8s/commit-boost/notes.org

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* commit-boost config requires prometheus stuff
2+
* rolling duration for logs needs to be set to never
3+
* metrics server?

k8s/commit-boost/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "commit-boost.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "commit-boost.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "commit-boost.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "commit-boost.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "commit-boost.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "commit-boost.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "commit-boost.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "commit-boost.labels" -}}
37+
helm.sh/chart: {{ include "commit-boost.chart" . }}
38+
{{ include "commit-boost.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "commit-boost.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "commit-boost.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "commit-boost.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "commit-boost.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "commit-boost.fullname" . }}
5+
labels:
6+
{{- include "commit-boost.labels" . | nindent 4 }}
7+
data:
8+
{{- if .Values.commitBoost.pbs.enable }}
9+
config.pbs.toml: |-
10+
{{ .Values.commitBoost.pbs.config | nindent 4 }}
11+
{{- end }}
12+
13+
prometheus.yaml: ""
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "commit-boost.fullname" . }}
5+
labels:
6+
{{- include "commit-boost.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "commit-boost.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "commit-boost.labels" . | nindent 8 }}
22+
{{- with .Values.podLabels }}
23+
{{- toYaml . | nindent 8 }}
24+
{{- end }}
25+
spec:
26+
{{- with .Values.imagePullSecrets }}
27+
imagePullSecrets:
28+
{{- toYaml . | nindent 8 }}
29+
{{- end }}
30+
serviceAccountName: {{ include "commit-boost.serviceAccountName" . }}
31+
securityContext:
32+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
33+
containers:
34+
{{- if .Values.commitBoost.pbs.enable }}
35+
- name: {{ .Chart.Name }}-pbs
36+
securityContext:
37+
{{- toYaml .Values.securityContext | nindent 12 }}
38+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
39+
imagePullPolicy: {{ .Values.image.pullPolicy }}
40+
ports:
41+
- name: http-pbs
42+
containerPort: {{ .Values.service.port }}
43+
protocol: TCP
44+
- name: http-metrics
45+
containerPort: {{ .Values.service.metrics_port }}
46+
protocol: TCP
47+
livenessProbe:
48+
httpGet:
49+
path: /status
50+
port: http-metrics
51+
readinessProbe:
52+
httpGet:
53+
path: /status
54+
port: http-metrics
55+
resources:
56+
{{- toYaml .Values.resources | nindent 12 }}
57+
env:
58+
- name: CB_CONFIG
59+
value: /config/config.pbs.toml
60+
- name: ROLLING_DURATION
61+
value: never
62+
- name: METRICS_SERVER
63+
value: '{{ .Values.service.metrics_port }}'
64+
- name: RUST_LOG
65+
value: info
66+
volumeMounts:
67+
- name: commit-boost-configs
68+
mountPath: /config
69+
{{- with .Values.volumeMounts }}
70+
{{- toYaml . | nindent 12 }}
71+
{{- end }}
72+
{{- end }}
73+
volumes:
74+
- name: commit-boost-configs
75+
configMap:
76+
defaultMode: 0755
77+
name: {{ include "commit-boost.fullname" . }}
78+
items:
79+
- key: prometheus.yaml
80+
path: prometheus.yaml
81+
{{- if .Values.commitBoost.pbs.enable }}
82+
- key: config.pbs.toml
83+
path: config.pbs.toml
84+
{{- end }}
85+
{{- with .Values.volumes }}
86+
{{- toYaml . | nindent 8 }}
87+
{{- end }}
88+
{{- with .Values.nodeSelector }}
89+
nodeSelector:
90+
{{- toYaml . | nindent 8 }}
91+
{{- end }}
92+
{{- with .Values.affinity }}
93+
affinity:
94+
{{- toYaml . | nindent 8 }}
95+
{{- end }}
96+
{{- with .Values.tolerations }}
97+
tolerations:
98+
{{- toYaml . | nindent 8 }}
99+
{{- end }}

k8s/commit-boost/templates/hpa.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "commit-boost.fullname" . }}
6+
labels:
7+
{{- include "commit-boost.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "commit-boost.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "commit-boost.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
5+
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
6+
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
7+
{{- end }}
8+
{{- end }}
9+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
10+
apiVersion: networking.k8s.io/v1
11+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
12+
apiVersion: networking.k8s.io/v1beta1
13+
{{- else -}}
14+
apiVersion: extensions/v1beta1
15+
{{- end }}
16+
kind: Ingress
17+
metadata:
18+
name: {{ $fullName }}
19+
labels:
20+
{{- include "commit-boost.labels" . | nindent 4 }}
21+
{{- with .Values.ingress.annotations }}
22+
annotations:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
spec:
26+
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
27+
ingressClassName: {{ .Values.ingress.className }}
28+
{{- end }}
29+
{{- if .Values.ingress.tls }}
30+
tls:
31+
{{- range .Values.ingress.tls }}
32+
- hosts:
33+
{{- range .hosts }}
34+
- {{ . | quote }}
35+
{{- end }}
36+
secretName: {{ .secretName }}
37+
{{- end }}
38+
{{- end }}
39+
rules:
40+
{{- range .Values.ingress.hosts }}
41+
- host: {{ .host | quote }}
42+
http:
43+
paths:
44+
{{- range .paths }}
45+
- path: {{ .path }}
46+
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
47+
pathType: {{ .pathType }}
48+
{{- end }}
49+
backend:
50+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
51+
service:
52+
name: {{ $fullName }}
53+
port:
54+
number: {{ $svcPort }}
55+
{{- else }}
56+
serviceName: {{ $fullName }}
57+
servicePort: {{ $svcPort }}
58+
{{- end }}
59+
{{- end }}
60+
{{- end }}
61+
{{- end }}

0 commit comments

Comments
 (0)