diff --git a/.gitignore b/.gitignore index f4b5952..a73ee73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.venv/ -/venv/ \ No newline at end of file +/venv/ +.idea \ No newline at end of file diff --git a/tp3/Chart.yaml b/tp3/Chart.yaml new file mode 100644 index 0000000..6323589 --- /dev/null +++ b/tp3/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: r209 +description: Un chart Helm pour déployer l'application r209 +type: application +version: 0.1.0 +appVersion: 1.0.0 \ No newline at end of file diff --git a/tp3/templates/db_configmap.yaml b/tp3/templates/db_configmap.yaml new file mode 100644 index 0000000..4cb75e1 --- /dev/null +++ b/tp3/templates/db_configmap.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-r209-users-sql +data: + initdb.sql: |- + BEGIN TRANSACTION; + DROP TABLE IF EXISTS "users"; + CREATE TABLE IF NOT EXISTS "users" ( + "login" TEXT, + "fullname" TEXT, + "birthdate" DATE, + "password" TEXT, + "admin" INTEGER NOT NULL DEFAULT 0, + PRIMARY KEY("login") + ); + INSERT INTO "users" ("login","fullname","birthdate","password","admin") VALUES ('sam','Sam Maitégal','2003-12-05 00:00:00.000','$2b$12$57glhlGaBXcr9b2JJdPx6.awrDfeOKIwFYy9bUd4mlBL2/VRoy2aO',1), + ('ella','Ella Traifin','2003-01-01 00:00:00.000','$2b$12$FPSwH.iB08zvDrXf0lXTIONiVK/309wGKrPG3a0eJsMXBNYy5KCGa',0), + ('bob','Bob Art','2003-01-01 00:00:00.000','$2b$12$3z97LmOQfmIRE6EmjlZuiu3semEqvkvhLhOK2nlcO1blJCvY5Avny',0), + ('joe','Joe Zepa','2002-12-25 00:00:00.000','$2b$12$ye9mp794RWnLO4gR2aDpUOlUtty983mjXvZRsj8AH7qNt9Pnz33yy',0), + ('eve','Eve Reste','2003-05-22 00:00:00.000','$2b$12$Dv5eKRCbFNJL/8xkuxuV5eIQ.0G9VPMK6ps6EmBmcPPDI93Rau4Lm',0), + ('tom','Tom Ejérie','2003-07-23 00:00:00.000','$2b$12$31G4YEoKtrQI67SkPTKioOizlgYKd5A/FogHyED2Xtk3sIqtPALu2',0), + ('manu','Manu Cure','2004-02-17 00:00:00.000','$2b$12$hxwwdka/QmtLvS1udTVUke8RsD9ZE85regeBIDUSo8Pf2hTN8Ekcu',0), + ('bess','Bess Tiolle','2004-09-07 00:00:00.000','$2b$12$nf7n2Ll/./P/4zedaeXABuFP4WfyECgk.vmT1IqHpOsqFo0MhmeuS',0), + ('paul','Paul Hussion','2003-08-02 00:00:00.000','$2b$12$PoySQqlLTfoIgc/fSvQEueDthzOLaSb5K6l6tnMbYXYNu0Pd/u85.',0), + ('cami','Camille Onète','2003-10-31 00:00:00.000','$2b$12$ML8F4eUZWB5IV82p7XSmqOv/IvwS8mEW7OG3zhqYH5cAlj7pj/hUy',0), + ('eva','Eva Luassion','1998-11-02 00:00:00.000','$2b$12$5MoEIbM60Qx/0HblAMEa..o09BeFuVgAzevOe1OqQdezUdQ1xD6ju',0), + ('jean','Jean Serrien','2003-01-12 00:00:00.000','$2b$12$OjajkYs.rL8aKFT3c5ogyu3ttTbALUuw9yQQbU3VOpBvKlKD/fpX.',0), + ('ines','Inès Timable','2003-03-15 00:00:00.000','$2b$12$PXH3fk3H0kfNxZgRu/hsjuE4rnEsrOEfPlvC2Gb4oHzV5qmmaRWbW',0), + ('larry','Larry Bambelle','2003-07-15 00:00:00.000','$2b$12$h9saMfv3svCZzDniiCbjw.60q4elP/sZs0xpx6CTgY3fqlOonjWae',0), + ('theo','Théo Courant','2003-06-25 00:00:00.000','$2b$12$SEFG1/8ly4TF.t0C5W4Xy.IAyxRGWrrhg.f3W4zVctR5bKL7EW6WO',0); + COMMIT; diff --git a/tp3/templates/db_secrets.yaml b/tp3/templates/db_secrets.yaml new file mode 100644 index 0000000..613733b --- /dev/null +++ b/tp3/templates/db_secrets.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-secret +data: + POSTGRES_USER: {{ .Values.database.user | b64enc }} + POSTGRES_PASSWORD: {{ .Values.database.password | b64enc }} diff --git a/tp3/templates/db_service.yaml b/tp3/templates/db_service.yaml new file mode 100644 index 0000000..a321c2b --- /dev/null +++ b/tp3/templates/db_service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: db-service +spec: + selector: + app: db-statefulset + type: ClusterIP + ports: + - port: 5432 + name: postgres + targetPort: postgres diff --git a/tp3/templates/db_statefulset.yaml b/tp3/templates/db_statefulset.yaml new file mode 100644 index 0000000..c967c7f --- /dev/null +++ b/tp3/templates/db_statefulset.yaml @@ -0,0 +1,37 @@ + + +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: db-statefulset +spec: + selector: + matchLabels: + app: db-statefulset + serviceName: db + template: + metadata: + labels: + app: db-statefulset + spec: + containers: + - name: postgresql + image: postgres:alpine + imagePullPolicy: {{ .Values.images.pullPolicy | default "IfNotPresent" }} + ports: + - containerPort: 5432 + name: postgres + env: + - name: POSTGRES_DB + value: {{ .Values.database.name }} + envFrom: + - secretRef: + name: db-secret + volumeMounts: + - mountPath: /docker-entrypoint-initdb.d + name: db-users-sql-vol + volumes: + - name: db-users-sql-vol + configMap: + name: db-r209-users-sql + diff --git a/tp3/templates/r209_deployment.yaml b/tp3/templates/r209_deployment.yaml new file mode 100644 index 0000000..f977365 --- /dev/null +++ b/tp3/templates/r209_deployment.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: r209-deployment + labels: + app: r209-deployment +spec: + replicas: {{ .Values.r209.replicas }} + selector: + matchLabels: + app: r209-deployment + template: + metadata: + name: r209-deployment + labels: + app: r209-deployment + spec: + containers: + - name: r209-deployment + image: iut1r-registry.univ-grenoble-alpes.fr/but/r209-psql:{{.Values.r209.tag}} + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: POSTGRES_DB + value: r209 + - name: POSTGRES_HOST + value: db-service + envFrom: + - secretRef: + name: db-secret + restartPolicy: Always diff --git a/tp3/templates/r209_service.yaml b/tp3/templates/r209_service.yaml new file mode 100644 index 0000000..74b5856 --- /dev/null +++ b/tp3/templates/r209_service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: r209-service +spec: + selector: + app: r209-deployment + ports: + - protocol: TCP + port: 80 + targetPort: 5000 + nodePort: {{ .Values.r209.port }} + type: NodePort + \ No newline at end of file diff --git a/tp3/values.yaml b/tp3/values.yaml new file mode 100644 index 0000000..6efaad5 --- /dev/null +++ b/tp3/values.yaml @@ -0,0 +1,17 @@ +# Valeurs par défaut de l'application r209 + +# Configuration de la base de données +database: + user: r209 + password: r209 + name: r209 + +# Configuration de la politique des images +images: + pullPolicy: IfNotPresent + +# Configuration de l'application r209 +r209: + tag: latest + replicas: 1 + port: 30380