From cbfc0a53b3aaff8ea237e7bedb3666f1061b068b Mon Sep 17 00:00:00 2001 From: Emi BOUCLY Date: Mon, 20 Oct 2025 09:45:26 +0200 Subject: [PATCH] tp2 --- .gitignore | 2 ++ .idea/.gitignore | 8 +++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 7 ++++ .idea/modules.xml | 8 +++++ .idea/sae5dc03-tp.iml | 10 ++++++ tp2/adminer-pod.yaml | 17 +++++++++ tp2/adminer-service.yaml | 14 ++++++++ tp2/db-secret.yaml | 7 ++++ tp2/db-service.yaml | 12 +++++++ tp2/db-statefulset.yaml | 35 +++++++++++++++++++ tp2/db-users-sql-configmap.yaml | 32 +++++++++++++++++ tp2/r209-deployment.yaml | 30 ++++++++++++++++ tp2/r209-pod.yaml | 12 +++++++ tp2/r209-service.yaml | 14 ++++++++ 15 files changed, 214 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/sae5dc03-tp.iml create mode 100644 tp2/adminer-pod.yaml create mode 100644 tp2/adminer-service.yaml create mode 100644 tp2/db-secret.yaml create mode 100644 tp2/db-service.yaml create mode 100644 tp2/db-statefulset.yaml create mode 100644 tp2/db-users-sql-configmap.yaml create mode 100644 tp2/r209-deployment.yaml create mode 100644 tp2/r209-pod.yaml create mode 100644 tp2/r209-service.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4b5952 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.venv/ +/venv/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8367f33 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5fd314a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sae5dc03-tp.iml b/.idea/sae5dc03-tp.iml new file mode 100644 index 0000000..3958b83 --- /dev/null +++ b/.idea/sae5dc03-tp.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tp2/adminer-pod.yaml b/tp2/adminer-pod.yaml new file mode 100644 index 0000000..c146d0b --- /dev/null +++ b/tp2/adminer-pod.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Pod +metadata: + name: adminer + labels: + role: adminer + app: adminer +spec: + containers: + - name: adminer + image: iut1r-registry.univ-grenoble-alpes.fr/library/adminer + imagePullPolicy: IfNotPresent + ports: + - name: adminer + containerPort: 8080 + protocol: TCP + restartPolicy: Always diff --git a/tp2/adminer-service.yaml b/tp2/adminer-service.yaml new file mode 100644 index 0000000..60bcc6c --- /dev/null +++ b/tp2/adminer-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: adminer-service +spec: + selector: + app: adminer + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + nodePort: 30288 + type: NodePort + \ No newline at end of file diff --git a/tp2/db-secret.yaml b/tp2/db-secret.yaml new file mode 100644 index 0000000..6215ba8 --- /dev/null +++ b/tp2/db-secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-secret +data: + POSTGRES_USER: cjIwOQ== + POSTGRES_PASSWORD: cjIwOQ== diff --git a/tp2/db-service.yaml b/tp2/db-service.yaml new file mode 100644 index 0000000..a6b470c --- /dev/null +++ b/tp2/db-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: db-service +spec: + selector: + app: db + type: ClusterIP + ports: + - port: 5432 + name: postgres + targetPort: postgres diff --git a/tp2/db-statefulset.yaml b/tp2/db-statefulset.yaml new file mode 100644 index 0000000..0104b2a --- /dev/null +++ b/tp2/db-statefulset.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: db +spec: + selector: + matchLabels: + app: db + serviceName: db + template: + metadata: + labels: + app: db + spec: + volumes: + - name: db-users-sql-vol + configMap: + name: db-users-sql + containers: + - name: postgresql + image: postgres:alpine + ports: + - containerPort: 5432 + name: postgres + env: + - name: POSTGRES_USER + value: r209 + - name: POSTGRES_PASSWORD + value: r209 + - name: POSTGRES_DB + value: r209 + volumeMounts: + - mountPath: /docker-entrypoint-initdb.d + name: db-users-sql-vol + diff --git a/tp2/db-users-sql-configmap.yaml b/tp2/db-users-sql-configmap.yaml new file mode 100644 index 0000000..9fb0610 --- /dev/null +++ b/tp2/db-users-sql-configmap.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: db-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/tp2/r209-deployment.yaml b/tp2/r209-deployment.yaml new file mode 100644 index 0000000..24ac438 --- /dev/null +++ b/tp2/r209-deployment.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: r209-deployment + labels: + app: r209-deployment +spec: + replicas: 1 + 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 + imagePullPolicy: IfNotPresent + env: + - name: POSTGRES_DB + value: r209 + - name: POSTGRES_HOST + value: db-service + envFrom: + - secretRef: + name: db-secret + restartPolicy: Always diff --git a/tp2/r209-pod.yaml b/tp2/r209-pod.yaml new file mode 100644 index 0000000..ede544a --- /dev/null +++ b/tp2/r209-pod.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: r209-pod + labels: + role: r209-pod +spec: + containers: + - name: r209-pod + image: iut1r-registry.univ-grenoble-alpes.fr/but/r209 + imagePullPolicy: IfNotPresent + restartPolicy: Always diff --git a/tp2/r209-service.yaml b/tp2/r209-service.yaml new file mode 100644 index 0000000..cb5437e --- /dev/null +++ b/tp2/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: 30280 + type: NodePort + \ No newline at end of file