feat: tp5, pas fini (7.4 commencé)
This commit is contained in:
parent
1fef95a37f
commit
83775e9dc0
18 changed files with 466 additions and 0 deletions
6
tp5/chart/Chart.yaml
Normal file
6
tp5/chart/Chart.yaml
Normal file
|
|
@ -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
|
||||
8
tp5/chart/templates/db_secret.yaml
Normal file
8
tp5/chart/templates/db_secret.yaml
Normal file
|
|
@ -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 }}
|
||||
16
tp5/chart/templates/db_service.yaml
Normal file
16
tp5/chart/templates/db_service.yaml
Normal file
|
|
@ -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
|
||||
36
tp5/chart/templates/db_statefulset.yaml
Normal file
36
tp5/chart/templates/db_statefulset.yaml
Normal file
|
|
@ -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
|
||||
34
tp5/chart/templates/enseignants_deployment.yaml
Normal file
34
tp5/chart/templates/enseignants_deployment.yaml
Normal file
|
|
@ -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
|
||||
14
tp5/chart/templates/enseignants_service.yaml
Normal file
14
tp5/chart/templates/enseignants_service.yaml
Normal file
|
|
@ -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
|
||||
38
tp5/chart/templates/missions_deployment.yaml
Normal file
38
tp5/chart/templates/missions_deployment.yaml
Normal file
|
|
@ -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
|
||||
14
tp5/chart/templates/missions_service.yaml
Normal file
14
tp5/chart/templates/missions_service.yaml
Normal file
|
|
@ -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
|
||||
34
tp5/chart/templates/villes_deployment.yaml
Normal file
34
tp5/chart/templates/villes_deployment.yaml
Normal file
|
|
@ -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
|
||||
14
tp5/chart/templates/villes_service.yaml
Normal file
14
tp5/chart/templates/villes_service.yaml
Normal file
|
|
@ -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
|
||||
35
tp5/chart/templates/web_deployment.yaml
Normal file
35
tp5/chart/templates/web_deployment.yaml
Normal file
|
|
@ -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
|
||||
15
tp5/chart/templates/web_service.yaml
Normal file
15
tp5/chart/templates/web_service.yaml
Normal file
|
|
@ -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" }}
|
||||
45
tp5/chart/values.yaml
Normal file
45
tp5/chart/values.yaml
Normal file
|
|
@ -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
|
||||
69
tp5/istio-gateway-missions.yaml
Normal file
69
tp5/istio-gateway-missions.yaml
Normal file
|
|
@ -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
|
||||
|
||||
21
tp5/locustfile.py
Normal file
21
tp5/locustfile.py
Normal file
|
|
@ -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)
|
||||
17
tp5/villes-retrylogic.yaml
Normal file
17
tp5/villes-retrylogic.yaml
Normal file
|
|
@ -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
|
||||
35
tp5/web_deployment.yaml
Normal file
35
tp5/web_deployment.yaml
Normal file
|
|
@ -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
|
||||
15
tp5/web_service.yaml
Normal file
15
tp5/web_service.yaml
Normal file
|
|
@ -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" }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue