From 83775e9dc0e3c25799b9349cd054f73621d169b4 Mon Sep 17 00:00:00 2001 From: Emi BOUCLY Date: Wed, 12 Nov 2025 16:51:07 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20tp5,=20pas=20fini=20(7.4=20commenc?= =?UTF-8?q?=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tp5/chart/Chart.yaml | 6 ++ tp5/chart/templates/db_secret.yaml | 8 +++ tp5/chart/templates/db_service.yaml | 16 +++++ tp5/chart/templates/db_statefulset.yaml | 36 ++++++++++ .../templates/enseignants_deployment.yaml | 34 +++++++++ tp5/chart/templates/enseignants_service.yaml | 14 ++++ tp5/chart/templates/missions_deployment.yaml | 38 ++++++++++ tp5/chart/templates/missions_service.yaml | 14 ++++ tp5/chart/templates/villes_deployment.yaml | 34 +++++++++ tp5/chart/templates/villes_service.yaml | 14 ++++ tp5/chart/templates/web_deployment.yaml | 35 ++++++++++ tp5/chart/templates/web_service.yaml | 15 ++++ tp5/chart/values.yaml | 45 ++++++++++++ tp5/istio-gateway-missions.yaml | 69 +++++++++++++++++++ tp5/locustfile.py | 21 ++++++ tp5/villes-retrylogic.yaml | 17 +++++ tp5/web_deployment.yaml | 35 ++++++++++ tp5/web_service.yaml | 15 ++++ 18 files changed, 466 insertions(+) create mode 100644 tp5/chart/Chart.yaml create mode 100644 tp5/chart/templates/db_secret.yaml create mode 100644 tp5/chart/templates/db_service.yaml create mode 100644 tp5/chart/templates/db_statefulset.yaml create mode 100644 tp5/chart/templates/enseignants_deployment.yaml create mode 100644 tp5/chart/templates/enseignants_service.yaml create mode 100644 tp5/chart/templates/missions_deployment.yaml create mode 100644 tp5/chart/templates/missions_service.yaml create mode 100644 tp5/chart/templates/villes_deployment.yaml create mode 100644 tp5/chart/templates/villes_service.yaml create mode 100644 tp5/chart/templates/web_deployment.yaml create mode 100644 tp5/chart/templates/web_service.yaml create mode 100644 tp5/chart/values.yaml create mode 100644 tp5/istio-gateway-missions.yaml create mode 100644 tp5/locustfile.py create mode 100644 tp5/villes-retrylogic.yaml create mode 100644 tp5/web_deployment.yaml create mode 100644 tp5/web_service.yaml diff --git a/tp5/chart/Chart.yaml b/tp5/chart/Chart.yaml new file mode 100644 index 0000000..d6e1dd3 --- /dev/null +++ b/tp5/chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: missions +description: Un chart Helm pour déployer l'application missions +type: application +version: 1.0.0 +appVersion: 1.0.0 diff --git a/tp5/chart/templates/db_secret.yaml b/tp5/chart/templates/db_secret.yaml new file mode 100644 index 0000000..b4dceb9 --- /dev/null +++ b/tp5/chart/templates/db_secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: database-secret + namespace: {{ .Values.namespace }} +data: + DB_USER: {{ .Values.database.user | b64enc }} + DB_PASSWORD: {{ .Values.database.user | b64enc }} diff --git a/tp5/chart/templates/db_service.yaml b/tp5/chart/templates/db_service.yaml new file mode 100644 index 0000000..3136790 --- /dev/null +++ b/tp5/chart/templates/db_service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: database + namespace: {{ .Values.namespace }} + labels: + app: database +spec: + ports: + - name: tcp-postgresql + port: 5432 + protocol: TCP + targetPort: 5432 + type: ClusterIP + selector: + app: database diff --git a/tp5/chart/templates/db_statefulset.yaml b/tp5/chart/templates/db_statefulset.yaml new file mode 100644 index 0000000..651eb26 --- /dev/null +++ b/tp5/chart/templates/db_statefulset.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: database + namespace: {{ .Values.namespace }} +spec: + selector: + matchLabels: + app: database + serviceName: database + template: + metadata: + labels: + app: database + spec: + containers: + - name: database + image: "{{.Values.images.registry}}/missions-db:{{ .Values.db.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + ports: + - containerPort: 5432 + name: postgres + env: + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + key: DB_USER + name: database-secret + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + key: DB_PASSWORD + name: database-secret + - name: POSTGRES_DB + value: {{ .Values.database.name }} + restartPolicy: Always diff --git a/tp5/chart/templates/enseignants_deployment.yaml b/tp5/chart/templates/enseignants_deployment.yaml new file mode 100644 index 0000000..0394e3d --- /dev/null +++ b/tp5/chart/templates/enseignants_deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: enseignants + namespace: {{ .Values.namespace }} + labels: + app: enseignants +spec: + replicas: {{ .Values.enseignants.replicas }} + selector: + matchLabels: + app: enseignants + template: + metadata: + name: enseignants + labels: + app: enseignants + version: "1.0" + spec: + containers: + - name: enseignants + image: "{{.Values.images.registry}}/missions-enseignants:{{ .Values.enseignants.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: DB_HOST + value: database + - name: DB_NAME + value: {{ .Values.database.name }} + envFrom: + - secretRef: + name: database-secret + ports: + - containerPort: 5000 + restartPolicy: Always diff --git a/tp5/chart/templates/enseignants_service.yaml b/tp5/chart/templates/enseignants_service.yaml new file mode 100644 index 0000000..ce1479f --- /dev/null +++ b/tp5/chart/templates/enseignants_service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: enseignants + namespace: {{ .Values.namespace }} +spec: + selector: + app: enseignants + ports: + - name: http-enseignants + protocol: TCP + port: {{ .Values.enseignants.port }} + targetPort: 5000 + type: ClusterIP diff --git a/tp5/chart/templates/missions_deployment.yaml b/tp5/chart/templates/missions_deployment.yaml new file mode 100644 index 0000000..533a96b --- /dev/null +++ b/tp5/chart/templates/missions_deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: missions + namespace: {{ .Values.namespace }} + labels: + app: missions +spec: + replicas: {{ .Values.missions.replicas }} + selector: + matchLabels: + app: missions + template: + metadata: + name: missions + labels: + app: missions + version: "1.0" + spec: + containers: + - name: missions + image: "{{.Values.images.registry}}/missions-missions:{{ .Values.missions.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: DB_HOST + value: database + - name: DB_NAME + value: {{ .Values.database.name }} + - name: SERVICE_VILLES_URL + value: http://villes:{{ .Values.villes.port }} + - name: SERVICE_ENSEIGNANTS_URL + value: http://enseignants:{{ .Values.enseignants.port }} + envFrom: + - secretRef: + name: database-secret + ports: + - containerPort: 5000 + restartPolicy: Always diff --git a/tp5/chart/templates/missions_service.yaml b/tp5/chart/templates/missions_service.yaml new file mode 100644 index 0000000..0f75e63 --- /dev/null +++ b/tp5/chart/templates/missions_service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: missions + namespace: {{ .Values.namespace }} +spec: + selector: + app: missions + ports: + - name: http-missions + protocol: TCP + port: {{ .Values.missions.port }} + targetPort: 5000 + type: ClusterIP diff --git a/tp5/chart/templates/villes_deployment.yaml b/tp5/chart/templates/villes_deployment.yaml new file mode 100644 index 0000000..de8fd7a --- /dev/null +++ b/tp5/chart/templates/villes_deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: villes + namespace: {{ .Values.namespace }} + labels: + app: villes +spec: + replicas: {{ .Values.villes.replicas }} + selector: + matchLabels: + app: villes + template: + metadata: + name: villes + labels: + app: villes + version: "1.0" + spec: + containers: + - name: villes + image: "{{.Values.images.registry}}/missions-villes:{{ .Values.villes.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: DB_HOST + value: database + - name: DB_NAME + value: {{ .Values.database.name }} + envFrom: + - secretRef: + name: database-secret + ports: + - containerPort: 5000 + restartPolicy: Always diff --git a/tp5/chart/templates/villes_service.yaml b/tp5/chart/templates/villes_service.yaml new file mode 100644 index 0000000..bd72cc1 --- /dev/null +++ b/tp5/chart/templates/villes_service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: villes + namespace: {{ .Values.namespace }} +spec: + selector: + app: villes + ports: + - name: http-villes + protocol: TCP + port: {{ .Values.villes.port }} + targetPort: 5000 + type: ClusterIP diff --git a/tp5/chart/templates/web_deployment.yaml b/tp5/chart/templates/web_deployment.yaml new file mode 100644 index 0000000..ef52c03 --- /dev/null +++ b/tp5/chart/templates/web_deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: web + namespace: {{ .Values.namespace }} + labels: + app: web +spec: + replicas: {{ .Values.web.replicas }} + selector: + matchLabels: + app: web + template: + metadata: + name: web + labels: + app: web + version: "1.0" + spec: + containers: + - name: web + image: "{{.Values.images.registry}}/missions-web:{{ .Values.web.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: DB_HOST + value: database + - name: DB_NAME + value: {{ .Values.database.name }} + - name: SERVICE_MISSIONS_URL + value: http://missions:{{ .Values.missions.port }} + - name: SERVICE_ENSEIGNANTS_URL + value: http://enseignants:{{ .Values.enseignants.port }} + ports: + - containerPort: 8080 + restartPolicy: Always diff --git a/tp5/chart/templates/web_service.yaml b/tp5/chart/templates/web_service.yaml new file mode 100644 index 0000000..1cd59d1 --- /dev/null +++ b/tp5/chart/templates/web_service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: app + namespace: {{ .Values.namespace }} +spec: + selector: + app: web + ports: + - name: http-app + protocol: TCP + port: {{ .Values.web.port }} + targetPort: 5000 + nodePort: {{ .Values.web.nodePort }} + type: {{ .Values.web.serviceType | default "ClusterIP" }} diff --git a/tp5/chart/values.yaml b/tp5/chart/values.yaml new file mode 100644 index 0000000..4d2cec1 --- /dev/null +++ b/tp5/chart/values.yaml @@ -0,0 +1,45 @@ +# Configuration du namespace +namespace: tp5 + +# Configuration pour les images +images: + pullPolicy: Always + registry: iut1r-registry.univ-grenoble-alpes.fr/but + +# Configuration de la base de données +database: + user: missions + password: missions + name: missions + +# Configuration du déploiement de db +db: + tag: latest + replicas: 1 + port: 5432 + +# Configuration du WebService enseignants +enseignants: + tag: latest + replicas: 1 + port: 5000 + +# Configuration du WebService missions +missions: + tag: latest + replicas: 1 + port: 5000 + +# Configuration du WebService villes +villes: + tag: latest + replicas: 1 + port: 5000 + +# Configuration de l'application web +web: + tag: latest + replicas: 1 + port: 8080 + nodePort: 30580 + serviceType: NodePort diff --git a/tp5/istio-gateway-missions.yaml b/tp5/istio-gateway-missions.yaml new file mode 100644 index 0000000..e6dac2e --- /dev/null +++ b/tp5/istio-gateway-missions.yaml @@ -0,0 +1,69 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + namespace: tp5 + name: missions-gateway +spec: + selector: + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "*" + + +--- +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + namespace: tp5 + name: missions +spec: + hosts: + - "*" + gateways: + - missions-gateway + http: + - name: API Enseignants + match: + - uri: + prefix: "/api/enseignants" + rewrite: + uri: "/enseignants" + route: + - destination: + host: enseignants + port: + number: 5000 + - name: API Missions + match: + - uri: + prefix: "/api/missions" + rewrite: + uri: "/missions" + route: + - destination: + host: missions + port: + number: 5000 + - name: API Villes + match: + - uri: + prefix: "/api/villes" + rewrite: + uri: "/villes" + route: + - destination: + host: villes + port: + number: 5000 + - name: Application Web + route: + - destination: + host: app + port: + number: 8080 + diff --git a/tp5/locustfile.py b/tp5/locustfile.py new file mode 100644 index 0000000..fa3d084 --- /dev/null +++ b/tp5/locustfile.py @@ -0,0 +1,21 @@ +import time + +from locust import HttpUser, task, between + + +class QuickstartUser(HttpUser): + wait_time = between(1, 5) + + @task + def missions(self): + self.client.get("/") + + @task + def enseignants(self): + self.client.get("/enseignants") + + @task + def view_missions(self): + for mission_id in range(1, 6): + self.client.get(f"/mission/{mission_id}") + time.sleep(1) diff --git a/tp5/villes-retrylogic.yaml b/tp5/villes-retrylogic.yaml new file mode 100644 index 0000000..07b4d1e --- /dev/null +++ b/tp5/villes-retrylogic.yaml @@ -0,0 +1,17 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: villes-retrylogic + namespace: tp5 +spec: + hosts: + - villes + http: + - name: Application Web + route: + - destination: + host: villes + retries: + attempts: 4 + perTryTimeout: 2s + retryOn: 5xx diff --git a/tp5/web_deployment.yaml b/tp5/web_deployment.yaml new file mode 100644 index 0000000..ef52c03 --- /dev/null +++ b/tp5/web_deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: web + namespace: {{ .Values.namespace }} + labels: + app: web +spec: + replicas: {{ .Values.web.replicas }} + selector: + matchLabels: + app: web + template: + metadata: + name: web + labels: + app: web + version: "1.0" + spec: + containers: + - name: web + image: "{{.Values.images.registry}}/missions-web:{{ .Values.web.tag }}" + imagePullPolicy: {{ .Values.images.pullPolicy }} + env: + - name: DB_HOST + value: database + - name: DB_NAME + value: {{ .Values.database.name }} + - name: SERVICE_MISSIONS_URL + value: http://missions:{{ .Values.missions.port }} + - name: SERVICE_ENSEIGNANTS_URL + value: http://enseignants:{{ .Values.enseignants.port }} + ports: + - containerPort: 8080 + restartPolicy: Always diff --git a/tp5/web_service.yaml b/tp5/web_service.yaml new file mode 100644 index 0000000..1cd59d1 --- /dev/null +++ b/tp5/web_service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: app + namespace: {{ .Values.namespace }} +spec: + selector: + app: web + ports: + - name: http-app + protocol: TCP + port: {{ .Values.web.port }} + targetPort: 5000 + nodePort: {{ .Values.web.nodePort }} + type: {{ .Values.web.serviceType | default "ClusterIP" }}