Skip to content

Commit

Permalink
use secret for mysql password
Browse files Browse the repository at this point in the history
  • Loading branch information
teticio committed Aug 31, 2021
1 parent 2b1593a commit d34f762
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
Empty file modified deploy_kops.sh
100644 → 100755
Empty file.
20 changes: 19 additions & 1 deletion helm-chart/deejai/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: init-deejai
- name: init-{{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: mysql-root-password
- name: SQLALCHEMY_DATABASE_URL
value: mysql+pymysql://root:$(MYSQL_ROOT_PASSWORD)@mysql:3306/deejai
command:
- /bin/bash
- -ec
Expand All @@ -41,6 +51,14 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: mysql-root-password
- name: SQLALCHEMY_DATABASE_URL
value: mysql+pymysql://root:$(MYSQL_ROOT_PASSWORD)@mysql:3306/deejai
ports:
- name: http
containerPort: 8000
Expand Down
6 changes: 4 additions & 2 deletions helm-chart/deejai/templates/mysql-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ spec:
- image: mysql:5.6
name: mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
value: password
valueFrom:
secretKeyRef:
name: mysql
key: mysql-root-password
ports:
- containerPort: 3306
name: mysql
Expand Down
11 changes: 11 additions & 0 deletions helm-chart/deejai/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql
type: Opaque
data:
{{ if .Values.mysqlRootPassword }}
mysql-root-password: {{ .Values.mysqlRootPassword | b64enc | quote }}
{{ else }}
mysql-root-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
1 change: 0 additions & 1 deletion helm-chart/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM python:3.8
ARG APP_URL
ENV APP_URL $APP_URL
ENV CUDA_VISIBLE_DEVICES ""
ENV SQLALCHEMY_DATABASE_URL mysql+pymysql://root:password@mysql:3306/deejai
COPY . /deej-ai.online-app
WORKDIR "/deej-ai.online-app"
RUN sed -i "s|\(http\)[^/]*/[^/]*/[^/]*/|${APP_URL}/|g" .env.production && \
Expand Down
3 changes: 2 additions & 1 deletion install_helm_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ helm upgrade \
--install deejai helm-chart/deejai \
--create-namespace \
--namespace deejai \
--values helm-chart/deejai/values.yaml
--values helm-chart/deejai/values.yaml \
--set mysqlRootPassword=password
5 changes: 1 addition & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// TODO
//
// frontend:
// robots.txt etc
// service
// unit tests
// banner image and ico file
// ico file
// fix warnings for unique key
// fix warning about combining h2 and a in Banner
// incremental search
//
// backend:
// set seed in noise
Expand Down

0 comments on commit d34f762

Please sign in to comment.