-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from SubstraFoundation/add-operator
Convert add user/nodes Jobs to Operator
- Loading branch information
Showing
5 changed files
with
94 additions
and
192 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
charts/substra-backend/templates/add-account-operator.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "substra.fullname" . }}-add-account | ||
labels: | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
app.kubernetes.io/name: {{ template "substra.name" . }}-add-account | ||
app.kubernetes.io/part-of: {{ template "substra.name" . }} | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: {{ template "substra.name" . }}-add-account | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ template "substra.name" . }}-add-account | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- name: add-account | ||
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}" | ||
imagePullPolicy: "{{ .Values.backend.image.pullPolicy }}" | ||
command: ["/bin/bash", "-c"] | ||
args: | ||
- | | ||
while true; do | ||
./manage.py migrate | ||
## Users | ||
while read user_password; do | ||
./manage.py add_user $user_password | ||
done < /accounts/users | ||
## IncomingNode | ||
while read user_password; do | ||
./manage.py create_incoming_node $user_password | ||
done < /accounts/incoming_nodes | ||
## OutgoingNode | ||
while read user_password; do | ||
./manage.py create_outgoing_node $user_password | ||
done < /accounts/outgoing_nodes | ||
sleep 60 | ||
done | ||
resources: | ||
{{- toYaml .Values.resources | nindent 14 }} | ||
env: | ||
- name: DJANGO_SETTINGS_MODULE | ||
value: backend.settings.{{ .Values.backend.settings }} | ||
- name: BACKEND_DB_NAME | ||
value: {{ .Values.postgresql.postgresqlDatabase }} | ||
- name: BACKEND_DB_USER | ||
value: {{ .Values.postgresql.postgresqlUsername }} | ||
- name: BACKEND_DB_PWD | ||
value: {{ .Values.postgresql.postgresqlPassword }} | ||
- name: DATABASE_HOST | ||
value: {{ .Release.Name }}-postgresql | ||
- name: PYTHONUNBUFFERED | ||
value: "1" | ||
volumeMounts: | ||
- mountPath: /accounts | ||
name: accounts | ||
readOnly: true | ||
initContainers: | ||
- name: wait-postgresql | ||
image: jwilder/dockerize | ||
command: ['dockerize', '-wait', 'tcp://{{ .Release.Name }}-postgresql:5432'] | ||
volumes: | ||
- name: accounts | ||
configMap: | ||
name: {{ template "substra.fullname" . }}-add-account |
17 changes: 17 additions & 0 deletions
17
charts/substra-backend/templates/configmap-add-account.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "substra.fullname" . }}-add-account | ||
data: | ||
users: | | ||
{{- range .Values.users }} | ||
{{ .name }} {{ .secret }} | ||
{{- end }} | ||
incoming_nodes: | | ||
{{- range .Values.incomingNodes }} | ||
{{ .name }} {{ .secret }} | ||
{{- end }} | ||
outgoing_nodes: | | ||
{{- range .Values.outgoingNodes }} | ||
{{ .name }} {{ .secret }} | ||
{{- end }} |
62 changes: 0 additions & 62 deletions
62
charts/substra-backend/templates/job-add-incoming-nodes.yaml
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
charts/substra-backend/templates/job-add-outgoing-nodes.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.