Skip to content

Commit ff91854

Browse files
authored
Merge pull request #1 from codex-team/configuration-volumes
Implement first version
2 parents 4085bb8 + 8786c91 commit ff91854

10 files changed

Lines changed: 343 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.tgz

Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: codex-docs
3+
description: A Helm chart for CodeX Docs
4+
type: application
5+
version: 0.0.3
6+
appVersion: "v0.1.2"

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# codex.docs.chart
22
Helm chart for deploying CodeX Docs
3+
4+
## Running
5+
6+
Execute the following commands from the repository root folder:
7+
```
8+
helm install codex-docs ./ -n codex-docs --create-namespace
9+
```
10+
11+
You can proxy pod to http://localhost:3000
12+
```
13+
kubectl port-forward $(kubectl get pods -n codex-docs -o jsonpath="{.items[0].metadata.name}") 3000:3000 -n codex-docs
14+
```
15+
16+
For local deployment you can use minikube:
17+
```
18+
minikube service codex-docs -n codex-docs --url
19+
```

templates/_helpers.tpl

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 "codexdocs.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 "codexdocs.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 "codexdocs.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "codexdocs.labels" -}}
37+
helm.sh/chart: {{ include "codexdocs.chart" . }}
38+
{{ include "codexdocs.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 "codexdocs.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "codexdocs.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 "codexdocs.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "codexdocs.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

templates/configmap.yaml

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: {{ .Release.Name }}-config
5+
data:
6+
codexdocsrc: |-
7+
{{ .Values.configuration.codexdocsrc | toJson }}
8+
production.json: |-
9+
{{ .Values.configuration.production | toJson }}

templates/deployment.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "codexdocs.fullname" . }}
5+
labels:
6+
{{- include "codexdocs.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "codexdocs.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "codexdocs.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
securityContext:
28+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
29+
volumes:
30+
- name: config
31+
configMap:
32+
defaultMode: 420
33+
name: {{ .Release.Name }}-config
34+
- name: {{ include "codexdocs.fullname" . }}-db
35+
persistentVolumeClaim:
36+
claimName: {{ include "codexdocs.fullname" . }}-db
37+
- name: {{ include "codexdocs.fullname" . }}-uploads
38+
persistentVolumeClaim:
39+
claimName: {{ include "codexdocs.fullname" . }}-uploads
40+
containers:
41+
- name: {{ .Chart.Name }}
42+
securityContext:
43+
{{- toYaml .Values.securityContext | nindent 12 }}
44+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
45+
imagePullPolicy: {{ .Values.image.pullPolicy }}
46+
volumeMounts:
47+
- name: config
48+
mountPath: /usr/src/app/.codexdocsrc
49+
subPath: "codexdocsrc"
50+
- name: config
51+
mountPath: /usr/src/app/config/production.json
52+
subPath: "production.json"
53+
- name: {{ include "codexdocs.fullname" . }}-db
54+
mountPath: {{ .Values.configuration.production.database }}
55+
- name: {{ include "codexdocs.fullname" . }}-uploads
56+
mountPath: {{ .Values.configuration.production.uploads }}
57+
ports:
58+
- name: http
59+
containerPort: 3000
60+
protocol: TCP
61+
resources:
62+
{{- toYaml .Values.resources | nindent 12 }}
63+
{{- with .Values.nodeSelector }}
64+
nodeSelector:
65+
{{- toYaml . | nindent 8 }}
66+
{{- end }}
67+
{{- with .Values.affinity }}
68+
affinity:
69+
{{- toYaml . | nindent 8 }}
70+
{{- end }}
71+
{{- with .Values.tolerations }}
72+
tolerations:
73+
{{- toYaml . | nindent 8 }}
74+
{{- end }}

templates/ingress.yaml

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 "codexdocs.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 "codexdocs.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 }}

templates/service.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "codexdocs.fullname" . }}
5+
labels:
6+
{{- include "codexdocs.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "codexdocs.selectorLabels" . | nindent 4 }}

templates/volumes.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: {{ include "codexdocs.fullname" . }}-db
5+
labels:
6+
{{- include "codexdocs.labels" . | nindent 4 }}
7+
spec:
8+
accessModes:
9+
- ReadWriteOnce
10+
resources:
11+
requests:
12+
storage: 1Gi
13+
---
14+
apiVersion: v1
15+
kind: PersistentVolumeClaim
16+
metadata:
17+
name: {{ include "codexdocs.fullname" . }}-uploads
18+
labels:
19+
{{- include "codexdocs.labels" . | nindent 4 }}
20+
spec:
21+
accessModes:
22+
- ReadWriteOnce
23+
resources:
24+
requests:
25+
storage: 5Gi

values.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
replicaCount: 1
2+
3+
configuration:
4+
codexdocsrc:
5+
title: "CodeX Docs"
6+
description: "A block-styled editor with clean JSON output"
7+
landingFrameSrc: "https://codex.so/editor?frame=1"
8+
menu:
9+
- "Guides"
10+
- "API"
11+
- "Plugins"
12+
- title: "Support Project"
13+
uri: "/support"
14+
misprintsChatId:
15+
startPage:
16+
yandexMetrikaId:
17+
carbon:
18+
placement:
19+
serve:
20+
production:
21+
port: 3000
22+
database: "/mnt/db"
23+
rcFile: "./.codexdocsrc"
24+
"uploads": "/usr/src/app/public/uploads"
25+
"secret": "iamasecretstring"
26+
27+
image:
28+
repository: ghcr.io/codex-team/codex.docs
29+
pullPolicy: Always
30+
tag: ""
31+
32+
imagePullSecrets: []
33+
fullnameOverride: ""
34+
35+
podAnnotations: {}
36+
37+
podSecurityContext: {}
38+
39+
securityContext: {}
40+
41+
service:
42+
type: ClusterIP
43+
port: 3000
44+
45+
ingress:
46+
enabled: true
47+
className: ""
48+
annotations: {}
49+
hosts:
50+
- host: codex-docs.local
51+
paths:
52+
- path: /
53+
pathType: Prefix
54+
backend:
55+
service:
56+
name: web
57+
port:
58+
number: 3000
59+
tls: []
60+
61+
resources: {}
62+
63+
autoscaling:
64+
enabled: false
65+
minReplicas: 1
66+
maxReplicas: 100
67+
targetCPUUtilizationPercentage: 80
68+
69+
nodeSelector: {}
70+
71+
tolerations: []
72+
73+
affinity: {}

0 commit comments

Comments
 (0)