Skip to content

Commit 4439bee

Browse files
committed
feat: add helm chart
Signed-off-by: Andre Nogueira <andre.nogueira@mollie.com>
1 parent 8060ade commit 4439bee

File tree

14 files changed

+1235
-0
lines changed

14 files changed

+1235
-0
lines changed

kubernetes/chart/.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/

kubernetes/chart/Chart.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v2
2+
type: application
3+
name: sourcebot
4+
version: 0.1.0
5+
appVersion: ""
6+
description: The open source Sourcegraph alternative. Sourcebot gives you a powerful interface to search though all your repos and branches across multiple code hosts.
7+
icon: https://raw.githubusercontent.com/sourcebot-dev/sourcebot/ebf6721836b8f878d42bb8c1e844bdc7867a74fe/packages/web/public/logo_512.png
8+
keywords:
9+
- code-search
10+
- code-intelligence
11+
- sourcebot
12+
home: https://sourcebot.dev/
13+
sources:
14+
- https://github.com/sourcebot-dev/sourcebot
15+
- https://github.com/sourcebot-dev/sourcebot/kubernetes/chart

kubernetes/chart/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# sourcebot
2+
3+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
4+
5+
The open source Sourcegraph alternative. Sourcebot gives you a powerful interface to search though all your repos and branches across multiple code hosts.
6+
7+
**Homepage:** <https://sourcebot.dev/>
8+
9+
## Source Code
10+
11+
* <https://github.com/sourcebot-dev/sourcebot>
12+
* <https://github.com/sourcebot-dev/sourcebot/kubernetes/chart>
13+
14+
## Values
15+
16+
| Key | Type | Default | Description |
17+
|-----|------|---------|-------------|
18+
| additionalLabels | object | `{}` | Add extra labels to all resources. |
19+
| affinity | object | `{}` | Set affinity rules for pod scheduling. Defaults to soft anti-affinity if not set. See: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ |
20+
| args | list | `[]` | Override the default arguments of the container. |
21+
| autoscaling | object | `{"enabled":false,"maxReplicas":3,"minReplicas":1,"targetCPUUtilizationPercentage":80,"targetMemoryUtilizationPercentage":80}` | Configure Horizontal Pod Autoscaler. |
22+
| autoscaling.enabled | bool | `false` | Enable or disable Horizontal Pod Autoscaler. |
23+
| autoscaling.maxReplicas | int | `3` | Maximum number of replicas. |
24+
| autoscaling.minReplicas | int | `1` | Minimum number of replicas. |
25+
| autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization percentage for autoscaling. |
26+
| autoscaling.targetMemoryUtilizationPercentage | int | `80` | Target memory utilization percentage for autoscaling. |
27+
| command | list | `[]` | Override the default command of the container. |
28+
| config | object | `{"$schema":"https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json","connections":{},"settings":{}}` | Configure Sourcebot-specific application settings. |
29+
| containerSecurityContext | object | `{}` | Set the container-level security context. |
30+
| database | object | `{}` | Configure the database secret. |
31+
| envSecrets | list | `[]` | Set environment variables from Kubernetes secrets. |
32+
| envs | list | `[]` | Set additional environment variables. |
33+
| fullnameOverride | string | `""` | Override the full name of the chart. |
34+
| image | object | `{"pullPolicy":"Always","repository":"ghcr.io/sourcebot-dev/sourcebot","tag":"latest"}` | Configure the container image. |
35+
| image.pullPolicy | string | `"Always"` | Image pull policy. |
36+
| image.repository | string | `"ghcr.io/sourcebot-dev/sourcebot"` | Container image repository. |
37+
| image.tag | string | `"latest"` | Container image tag. |
38+
| imagePullSecrets | list | `[]` | Configure image pull secrets for private registries. |
39+
| ingress | object | `{"annotations":{},"className":"","enabled":false,"hosts":[],"tls":[]}` | Configure ingress for Sourcebot. |
40+
| ingress.annotations | object | `{}` | Ingress annotations. |
41+
| ingress.className | string | `""` | Ingress class name. |
42+
| ingress.enabled | bool | `false` | Enable or disable ingress. |
43+
| ingress.hosts | list | `[]` | List of hostnames and paths for ingress rules. |
44+
| ingress.tls | list | `[]` | TLS settings for ingress. |
45+
| initContainers | list | `[]` | Configure init containers to run before the main container. |
46+
| license | object | `{}` | Configure the enterprise license key secret. |
47+
| livenessProbe | object | `{"failureThreshold":5,"httpGet":{"path":"/","port":"http"},"initialDelaySeconds":10,"periodSeconds":10}` | Liveness probe to check if the container is alive. |
48+
| livenessProbe.failureThreshold | int | `5` | Number of consecutive failures before marking the container as unhealthy. |
49+
| livenessProbe.httpGet | object | `{"path":"/","port":"http"}` | Http GET request to check if the container is alive. |
50+
| livenessProbe.httpGet.path | string | `"/"` | Path to check. |
51+
| livenessProbe.httpGet.port | string | `"http"` | Port to check. |
52+
| livenessProbe.initialDelaySeconds | int | `10` | Initial delay before the first probe. |
53+
| livenessProbe.periodSeconds | int | `10` | Frequency of the probe. |
54+
| nameOverride | string | `""` | Override the name of the chart. |
55+
| nodeSelector | object | `{}` | Set node selector constraints. See: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector |
56+
| podAnnotations | object | `{}` | Add annotations to the pod metadata. |
57+
| podDisruptionBudget | object | `{"enabled":true,"maxUnavailable":1,"minAvailable":1}` | Configure Pod Disruption Budget. |
58+
| podDisruptionBudget.enabled | bool | `true` | Enable Pod Disruption Budget. |
59+
| podDisruptionBudget.maxUnavailable | int | `1` | Maximum number of pods that can be unavailable. |
60+
| podDisruptionBudget.minAvailable | int | `1` | Minimum number of pods that must be available. |
61+
| podSecurityContext | object | `{}` | Set the pod-level security context. |
62+
| priorityClassName | string | `""` | Set the priority class name for pods. See: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/ |
63+
| readinessProbe | object | `{"failureThreshold":5,"httpGet":{"path":"/","port":"http"},"initialDelaySeconds":10,"periodSeconds":10}` | Readiness probe to check if the container is ready to serve traffic. |
64+
| readinessProbe.failureThreshold | int | `5` | Number of consecutive failures before marking the container as not ready. |
65+
| readinessProbe.httpGet | object | `{"path":"/","port":"http"}` | Http GET request to check if the container is ready. |
66+
| readinessProbe.httpGet.path | string | `"/"` | Path to check. |
67+
| readinessProbe.httpGet.port | string | `"http"` | Port to check. |
68+
| readinessProbe.initialDelaySeconds | int | `10` | Initial delay before the first probe. |
69+
| readinessProbe.periodSeconds | int | `10` | Frequency of the probe. |
70+
| redis | object | `{}` | Configure the Redis secret. |
71+
| replicaCount | int | `1` | Set the number of replicas for the deployment. |
72+
| resources | object | `{}` | Configure resource requests and limits for the container. |
73+
| service | object | `{"annotations":{},"containerPort":3000,"port":3000,"type":"ClusterIP"}` | Configure the Sourcebot Kubernetes service. |
74+
| service.annotations | object | `{}` | Service annotations. |
75+
| service.containerPort | int | `3000` | Internal container port. |
76+
| service.port | int | `3000` | External service port. |
77+
| service.type | string | `"ClusterIP"` | Type of the Kubernetes service (e.g., ClusterIP, NodePort, LoadBalancer). |
78+
| serviceAccount | object | `{"annotations":{},"automount":false,"create":true,"name":""}` | Configure the ServiceAccount. |
79+
| serviceAccount.annotations | object | `{}` | Add annotations to the ServiceAccount. |
80+
| serviceAccount.automount | bool | `false` | Enable or disable automatic ServiceAccount mounting. |
81+
| serviceAccount.create | bool | `true` | Create a new ServiceAccount. |
82+
| serviceAccount.name | string | `""` | Use an existing ServiceAccount (if set). |
83+
| startupProbe | object | `{"failureThreshold":30,"httpGet":{"path":"/","port":"http"},"periodSeconds":30}` | Startup probe to check if the container has started successfully. |
84+
| startupProbe.failureThreshold | int | `30` | Number of seconds to wait before starting the probe. |
85+
| startupProbe.httpGet | object | `{"path":"/","port":"http"}` | Http GET request to check if the container has started. |
86+
| startupProbe.httpGet.path | string | `"/"` | Path to check. |
87+
| startupProbe.httpGet.port | string | `"http"` | Port to check. |
88+
| startupProbe.periodSeconds | int | `30` | Initial delay before the first probe. |
89+
| tolerations | list | `[]` | Set tolerations for pod scheduling. See: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ |
90+
| volumeMounts | list | `[]` | Define volume mounts for the container. |
91+
| volumes | list | `[]` | Define additional volumes. |
92+

kubernetes/chart/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 "sourcebot.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 its status by running 'kubectl get --namespace {{ $.Release.Namespace }} svc -w {{ include "sourcebot.fullname" $ }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ $.Release.Namespace }} {{ include "sourcebot.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 "sourcebot.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:3000 to use Sourcebot after forwarding"
21+
kubectl --namespace {{ $.Release.Namespace }} port-forward $POD_NAME 3000:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "sourcebot.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 "sourcebot.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 "sourcebot.chart" -}}
30+
{{- printf "%s-%s" $.Chart.Name $.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "sourcebot.labels" -}}
37+
helm.sh/chart: {{ include "sourcebot.chart" $ }}
38+
{{ include "sourcebot.selectorLabels" $ }}
39+
{{- if $.Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ $.Release.Service }}
43+
{{- with $.Values.additionalLabels }}
44+
{{ toYaml . }}
45+
{{- end }}
46+
{{- end }}
47+
48+
{{/*
49+
Selector labels
50+
*/}}
51+
{{- define "sourcebot.selectorLabels" -}}
52+
app.kubernetes.io/name: {{ include "sourcebot.name" $ }}
53+
app.kubernetes.io/instance: {{ $.Release.Name }}
54+
{{- end }}
55+
56+
{{/*
57+
Create the image to use for the container.
58+
*/}}
59+
{{- define "sourcebot.image" -}}
60+
{{- if $.Values.image.digest -}}
61+
"{{ $.Values.image.repository }}@{{ $.Values.image.digest }}"
62+
{{- else if $.Values.image.tag -}}
63+
"{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
64+
{{- else -}}
65+
"{{ $.Values.image.repository }}:{{ $.Chart.AppVersion }}"
66+
{{- end -}}
67+
{{- end }}
68+
69+
{{/*
70+
Create the name of the service account to use
71+
*/}}
72+
{{- define "sourcebot.serviceAccountName" -}}
73+
{{- if $.Values.serviceAccount.create }}
74+
{{- default (include "sourcebot.fullname" $) $.Values.serviceAccount.name }}
75+
{{- else }}
76+
{{- default "default" $.Values.serviceAccount.name }}
77+
{{- end }}
78+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ include "sourcebot.fullname" $ }}
6+
labels:
7+
{{- include "sourcebot.labels" $ | nindent 4 }}
8+
data:
9+
config.json: |
10+
{{- toJson $.Values.config | nindent 4 }}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "sourcebot.fullname" $ }}
6+
labels:
7+
{{- include "sourcebot.labels" $ | nindent 4 }}
8+
spec:
9+
{{- if not $.Values.autoscaling.enabled }}
10+
replicas: {{ $.Values.replicaCount }}
11+
{{- end }}
12+
selector:
13+
matchLabels:
14+
{{- include "sourcebot.selectorLabels" $ | nindent 6 }}
15+
template:
16+
metadata:
17+
{{- with $.Values.podAnnotations }}
18+
annotations:
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
labels:
22+
{{- include "sourcebot.labels" $ | nindent 8 }}
23+
{{- with $.Values.podLabels }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
spec:
27+
{{- with $.Values.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
serviceAccountName: {{ include "sourcebot.serviceAccountName" $ }}
32+
{{- with $.Values.podSecurityContext }}
33+
securityContext:
34+
{{- toYaml . | nindent 8 }}
35+
{{- end }}
36+
containers:
37+
- name: {{ .Chart.Name }}
38+
{{- with $.Values.containerSecurityContext }}
39+
securityContext:
40+
{{- toYaml . | nindent 12 }}
41+
{{- end }}
42+
image: {{ include "sourcebot.image" $ }}
43+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
44+
{{- with $.Values.command }}
45+
command: {{ toYaml . | nindent 12 }}
46+
{{- end }}
47+
{{- with $.Values.args }}
48+
args: {{ toYaml . | nindent 12 }}
49+
{{- end }}
50+
env:
51+
- name: CONFIG_PATH
52+
value: /etc/sourcebot/config.json
53+
{{- if $.Values.license }}
54+
- name: SOURCEBOT_EE_LICENSE_KEY
55+
valueFrom:
56+
secretKeyRef:
57+
name: {{ $.Values.license.secretName }}
58+
key: {{ $.Values.license.secretKey }}
59+
{{- end }}
60+
{{- if $.Values.database }}
61+
- name: DATABASE_URL
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ $.Values.database.secretName }}
65+
key: {{ $.Values.database.secretKey }}
66+
{{- end }}
67+
{{- if $.Values.redis }}
68+
- name: REDIS_URL
69+
valueFrom:
70+
secretKeyRef:
71+
name: {{ $.Values.redis.secretName }}
72+
key: {{ $.Values.redis.secretKey }}
73+
{{- end }}
74+
{{- range $.Values.envSecrets }}
75+
- name: {{ .envName }}
76+
valueFrom:
77+
secretKeyRef:
78+
name: {{ .secretName }}
79+
key: {{ .secretKey }}
80+
{{- end }}
81+
{{- with $.Values.envs }}
82+
{{- toYaml . | nindent 12 }}
83+
{{- end }}
84+
ports:
85+
- name: http
86+
containerPort: {{ $.Values.service.containerPort }}
87+
protocol: TCP
88+
{{- with $.Values.livenessProbe }}
89+
livenessProbe:
90+
{{- toYaml . | nindent 12 }}
91+
{{- end }}
92+
{{- with $.Values.readinessProbe }}
93+
readinessProbe:
94+
{{- toYaml . | nindent 12 }}
95+
{{- end }}
96+
{{- with $.Values.startupProbe }}
97+
startupProbe:
98+
{{- toYaml . | nindent 12 }}
99+
{{- end }}
100+
{{- with $.Values.resources }}
101+
resources:
102+
{{- toYaml . | nindent 12 }}
103+
{{- end }}
104+
volumeMounts:
105+
- name: sourcebot-config
106+
mountPath: /etc/sourcebot/config.json
107+
subPath: config.json
108+
readOnly: true
109+
{{- with $.Values.volumeMounts }}
110+
{{- toYaml . | nindent 12 }}
111+
{{- end }}
112+
{{- with $.Values.priorityClassName }}
113+
priorityClassName: {{ . }}
114+
{{- end }}
115+
volumes:
116+
- name: sourcebot-config
117+
configMap:
118+
name: {{ include "sourcebot.fullname" $ }}
119+
items:
120+
- key: config.json
121+
path: config.json
122+
{{- with $.Values.volumes }}
123+
{{- toYaml . | nindent 8 }}
124+
{{- end }}
125+
{{- with $.Values.nodeSelector }}
126+
nodeSelector:
127+
{{- toYaml . | nindent 8 }}
128+
{{- end }}
129+
{{- with $.Values.affinity }}
130+
affinity:
131+
{{- toYaml . | nindent 8 }}
132+
{{- end }}
133+
{{- with $.Values.tolerations }}
134+
tolerations:
135+
{{- toYaml . | nindent 8 }}
136+
{{- end }}

0 commit comments

Comments
 (0)