Skip to content

Commit 2acc824

Browse files
authored
Merge pull request #5 from ethpandaops/feat/chproxy
feat(charts/chproxy): init
2 parents 2fcc72c + b663d9f commit 2acc824

17 files changed

+758
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ helm search repo ethpandaops-general-helm-charts
2626
## List of charts
2727

2828
- [`cloudflare-tunnel`](charts/cloudflare-tunnel)
29+
- [`chproxy`](charts/chproxy)
30+
- [`raw-configmap`](charts/raw-configmap)
2931

3032
## Development
3133

charts/chproxy/.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/

charts/chproxy/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: chproxy
3+
description: HTTP proxy and load balancer for ClickHouse
4+
home: https://www.chproxy.org
5+
type: application
6+
version: 0.0.1
7+
maintainers:
8+
- name: savid
9+
email: andrew.davis@ethereum.org

charts/chproxy/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
# chproxy
3+
4+
![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)
5+
6+
HTTP proxy and load balancer for ClickHouse
7+
8+
**Homepage:** <https://www.chproxy.org>
9+
10+
## Values
11+
12+
| Key | Type | Default | Description |
13+
|-----|------|---------|-------------|
14+
| affinity | object | `{}` | Affinity configuration for pods |
15+
| annotations | object | `{}` | Annotations for the Deployment |
16+
| args | list | `[]` | Command arguments |
17+
| autoscaling.enabled | bool | `false` | Autoscaling configuration |
18+
| autoscaling.maxReplicas | int | `3` | Maximum number of replicas |
19+
| autoscaling.minReplicas | int | `2` | Minimum number of replicas |
20+
| autoscaling.targetCPUUtilizationPercentage | int | `85` | Target CPU utilization percentage |
21+
| config.clusters[0].name | string | `"default"` | |
22+
| config.clusters[0].nodes[0] | string | `"clickhouse:8123"` | |
23+
| config.clusters[0].scheme | string | `"http"` | |
24+
| config.clusters[0].users[0].name | string | `"default"` | |
25+
| config.hack_me_please | bool | `true` | |
26+
| config.log_debug | bool | `false` | |
27+
| config.server.http.listen_addr | string | `":8080"` | |
28+
| config.server.http.read_timeout | string | `"5m"` | |
29+
| config.server.proxy.enable | bool | `true` | |
30+
| config.server.proxy.header | string | `"CF-Connecting-IP"` | |
31+
| config.users[0].name | string | `"default"` | |
32+
| config.users[0].to_cluster | string | `"default"` | |
33+
| config.users[0].to_user | string | `"default"` | |
34+
| containerSecurityContext | object | See `values.yaml` | The security context for containers |
35+
| customArgs | list | `[]` | Custom args for the chproxy container |
36+
| customCommand | list | `[]` | Command replacement for the chproxy container |
37+
| extraContainers | list | `[]` | Additional containers |
38+
| extraEnv | list | `[]` | Additional env variables |
39+
| extraPodPorts | list | `[]` | Extra Pod ports |
40+
| extraPorts | list | `[]` | Additional ports. Useful when using extraContainers |
41+
| extraVolumeMounts | list | `[]` | Additional volume mounts |
42+
| extraVolumes | list | `[]` | Additional volumes |
43+
| fullnameOverride | string | `""` | Overrides the chart's computed fullname |
44+
| image.pullPolicy | string | `"IfNotPresent"` | chproxy container pull policy |
45+
| image.repository | string | `"contentsquareplatform/chproxy"` | chproxy container image repository |
46+
| image.tag | string | `"v1.26.5"` | chproxy container image tag |
47+
| imagePullSecrets | list | `[]` | Image pull secrets for Docker images |
48+
| ingress.http.annotations | object | `{}` | Annotations for Ingress |
49+
| ingress.http.enabled | bool | `false` | Ingress resource for the HTTP API |
50+
| ingress.http.hosts[0].host | string | `"chart-example.local"` | |
51+
| ingress.http.hosts[0].paths | list | `[]` | |
52+
| ingress.http.tls | list | `[]` | Ingress TLS |
53+
| initContainers | list | `[]` | Additional init containers |
54+
| lifecycle | object | See `values.yaml` | Lifecycle hooks |
55+
| livenessProbe | object | See `values.yaml` | Liveness probe |
56+
| nameOverride | string | `""` | Overrides the chart's name |
57+
| nodeSelector | object | `{}` | Node selector for pods |
58+
| podAnnotations | object | `{}` | Pod annotations |
59+
| podDisruptionBudget | object | `{}` | Define the PodDisruptionBudget spec If not set then a PodDisruptionBudget will not be created |
60+
| podLabels | object | `{}` | Pod labels |
61+
| priorityClassName | string | `nil` | Pod priority class |
62+
| readinessProbe | object | See `values.yaml` | Readiness probe |
63+
| replicas | int | `1` | Number of replicas |
64+
| resources | object | `{}` | Resource requests and limits |
65+
| secretEnv | object | `{}` | Secret env variables injected via a created secret |
66+
| securityContext | object | See `values.yaml` | The security context for pods |
67+
| service.type | string | `"ClusterIP"` | Service type |
68+
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
69+
| serviceAccount.create | bool | `false` | Specifies whether a service account should be created |
70+
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
71+
| serviceMonitor.annotations | object | `{}` | Additional ServiceMonitor annotations |
72+
| serviceMonitor.enabled | bool | `false` | If true, a ServiceMonitor CRD is created for a prometheus operator https://github.com/coreos/prometheus-operator |
73+
| serviceMonitor.interval | string | `"15s"` | ServiceMonitor scrape interval |
74+
| serviceMonitor.labels | object | `{}` | Additional ServiceMonitor labels |
75+
| serviceMonitor.namespace | string | `nil` | Alternative namespace for ServiceMonitor |
76+
| serviceMonitor.path | string | `"/metrics"` | Path to scrape |
77+
| serviceMonitor.relabelings | list | `[]` | ServiceMonitor relabelings |
78+
| serviceMonitor.scheme | string | `"http"` | ServiceMonitor scheme |
79+
| serviceMonitor.scrapeTimeout | string | `"30s"` | ServiceMonitor scrape timeout |
80+
| serviceMonitor.tlsConfig | object | `{}` | ServiceMonitor TLS configuration |
81+
| terminationGracePeriodSeconds | int | `90` | How long to wait until the pod is forcefully terminated |
82+
| tolerations | list | `[]` | Tolerations for pods |
83+
| topologySpreadConstraints | list | `[]` | Topology Spread Constraints for pods |

charts/chproxy/README.md.gotmpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{{ template "chart.header" . }}
3+
{{ template "chart.deprecationWarning" . }}
4+
5+
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}
6+
7+
{{ template "chart.description" . }}
8+
9+
{{ template "chart.homepageLine" . }}
10+
11+
{{ template "chart.sourcesSection" . }}
12+
13+
{{ template "chart.requirementsSection" . }}
14+
15+
{{ template "chart.valuesSection" . }}

charts/chproxy/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 "chproxy.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 "chproxy.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chproxy.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ include "chproxy.httpPort" . }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "chproxy.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 }}

charts/chproxy/templates/_helpers.tpl

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chproxy.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 "chproxy.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 "chproxy.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chproxy.labels" -}}
37+
helm.sh/chart: {{ include "chproxy.chart" . }}
38+
{{ include "chproxy.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 "chproxy.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chproxy.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 "chproxy.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chproxy.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{- define "chproxy.httpPort" -}}
65+
{{ (split ":" .Values.config.server.http.listen_addr)._1 | default "8080" }}
66+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "chproxy.fullname" . }}
5+
labels:
6+
{{- include "chproxy.labels" . | nindent 4 }}
7+
data:
8+
config.yaml: |-
9+
{{ toYaml .Values.config | nindent 4 }}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "chproxy.fullname" . }}
5+
labels:
6+
{{- include "chproxy.labels" . | nindent 4 }}
7+
annotations:
8+
{{- toYaml .Values.annotations | nindent 4 }}
9+
spec:
10+
replicas: {{ .Values.replicas }}
11+
selector:
12+
matchLabels:
13+
{{- include "chproxy.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "chproxy.selectorLabels" . | nindent 8 }}
18+
{{- with .Values.podLabels }}
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
annotations:
22+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
23+
checksum/secrets: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
24+
{{- with .Values.podAnnotations }}
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
spec:
28+
serviceAccountName: {{ include "chproxy.serviceAccountName" . }}
29+
{{- if .Values.priorityClassName }}
30+
priorityClassName: {{ .Values.priorityClassName }}
31+
{{- end }}
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 8 }}
34+
initContainers:
35+
{{- if .Values.initContainers }}
36+
{{- toYaml .Values.initContainers | nindent 8 }}
37+
{{- end }}
38+
{{- with .Values.imagePullSecrets }}
39+
imagePullSecrets:
40+
{{- toYaml . | nindent 8 }}
41+
{{- end }}
42+
containers:
43+
- name: {{ .Chart.Name }}
44+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
45+
imagePullPolicy: {{ .Values.image.pullPolicy }}
46+
command:
47+
{{- if gt (len .Values.customCommand) 0 }}
48+
{{- toYaml .Values.customCommand | nindent 12}}
49+
{{- else }}
50+
- /chproxy
51+
- --config
52+
- /config.yaml
53+
{{- if gt (len .Values.args) 0 }}
54+
{{- toYaml .Values.args | nindent 12}}
55+
{{- end }}
56+
{{- end }}
57+
{{- if gt (len .Values.customArgs) 0 }}
58+
args:
59+
{{- toYaml .Values.customArgs | nindent 12}}
60+
{{- end }}
61+
securityContext:
62+
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
63+
volumeMounts:
64+
- name: config
65+
mountPath: "/config.yaml"
66+
subPath: config.yaml
67+
readOnly: true
68+
{{- if .Values.extraVolumeMounts }}
69+
{{ toYaml .Values.extraVolumeMounts | nindent 10 }}
70+
{{- end }}
71+
ports:
72+
- name: http
73+
containerPort: {{ include "chproxy.httpPort" . }}
74+
protocol: TCP
75+
{{- if .Values.extraPodPorts }}
76+
{{ toYaml .Values.extraPodPorts | nindent 10 }}
77+
{{- end }}
78+
livenessProbe:
79+
{{- toYaml .Values.livenessProbe | nindent 12 }}
80+
readinessProbe:
81+
{{- toYaml .Values.readinessProbe | nindent 12 }}
82+
lifecycle:
83+
{{- toYaml .Values.lifecycle | nindent 12 }}
84+
resources:
85+
{{- toYaml .Values.resources | nindent 12 }}
86+
env:
87+
{{- range $key, $value := .Values.secretEnv }}
88+
- name: {{ $key }}
89+
valueFrom:
90+
secretKeyRef:
91+
name: {{ include "chproxy.fullname" $ }}-env
92+
key: {{ $key }}
93+
{{- end }}
94+
{{- if .Values.extraEnv }}
95+
{{- toYaml .Values.extraEnv | nindent 12 }}
96+
{{- end }}
97+
{{- if .Values.extraContainers }}
98+
{{ toYaml .Values.extraContainers | nindent 8}}
99+
{{- end }}
100+
nodeSelector:
101+
{{- toYaml .Values.nodeSelector | nindent 8 }}
102+
affinity:
103+
{{- toYaml .Values.affinity | nindent 8 }}
104+
tolerations:
105+
{{- toYaml .Values.tolerations | nindent 8 }}
106+
topologySpreadConstraints:
107+
{{- toYaml .Values.topologySpreadConstraints | nindent 8 }}
108+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
109+
volumes:
110+
{{- if .Values.extraVolumes }}
111+
{{ toYaml .Values.extraVolumes | nindent 8}}
112+
{{- end }}
113+
- name: config
114+
configMap:
115+
name: {{ include "chproxy.fullname" . }}

charts/chproxy/templates/hpa.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.autoscaling.enabled -}}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "chproxy.fullname" . }}
6+
labels:
7+
{{- include "chproxy.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "chproxy.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
- type: Resource
17+
resource:
18+
name: cpu
19+
target:
20+
type: Utilization
21+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
22+
{{- end }}

0 commit comments

Comments
 (0)