Skip to content

Commit

Permalink
chore(helm): add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
muhuchah committed Aug 23, 2024
1 parent 6042b9a commit 5449554
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: negar
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
13 changes: 13 additions & 0 deletions templates/configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: db-configs
labels:
app: postgres
data:
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
HOST: "postgres"
PORT: {{ .Values.postgres.port }}
POSTGRES_CONNECTION_STRING: "Host=postgres;Database=postgres;Username=postgres;Password=postgres;"
53 changes: 53 additions & 0 deletions templates/deployment-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: {{ .Values.backend.replicaCount }}
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
initContainers:
- name: migrate
image: {{ .Values.backend.repository }}:{{ .Values.backend.tag }}
imagePullPolicy: {{ .Values.backend.pullPolicy }}
env:
- name: CONNECTION_STRING
valueFrom:
configMapKeyRef:
name: db-configs
key: POSTGRES_CONNECTION_STRING
command: ["dotnet", "./RelationAnalysis.Migrations.dll"]
ports:
- containerPort: {{ .Values.backend.port }}
resources:
requests:
memory: {{ .Values.backend.resources.requests.memory }}
cpu: {{ .Values.backend.resources.requests.cpu }}
limits:
memory: {{ .Values.backend.resources.limits.memory }}
cpu: {{ .Values.backend.resources.limits.cpu }}
containers:
- name: backend
image: {{ .Values.backend.repository }}:{{ .Values.backend.tag }}
imagePullPolicy: {{ .Values.backend.pullPolicy }}
env:
- name: CONNECTION_STRING
valueFrom:
configMapKeyRef:
name: db-configs
key: POSTGRES_CONNECTION_STRING
ports:
- containerPort: {{ .Values.backend.port }}
resources:
requests:
memory: {{ .Values.backend.resources.requests.memory }}
cpu: {{ .Values.backend.resources.requests.cpu }}
limits:
memory: {{ .Values.backend.resources.limits.memory }}
cpu: {{ .Values.backend.resources.limits.cpu }}
27 changes: 27 additions & 0 deletions templates/deployment-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
replicas: {{ .Values.frontend.replicaCount }}
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- name: frontend
image: {{ .Values.frontend.repository }}:{{ .Values.frontend.tag }}
imagePullPolicy: {{ .Values.frontend.pullPolicy }}
ports:
- containerPort: {{ .Values.frontend.port }}
resources:
requests:
memory: {{ .Values.frontend.resources.requests.memory }}
cpu: {{ .Values.frontend.resources.requests.cpu }}
limits:
memory: {{ .Values.frontend.resources.limits.memory }}"
cpu: {{ .Values.frontend.resources.limits.cpu }}
60 changes: 60 additions & 0 deletions templates/deployment-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
replicas: {{ .Values.postgres.replicaCount }}
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: {{ .Values.postgres.repository }}:{{ .Values.postgres.tag }}
imagePullPolicy: {{ .Values.postgres.pullPolicy }}
ports:
- containerPort: {{ .Values.postgres.port }}
env:
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: db-configs
key: POSTGRES_USER
- name: POSTGRES_PASSWORD
valueFrom:
configMapKeyRef:
name: db-configs
key: POSTGRES_PASSWORD
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: db-configs
key: POSTGRES_DB
- name: HOST
valueFrom:
configMapKeyRef:
name: db-configs
key: HOST
- name: PORT
valueFrom:
configMapKeyRef:
name: db-configs
key: PORT
volumeMounts:
- mountPath: /var/lib/postgres/data
name: db-data
resources:
requests:
memory: {{ .Values.postgres.resources.requests.memory }}
cpu: {{ .Values.postgres.resources.requests.cpu }}
limits:
memory: {{ .Values.postgres.resources.limits.memory }}
cpu: {{ .Values.postgres.resources.limits.cpu }}
volumes:
- name: db-data
persistentVolumeClaim:
claimName: db-persistent-pvc
10 changes: 10 additions & 0 deletions templates/pvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: db-persistent-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.postgres.pvc.storage }}
11 changes: 11 additions & 0 deletions templates/service-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: back-service
spec:
type: {{ .Values.backend.service.type }}
selector:
app: backend
ports:
- port: {{ .Values.backend.port }}
targetPort: {{ .Values.backend.service.port }}
11 changes: 11 additions & 0 deletions templates/service-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: front-service
spec:
type: {{ .Values.frontend.service.type }}
selector:
app: frontend
ports:
- port: {{ .Values.frontend.service.port }}
targetPort: {{ .Values.frontend.port }}
11 changes: 11 additions & 0 deletions templates/service-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
type: {{ .Values.postgres.service.type }}
ports:
- port: {{ .Values.postgres.port }}
targetPort: {{ .Values.postgres.service.port }}
selector:
app: postgres
58 changes: 58 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
backend:
repository: negar-backend
pullPolicy: IfNotPresent
tag: "latest"
replicaCount: 1
port: 80

service:
type: ClusterIP
port: 80

resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "1"

postgres:
repository: postgres
tag: "16.3"
pullPolicy: IfNotPresent
replicaCount: 1
port: 5432

service:
type: ClusterIP
port: 80

resources:
requests:
memory: "500Mi"
cpu: "500m"
limits:
memory: "1Gi"
cpu: "1"
pvc:
storage: 1Gi

frontend:
repository: negar-frontend
pullPolicy: IfNotPresent
tag: "latest"
replicaCount: 1
port: 80

service:
type: ClusterIP
port: 80

resources:
requests:
memory: "256Mi"
cpu: "500m"
limits:
memory: "512Mi"
cpu: "1"

0 comments on commit 5449554

Please sign in to comment.