From 36281d32efd525f37b20c7876bd11b2a02482740 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 5 Jul 2024 09:45:53 +0200 Subject: [PATCH] =?UTF-8?q?Preparaci=C3=B3n=20para=20k8s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReymotaPy/K8S/entra.sh | 1 + ReymotaPy/K8S/pv-local-reymotapy.yaml | 14 +++++ ReymotaPy/K8S/reymotapy-deployment.yaml | 53 +++++++++++++++++++ .../reymotapy-prod-persistentvolumeclaim.yaml | 14 +++++ ReymotaPy/K8S/verImg.sh | 1 + ReymotaPy/servicios/reymotapy/Dockerfile | 8 +-- .../servicios/reymotapy/requirements.txt | 14 +++++ ReymotaPy/servicios/reymotapy/verImg.sh | 1 + 8 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 ReymotaPy/K8S/entra.sh create mode 100644 ReymotaPy/K8S/pv-local-reymotapy.yaml create mode 100644 ReymotaPy/K8S/reymotapy-deployment.yaml create mode 100644 ReymotaPy/K8S/reymotapy-prod-persistentvolumeclaim.yaml create mode 100644 ReymotaPy/K8S/verImg.sh create mode 100644 ReymotaPy/servicios/reymotapy/requirements.txt create mode 100644 ReymotaPy/servicios/reymotapy/verImg.sh diff --git a/ReymotaPy/K8S/entra.sh b/ReymotaPy/K8S/entra.sh new file mode 100644 index 0000000..e41ec11 --- /dev/null +++ b/ReymotaPy/K8S/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/lyrics -- /bin/bash \ No newline at end of file diff --git a/ReymotaPy/K8S/pv-local-reymotapy.yaml b/ReymotaPy/K8S/pv-local-reymotapy.yaml new file mode 100644 index 0000000..627fc2e --- /dev/null +++ b/ReymotaPy/K8S/pv-local-reymotapy.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: reymotapy-app-folder + labels: + app: reymotapy +spec: + capacity: + storage: 100Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/reymotapy" + diff --git a/ReymotaPy/K8S/reymotapy-deployment.yaml b/ReymotaPy/K8S/reymotapy-deployment.yaml new file mode 100644 index 0000000..34a610d --- /dev/null +++ b/ReymotaPy/K8S/reymotapy-deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: v1 +kind: Service +metadata: + name: reymotapy +spec: + type: NodePort + ports: + - name: http + port: 5000 + nodePort: 30338 + targetPort: reymotapy + selector: + app: reymotapy +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: reymotapy + labels: + app: reymotapy +spec: + replicas: 1 + selector: + matchLabels: + app: reymotapy + strategy: + type: Recreate + template: + metadata: + labels: + app: reymotapy + spec: + containers: + - args: + - gunicorn + - --bind + - 0.0.0.0:5000 + - reymotapy:create_app() + image: creylopez/reymotapy:1.0 + name: reymotapy + ports: + - containerPort: 5000 + name: reymotapy + resources: {} + volumeMounts: + - mountPath: /reymotapy/instance + name: reymotapy-prod + restartPolicy: Always + volumes: + - name: reymotapy-prod + persistentVolumeClaim: + claimName: reymotapy-prod +status: {} diff --git a/ReymotaPy/K8S/reymotapy-prod-persistentvolumeclaim.yaml b/ReymotaPy/K8S/reymotapy-prod-persistentvolumeclaim.yaml new file mode 100644 index 0000000..eff329e --- /dev/null +++ b/ReymotaPy/K8S/reymotapy-prod-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: reymotapy-prod + name: reymotapy-prod +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} diff --git a/ReymotaPy/K8S/verImg.sh b/ReymotaPy/K8S/verImg.sh new file mode 100644 index 0000000..bfef918 --- /dev/null +++ b/ReymotaPy/K8S/verImg.sh @@ -0,0 +1 @@ +docker run -it creylopez/lyrics:5.3 bash diff --git a/ReymotaPy/servicios/reymotapy/Dockerfile b/ReymotaPy/servicios/reymotapy/Dockerfile index 67ca6b1..a5ec5ff 100644 --- a/ReymotaPy/servicios/reymotapy/Dockerfile +++ b/ReymotaPy/servicios/reymotapy/Dockerfile @@ -2,11 +2,11 @@ FROM python:3.8-slim-buster -WORKDIR /lyrics +WORKDIR /reymotapy # set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 # install system dependencies RUN apt-get update && apt-get install -y sqlite3 @@ -17,4 +17,4 @@ RUN pip3 install -r requirements.txt COPY . . # run entrypoint.sh -ENTRYPOINT ["/lyrics/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/reymotapy/entrypoint.sh"] diff --git a/ReymotaPy/servicios/reymotapy/requirements.txt b/ReymotaPy/servicios/reymotapy/requirements.txt new file mode 100644 index 0000000..99749ea --- /dev/null +++ b/ReymotaPy/servicios/reymotapy/requirements.txt @@ -0,0 +1,14 @@ +blinker==1.8.2 +click==8.1.7 +Flask==3.0.3 +Flask-Login==0.6.3 +Flask-SQLAlchemy==3.1.1 +greenlet==3.0.3 +gunicorn==22.0.0 +itsdangerous==2.2.0 +Jinja2==3.1.4 +MarkupSafe==2.1.5 +packaging==24.1 +SQLAlchemy==2.0.31 +typing_extensions==4.12.2 +Werkzeug==3.0.3 diff --git a/ReymotaPy/servicios/reymotapy/verImg.sh b/ReymotaPy/servicios/reymotapy/verImg.sh new file mode 100644 index 0000000..b4109ff --- /dev/null +++ b/ReymotaPy/servicios/reymotapy/verImg.sh @@ -0,0 +1 @@ +docker run -it creylopez/reymotapy:1.0 bash