Skip to content
Snippets Groups Projects
Commit f0490488 authored by BABA Salma's avatar BABA Salma
Browse files

Merge branch 'salma-tp3' into 'main'

Salma tp3

See merge request !2
parents d6290f00 b0654222
Branches main
No related tags found
1 merge request!2Salma tp3
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-deployment
labels:
app: hello
spec:
replicas: 3
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello-container
image: my-hello-kube:1.0
ports:
- containerPort: 81
# On part d'une image Python légère
FROM python:3.9-alpine
# On crée un répertoire /app dans le conteneur
WORKDIR /app
# On copie le code
COPY app.py /app
# On installe Flask
RUN pip install flask
# On documente le port
EXPOSE 80
# Commande de démarrage
CMD ["python", "app.py"]
# app.py
import uuid
from flask import Flask
app = Flask(__name__)
# Génère un identifiant unique (8 premiers caractères seulement)
unique_id = str(uuid.uuid4())[:8]
@app.route("/")
def hello():
return f"""
<h1>Hello Polytech Kubernetes!</h1>
<p>Pod unique ID: <b>{unique_id}</b></p>
"""
if __name__ == "__main__":
# Écoute sur le port 80
app.run(host="0.0.0.0", port=81)
apiVersion: v1
kind: Service
metadata:
name: hello-service
spec:
selector:
app: hello
type: NodePort
ports:
- protocol: TCP
port: 81 # Port du service
targetPort: 81 # Port dans le conteneur
nodePort: 30080 # Port visible depuis ta machine
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment