Skip to content

Commit

Permalink
chore(charts): use bitnami chart for database
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Feb 16, 2024
1 parent a0ec368 commit d39a2d5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 136 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ __pycache__
.pytest_cache
.vscode
.coverage
rest_framework
rest_framework
charts/*/charts
6 changes: 6 additions & 0 deletions charts/outdated/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 14.0.5
digest: sha256:f9bfcbfaea579dd2cb446c9ef96a960ea042e22ab47e55405b56fb5e57341a92
generated: "2024-02-14T09:14:59.288031462+01:00"
6 changes: 6 additions & 0 deletions charts/outdated/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ version: 0.1.0
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

dependencies:
- name: postgresql
version: ~14.0.5
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
12 changes: 8 additions & 4 deletions charts/outdated/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ metadata:
labels:
{{- include "outdated.labels" . | nindent 4 }}
data:
OIDC_OP_BASE_ENDPOINT: {{ cat .Values.oidc.host "/realms/" .Values.oidc.realm "/protocol/openid-connect" | replace " " "" }}
OIDC_OP_BASE_ENDPOINT: {{ cat .Values.oidc.host "/realms/" .Values.oidc.realm "/protocol/openid-connect" | replace " " "" | quote }}
ALLOWED_HOSTS: {{ .Values.django.allowedHosts | quote }}
DEBUG: "false"
DATABASE_HOST: "outdated-db.{{ .Release.Namespace }}"
POSTGRES_USER: "outdated"
POSTGRES_DB: "outdated"
{{- if .Values.postgresql.enabled }}
DATABASE_HOST: "outdated-postgresql.{{ .Release.Namespace }}"
DATABASE_PASSWORD: {{ .Values.postgresql.auth.password }}
DATABASE_NAME: {{ .Values.postgresql.auth.database }}
DATABASE_USER: {{ .Values.postgresql.auth.username }}
{{- end }}
OIDC_GROUPS_CLAIM: "groups"
SECRET_KEY: {{ randAscii 20 | quote }}
86 changes: 2 additions & 84 deletions charts/outdated/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ spec:
envFrom:
- configMapRef:
name: {{ template "outdated.fullname" . }}
- secretRef:
{{- if .Values.existingSecret }}
- secretRef:
name: {{ .Values.existingSecret }}
{{- else}}
name: outdated-secrets
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down Expand Up @@ -154,84 +152,4 @@ spec:
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}


{{- if .Values.postgresql.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "outdated.fullname" . }}-db
labels:
{{- include "outdated.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "outdated.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "outdated.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app.kubernetes.io/component: db
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "outdated.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-db
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.db.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ template "outdated.fullname" . }}
- secretRef:
{{- if .Values.existingSecret }}
name: {{ .Values.existingSecret }}
{{- else}}
name: outdated-secrets
{{- end }}

ports:
- name: http
containerPort: {{ .Values.db.service.port }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
16 changes: 0 additions & 16 deletions charts/outdated/templates/secret.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions charts/outdated/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,3 @@ spec:
selector:
{{- include "outdated.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: ember
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "outdated.fullname" . }}-db
labels:
{{- include "outdated.labels" . | nindent 4 }}
app.kubernetes.io/component: db
spec:
type: {{ .Values.db.service.type }}
ports:
- port: {{ .Values.db.service.port }}
targetPort: 5432
protocol: TCP
name: http
selector:
{{- include "outdated.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: db
18 changes: 5 additions & 13 deletions charts/outdated/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
# kubectl create secret generic outdated-secrets \
# --namespace app-outdated \
# --from-literal=DATABASE_PASSWORD=xyz \
# --from-literal=POSTGRES_PASSWORD=xyz \
# --from-literal=SECRET_KEY=xyz \
existingSecret: ~

# for using an external database set DATABASE_HOST and DATABASE_USER

existingSecret: ""

api:
replicaCount: 1
Expand All @@ -28,15 +30,6 @@ ember:
type: ClusterIP
port: 80

db:
image:
repository: postgres
pullPolicy: IfNotPresent
tag: "16-alpine"
service:
type: ClusterIP
port: 5432

django:
allowedHosts: "*"
debug: "False"
Expand All @@ -50,9 +43,8 @@ postgresql:
enabled: true
auth:
username: outdated
password: outdated
database: outdated

password: outdated

imagePullSecrets: []
nameOverride: ""
Expand Down
3 changes: 3 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
target-branch: main
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
charts:
- charts/outdated

0 comments on commit d39a2d5

Please sign in to comment.