diff --git a/.gitignore b/.gitignore index b30fa8ed..4f1cfaed 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__ .pytest_cache .vscode .coverage -rest_framework \ No newline at end of file +rest_framework +charts/*/charts \ No newline at end of file diff --git a/charts/outdated/Chart.lock b/charts/outdated/Chart.lock new file mode 100644 index 00000000..11918969 --- /dev/null +++ b/charts/outdated/Chart.lock @@ -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" diff --git a/charts/outdated/Chart.yaml b/charts/outdated/Chart.yaml index d7a2944e..e1c217bd 100644 --- a/charts/outdated/Chart.yaml +++ b/charts/outdated/Chart.yaml @@ -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 diff --git a/charts/outdated/templates/configmap.yaml b/charts/outdated/templates/configmap.yaml index 73a8ff76..ac7dd573 100644 --- a/charts/outdated/templates/configmap.yaml +++ b/charts/outdated/templates/configmap.yaml @@ -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 }} diff --git a/charts/outdated/templates/deployment.yaml b/charts/outdated/templates/deployment.yaml index cf1a0b0b..847c704c 100644 --- a/charts/outdated/templates/deployment.yaml +++ b/charts/outdated/templates/deployment.yaml @@ -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 }} @@ -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 }} \ No newline at end of file + {{- end }} \ No newline at end of file diff --git a/charts/outdated/templates/secret.yaml b/charts/outdated/templates/secret.yaml deleted file mode 100644 index 33ffae39..00000000 --- a/charts/outdated/templates/secret.yaml +++ /dev/null @@ -1,16 +0,0 @@ -{{- if not .Values.existingSecret }} -apiVersion: v1 -kind: Secret -metadata: - name: outdated-secrets -type: Opaque -data: - {{- if .Values.postgresql.enabled }} - DATABASE_PASSWORD: {{ .Values.postgresql.auth.password | b64enc | quote }} - POSTGRES_PASSWORD: {{ .Values.postgresql.auth.password | b64enc | quote }} - {{- else }} - DATABASE_PASSWORD: {{ .Values.externalDatabase.password | b64enc | quote }} - POSTGRES_PASSWORD: {{ .Values.externalDatabase.password | b64enc | quote }} - {{- end }} - SECRET_KEY: {{ randAlphaNum 20 | b64enc | quote }} -{{- end }} \ No newline at end of file diff --git a/charts/outdated/templates/service.yaml b/charts/outdated/templates/service.yaml index d2923c06..49d737c1 100644 --- a/charts/outdated/templates/service.yaml +++ b/charts/outdated/templates/service.yaml @@ -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 diff --git a/charts/outdated/values.yaml b/charts/outdated/values.yaml index 03a8427f..27b8ac24 100644 --- a/charts/outdated/values.yaml +++ b/charts/outdated/values.yaml @@ -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 @@ -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" @@ -50,9 +43,8 @@ postgresql: enabled: true auth: username: outdated - password: outdated database: outdated - + password: outdated imagePullSecrets: [] nameOverride: "" diff --git a/ct.yaml b/ct.yaml index 21315f92..9e4c988c 100644 --- a/ct.yaml +++ b/ct.yaml @@ -1,3 +1,6 @@ +--- target-branch: main +chart-repos: + - bitnami=https://charts.bitnami.com/bitnami charts: - charts/outdated