diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..94a08cb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.9 + +WORKDIR /app + +COPY . /app + +RUN pip install -r requirements.txt + +ENTRYPOINT FLASK_APP=app.py flask run --host=0.0.0.0 --port=5000 diff --git a/k8s/deployment.yml b/k8s/deployment.yml new file mode 100644 index 0000000..bc54226 --- /dev/null +++ b/k8s/deployment.yml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: flask-app + namespace: flask-ns + labels: + app: flask +spec: + selector: + matchLabels: + app: flask + template: + metadata: + labels: + app: flask + spec: + containers: + - name: flask-container + image: sharmaaakash170/basic-flask-app:latest + resources: + limits: + cpu: "500m" + requests: + cpu: "100m" + ports: + - containerPort: 5000 diff --git a/k8s/hpa.yml b/k8s/hpa.yml new file mode 100644 index 0000000..3c99edd --- /dev/null +++ b/k8s/hpa.yml @@ -0,0 +1,21 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: flask-hpa + namespace: flask-ns + labels: + app: flask +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: flask-app + minReplicas: 1 + maxReplicas: 5 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 5 diff --git a/k8s/namespace.yml b/k8s/namespace.yml new file mode 100644 index 0000000..b3e33b0 --- /dev/null +++ b/k8s/namespace.yml @@ -0,0 +1,5 @@ +kind: Namespace +apiVersion: v1 +metadata: + name: flask-ns + \ No newline at end of file diff --git a/k8s/service.yml b/k8s/service.yml new file mode 100644 index 0000000..87e4071 --- /dev/null +++ b/k8s/service.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: flask-service + namespace: flask-ns + labels: + app: flask +spec: + selector: + app: flask + ports: + - port: 5000 + targetPort: 5000 + protocol: TCP