Skip to content

Commit 0df96e6

Browse files
committed
create k8s manifests
1 parent 28d1266 commit 0df96e6

14 files changed

+427
-84
lines changed

k8s/Chart.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
name: nginx-helm-chart
2-
description: A generated Helm Chart for nginx-helm-chart from Skippbox Kompose
3-
version: 0.0.2
1+
name: balancer
2+
description: The helm chart for the balancer project
3+
version: 0.1.0
44
apiVersion: v2
5-
keywords:
6-
- nginx-helm-chart
75
sources:
86
- https://github.com/CodeForPhilly/balancer-main
97
home: https://opencollective.com/code-for-philly/projects/balancer

k8s/templates/_helpers.tpl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "balancer.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 "balancer.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 "balancer.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "balancer.labels" -}}
37+
helm.sh/chart: {{ include "balancer.chart" . }}
38+
{{ include "balancer.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 "balancer.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "balancer.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}

k8s/templates/backend

Whitespace-only changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}-backend
5+
labels:
6+
{{- include "balancer.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: backend
8+
spec:
9+
replicas: {{ .Values.backend.replicaCount | default 1 }}
10+
selector:
11+
matchLabels:
12+
{{- include "balancer.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: backend
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "balancer.selectorLabels" . | nindent 8 }}
18+
app.kubernetes.io/component: backend
19+
spec:
20+
containers:
21+
- name: backend
22+
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag | default .Chart.AppVersion }}"
23+
imagePullPolicy: {{ .Values.backend.image.pullPolicy | default "IfNotPresent" }}
24+
ports:
25+
- name: http
26+
containerPort: 8000
27+
protocol: TCP
28+
env:
29+
- name: SECRET_KEY
30+
valueFrom:
31+
secretKeyRef:
32+
name: {{ .Release.Name }}-balancer-secrets
33+
key: secret-key
34+
- name: DEBUG
35+
value: {{ .Values.backend.config.debug | default "1" | quote }}
36+
- name: SQL_USER
37+
value: {{ .Values.database.user | default "balancer" | quote }}
38+
- name: VITE_API_BASE_URL
39+
value: {{ .Values.backend.config.apiBaseUrl | default "https://balancertestsite.com/" | quote }}
40+
- name: DJANGO_ALLOWED_HOSTS
41+
value: {{ .Values.backend.config.allowedHosts | default "*" | quote }}
42+
- name: DATABASE
43+
value: {{ .Values.database.type | default "postgres" | quote }}
44+
- name: EMAIL_HOST_PASSWORD
45+
valueFrom:
46+
secretKeyRef:
47+
name: {{ .Release.Name }}-balancer-secrets
48+
key: email-password
49+
- name: SQL_ENGINE
50+
value: {{ .Values.database.engine | default "django.db.backends.postgresql" | quote }}
51+
- name: SQL_PORT
52+
value: {{ .Values.database.port | default "5432" | quote }}
53+
- name: EMAIL_HOST_USER
54+
value: {{ .Values.email.hostUser | default "[email protected]" | quote }}
55+
- name: SQL_DATABASE
56+
value: {{ .Values.database.name | default "balancer_dev" | quote }}
57+
- name: SQL_PASSWORD
58+
valueFrom:
59+
secretKeyRef:
60+
name: {{ .Release.Name }}-balancer-secrets
61+
key: database-password
62+
- name: OPENAI_API_KEY
63+
valueFrom:
64+
secretKeyRef:
65+
name: {{ .Release.Name }}-balancer-secrets
66+
key: openai-api-key
67+
- name: SQL_HOST
68+
value: {{ .Values.database.host | quote }}
69+
resources:
70+
requests:
71+
cpu: {{ .Values.backend.resources.requests.cpu | default "500m" }}
72+
memory: {{ .Values.backend.resources.requests.memory | default "1Gi" }}
73+
limits:
74+
cpu: {{ .Values.backend.resources.limits.cpu | default "1024m" }}
75+
memory: {{ .Values.backend.resources.limits.memory | default "3Gi" }}

k8s/templates/deployment.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}-balancer
5+
labels:
6+
{{- include "balancer.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount | default 1 }}
9+
selector:
10+
matchLabels:
11+
{{- include "balancer.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
labels:
15+
{{- include "balancer.selectorLabels" . | nindent 8 }}
16+
spec:
17+
containers:
18+
- name: balancer
19+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
20+
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
21+
ports:
22+
- name: http
23+
containerPort: 8000
24+
protocol: TCP
25+
env:
26+
- name: SECRET_KEY
27+
valueFrom:
28+
secretKeyRef:
29+
name: {{ .Release.Name }}-secrets
30+
key: secret-key
31+
- name: DEBUG
32+
value: {{ .Values.config.debug | default "1" | quote }}
33+
- name: SQL_USER
34+
value: {{ .Values.database.user | default "balancer" | quote }}
35+
- name: VITE_API_BASE_URL
36+
value: {{ .Values.config.apiBaseUrl | default "https://balancertestsite.com/" | quote }}
37+
- name: DJANGO_ALLOWED_HOSTS
38+
value: {{ .Values.config.allowedHosts | default "*" | quote }}
39+
- name: DATABASE
40+
value: {{ .Values.database.type | default "postgres" | quote }}
41+
- name: EMAIL_HOST_PASSWORD
42+
valueFrom:
43+
secretKeyRef:
44+
name: {{ .Release.Name }}-secrets
45+
key: email-password
46+
- name: SQL_ENGINE
47+
value: {{ .Values.database.engine | default "django.db.backends.postgresql" | quote }}
48+
- name: SQL_PORT
49+
value: {{ .Values.database.port | default "5432" | quote }}
50+
- name: EMAIL_HOST_USER
51+
value: {{ .Values.email.hostUser | default "[email protected]" | quote }}
52+
- name: SQL_DATABASE
53+
value: {{ .Values.database.name | default "balancer_dev" | quote }}
54+
- name: SQL_PASSWORD
55+
valueFrom:
56+
secretKeyRef:
57+
name: {{ .Release.Name }}-secrets
58+
key: database-password
59+
- name: OPENAI_API_KEY
60+
valueFrom:
61+
secretKeyRef:
62+
name: {{ .Release.Name }}-secrets
63+
key: openai-api-key
64+
- name: SQL_HOST
65+
value: {{ .Values.database.host | default "database-1.c9a0wokccvp3.us-east-1.rds.amazonaws.com" | quote }}
66+
resources:
67+
requests:
68+
cpu: {{ .Values.resources.requests.cpu | default "500m" }}
69+
memory: {{ .Values.resources.requests.memory | default "1Gi" }}
70+
limits:
71+
cpu: {{ .Values.resources.limits.cpu | default "1024m" }}
72+
memory: {{ .Values.resources.limits.memory | default "3Gi" }}

k8s/templates/frontend-static-service.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

k8s/templates/frontend-static-deployment.yaml renamed to k8s/templates/frontend.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,67 @@ spec:
5252
path: nginx.conf
5353
restartPolicy: Always
5454
status: {}
55+
---
56+
apiVersion: v1
57+
kind: Service
58+
metadata:
59+
annotations:
60+
kompose.cmd: kompose convert -c -f nginx-docker-compose.yml -o nginx-helm-chart
61+
kompose.version: 1.31.2 (a92241f79)
62+
creationTimestamp: null
63+
labels:
64+
io.kompose.service: frontend-static
65+
name: frontend-static
66+
spec:
67+
ports:
68+
- name: "http"
69+
port: 80
70+
protocol: TCP
71+
selector:
72+
io.kompose.service: frontend-static
73+
status:
74+
loadBalancer: {}
75+
---
76+
apiVersion: v1
77+
kind: ConfigMap
78+
metadata:
79+
name: nginx-conf
80+
data:
81+
nginx.conf: |
82+
user nginx;
83+
worker_processes 1;
84+
events {
85+
worker_connections 1024;
86+
}
87+
http {
88+
include /etc/nginx/mime.types;
89+
error_log /var/log/nginx/error_log;
90+
access_log /var/log/nginx/access_log;
91+
server {
92+
listen 80;
93+
listen [::]:80;
94+
server_name {{ .Values.nginx.serverName }};
95+
96+
location /access_log {
97+
alias /var/log/nginx/access_log;
98+
}
99+
location /error_log {
100+
alias /var/log/nginx/error_log;
101+
}
102+
103+
location / {
104+
root /usr/share/nginx/html;
105+
index index.html index.htm;
106+
}
107+
108+
#error_page 404 /404.html;
109+
110+
# redirect server error pages to the static page /50x.html
111+
#
112+
#error_page 500 502 503 504 /50x.html;
113+
#location = /50x.html {
114+
# root /usr/share/nginx/html;
115+
116+
#}
117+
}
118+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Release.Name }}-frontend
5+
labels:
6+
{{- include "balancer.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: frontend
8+
spec:
9+
replicas: {{ .Values.frontend.replicaCount | default 1 }}
10+
selector:
11+
matchLabels:
12+
{{- include "balancer.selectorLabels" . | nindent 6 }}
13+
app.kubernetes.io/component: frontend
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "balancer.selectorLabels" . | nindent 8 }}
18+
app.kubernetes.io/component: frontend
19+
spec:
20+
containers:
21+
- name: frontend
22+
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}"
23+
imagePullPolicy: {{ .Values.frontend.image.pullPolicy | default "IfNotPresent" }}
24+
ports:
25+
- name: http
26+
containerPort: 3000
27+
protocol: TCP
28+
env:
29+
- name: CHOKIDAR_USEPOLLING
30+
value: "true"
31+
- name: VITE_API_BASE_URL
32+
value: {{ .Values.frontend.config.apiBaseUrl | default "https://balancertestsite.com/" | quote }}
33+
resources:
34+
requests:
35+
cpu: {{ .Values.frontend.resources.requests.cpu | default "100m" }}
36+
memory: {{ .Values.frontend.resources.requests.memory | default "256Mi" }}
37+
limits:
38+
cpu: {{ .Values.frontend.resources.limits.cpu | default "500m" }}
39+
memory: {{ .Values.frontend.resources.limits.memory | default "512Mi" }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ .Release.Name }}-frontend
5+
labels:
6+
{{- include "balancer.labels" . | nindent 4 }}
7+
app.kubernetes.io/component: frontend
8+
spec:
9+
type: {{ .Values.frontend.service.type | default "ClusterIP" }}
10+
ports:
11+
- port: {{ .Values.frontend.service.port | default 3000 }}
12+
targetPort: http
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "balancer.selectorLabels" . | nindent 4 }}
17+
app.kubernetes.io/component: frontend

0 commit comments

Comments
 (0)