Skip to content

Commit bfcf723

Browse files
Jonathan BeltranJonathan Beltran
Jonathan Beltran
authored and
Jonathan Beltran
committed
[Phoenix] Database and Phoenix deployment
1 parent ccb9d1d commit bfcf723

File tree

7 files changed

+189
-1
lines changed

7 files changed

+189
-1
lines changed

helm/templates/_helpers.tpl

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{{/*
2+
Truncate at 63 chars, kuberneteres DNS name limitation.
3+
*/}}
4+
{{- define "phoenix.name" -}}
5+
{{- default "phoenix" .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
6+
{{- end -}}
7+
8+
9+
{{- define "phoenix.fullname" -}}
10+
{{- if .Values.fullnameOverride }}
11+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
12+
{{- else }}
13+
{{- $name := default "phoenix" .Values.nameOverride }}
14+
{{- if contains $name .Release.Name }}
15+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
18+
{{- end }}
19+
{{- end }}
20+
{{- end }}
21+
22+
23+
{{- define "phoenix.postgres" -}}
24+
{{- printf "%s-postgres" (include "phoenix.fullname" .) -}}
25+
{{- end -}}
26+
{{- define "phoenix.postgres-pvc" -}}
27+
{{- printf "%s-pvc" (include "phoenix.postgres" .) -}}
28+
{{- end -}}
29+
{{- define "phoenix.service" -}}
30+
{{- printf "%s-svc" (include "phoenix.fullname" .) -}}
31+
{{- end -}}
32+
{{- define "phoenix.ingress" -}}
33+
{{- printf "%s-ingress" (include "phoenix.fullname" .) -}}
34+
{{- end -}}
35+
36+
37+
{{- define "phoenix.tlsCoreSecretForIngress" -}}
38+
{{- if eq .Values.ingress.tls.certSource "none" -}}
39+
{{- printf "" -}}
40+
{{- else if eq .Values.ingress.tls.certSource "secret" -}}
41+
{{- .Values.ingress.tls.secret.secretName -}}
42+
{{- else -}}
43+
{{- include "phoenix.ingress" . -}}
44+
{{- end -}}
45+
{{- end -}}
46+
47+
48+
49+
50+
{{- define "phoenix.appPortName" -}}
51+
{{- printf "%s-app" (include "phoenix.fullname" .) -}}
52+
{{- end -}}
53+
{{- define "phoenix.appPort" -}}
54+
{{- .Values.server.port | default 6006 }}
55+
{{- end -}}
56+
{{- define "phoenix.metricsPortName" -}}
57+
{{- printf "%s-metrics" (include "phoenix.fullname" .) -}}
58+
{{- end -}}
59+
{{- define "phoenix.metricsPort" -}}
60+
{{- printf "9090" -}}
61+
{{- end -}}
62+
{{- define "phoenix.grpcPortName" -}}
63+
{{- printf "%s-grpc" (include "phoenix.fullname" .) -}}
64+
{{- end -}}
65+
{{- define "phoenix.grpcPort" -}}
66+
{{- .Values.server.grpcPort | default 4317 }}
67+
{{- end -}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "phoenix.postgres" . }}
5+
labels:
6+
app: postgres
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: postgres
12+
template:
13+
metadata:
14+
labels:
15+
app: postgres
16+
spec:
17+
containers:
18+
- name: postgres
19+
image: {{ .Values.postgres.image }}
20+
ports:
21+
- containerPort: {{ .Values.database.port }}
22+
name: postgres
23+
env:
24+
- name: POSTGRES_DB
25+
value: {{ .Values.database.db }}
26+
- name: POSTGRES_USER
27+
value: {{ .Values.database.user }}
28+
- name: POSTGRES_PASSWORD
29+
value: {{ .Values.database.password }}
30+
resources: {{ toYaml .Values.postgres.resources | nindent 10 }}
31+
volumeMounts:
32+
- name: postgres-data
33+
mountPath: /var/lib/postgresql/data
34+
subPath: postgres
35+
volumes:
36+
- name: postgres-data
37+
persistentVolumeClaim:
38+
claimName: {{ template "phoenix.postgres-pvc" . }}
File renamed without changes.

helm/templates/phoenix/ingress.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{- if .Values.ingress.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: "{{ template "phoenix.ingress" . }}"
6+
namespace: {{ .Release.Namespace | quote }}
7+
{{- if .Values.ingress.labels }}
8+
labels:
9+
{{ toYaml .Values.ingress.labels | indent 4 }}
10+
{{- end }}
11+
{{- if .Values.ingress.annotations}}
12+
annotations:
13+
{{ toYaml .Values.ingress.annotations | indent 4 }}
14+
{{- end }}
15+
spec:
16+
{{- if .Values.ingress.className }}
17+
ingressClassName: {{ .Values.ingress.className }}
18+
{{- end }}
19+
{{- if .Values.ingress.tls.enabled }}
20+
tls:
21+
- secretName: {{ template "phoenix.tlsCoreSecretForIngress" . }}
22+
{{- if .Values.ingress.host }}
23+
hosts:
24+
- {{ .Values.ingress.host }}
25+
{{- end }}
26+
{{- end }}
27+
rules:
28+
- http:
29+
paths:
30+
- path: {{ .api_path }}
31+
pathType: {{ .path_type }}
32+
backend:
33+
service:
34+
name: {{ template "phoenix.service" . }}
35+
port:
36+
number: {{ template "phoenix.appPort" . }}
37+
{{- if .Values.ingress.host }}
38+
host: {{ .Values.ingress.host }}
39+
{{- end }}
40+
{{- end }}

helm/templates/phoenix/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: {{ template "phoenix.service" . }}
5+
namespace: {{ .Release.Namespace | quote }}
6+
spec:
7+
ports:
8+
- name: {{ template "phoenix.grpcPortName" . }}
9+
port: {{ template "phoenix.grpcPort" . }}
10+
- name: {{ template "phoenix.appPortName" . }}
11+
port: {{ template "phoenix.appPort" . }}
12+
- name: {{ template "phoenix.metricsPortName" . }}
13+
port: {{ template "phoenix.metricsPort" . }}
14+
selector:
15+
component: {{ .Release.Name }}

helm/values.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22
# This file contains configuration values for deploying Phoenix via Helm.
33
# Each value corresponds to an environment variable in src/phoenix/config.py.
44

5+
6+
# ADDONS
7+
# - Ingress
8+
# - Postgres
9+
ingress:
10+
# create ingress to expose phoenix server
11+
enabled: true
12+
tls:
13+
enabled: false
14+
host: phoenix.192.168.49.2.nip.io
15+
16+
postgres:
17+
# create postgres deployment for in-cluster use
18+
enabled: false
19+
image: postgres:14.5
20+
resources:
21+
requests:
22+
memory: "256Mi"
23+
cpu: "100m"
24+
limits:
25+
memory: "512Mi"
26+
cpu: "500m"
27+
persistence:
28+
enabled: true
29+
storageClass: "standard" # Minikube's default storage class
30+
size: 1Gi
31+
532
server:
633
# The host the server will run on
734
host: "0.0.0.0" # PHOENIX_HOST
@@ -16,7 +43,8 @@ server:
1643
# The root URL used to access Phoenix from a web browser
1744
rootUrl: "" # PHOENIX_ROOT_URL
1845
# Enable Prometheus metrics
19-
enablePrometheus: false # PHOENIX_ENABLE_PROMETHEUS
46+
enablePrometheus: false # PHOENIX_ENABLE_PROMETHEUS
47+
2048

2149
# Database configuration
2250
# You can use either a full SQL database URL or individual Postgres settings

0 commit comments

Comments
 (0)