diff --git a/Libros/K8S/Makefile b/Libros/K8S/Makefile new file mode 100644 index 0000000..4a75550 --- /dev/null +++ b/Libros/K8S/Makefile @@ -0,0 +1,20 @@ +include ../servicios/.env +export IMG_VERSION = ${VERSION} +# limpia todo +all: imagen clean install + +imagen: + cd ../servicios; make + +install: + -kubectl create -f pv-local-libros.yaml + -kubectl create -f libros-prod-persistentvolumeclaim.yaml + -envsubst < libros-deployment.yaml |kubectl create -f - + +clean: + -envsubst < libros-deployment.yaml |kubectl delete -f - + -kubectl delete -f libros-prod-persistentvolumeclaim.yaml + -kubectl delete -f pv-local-libros.yaml + +prueba: + @echo $(VERSION) diff --git a/Libros/K8S/entra.sh b/Libros/K8S/entra.sh new file mode 100644 index 0000000..308aa14 --- /dev/null +++ b/Libros/K8S/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/libros -- /bin/bash diff --git a/Libros/K8S/libros-deployment.yaml b/Libros/K8S/libros-deployment.yaml new file mode 100644 index 0000000..28c447d --- /dev/null +++ b/Libros/K8S/libros-deployment.yaml @@ -0,0 +1,65 @@ +apiVersion: v1 +kind: Service +metadata: + name: libros +spec: + type: NodePort + ports: + - name: http + port: 5000 + nodePort: 30340 + targetPort: libros + selector: + app: libros +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: libros + labels: + app: libros +spec: + replicas: 1 + selector: + matchLabels: + app: libros + strategy: + type: Recreate + template: + metadata: + labels: + app: libros + spec: + containers: + - args: + - gunicorn + - --bind + - 0.0.0.0:5000 + - libros:create_app() + name: libros + image: registry.reymota.es/libros:$IMG_VERSION + env: + - name: VERSION + value: "$IMG_VERSION" + - name: ENVIRONMENT + value: "Producción" + ports: + - containerPort: 5000 + name: libros + resources: {} + volumeMounts: + - mountPath: /libros/instance + name: libros-instance + - mountPath: /libros/migrations + name: libros-migrations + imagePullSecrets: + - name: myregistrykey + restartPolicy: Always + volumes: + - name: libros-instance + persistentVolumeClaim: + claimName: libros-instance + - name: libros-migrations + persistentVolumeClaim: + claimName: libros-migrations +status: {} diff --git a/Libros/K8S/libros-prod-persistentvolumeclaim.yaml b/Libros/K8S/libros-prod-persistentvolumeclaim.yaml new file mode 100644 index 0000000..416c734 --- /dev/null +++ b/Libros/K8S/libros-prod-persistentvolumeclaim.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: libros-instance + name: libros-instance +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: libros-migrations + name: libros-migrations +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 50Mi +status: {} + diff --git a/Libros/K8S/pv-local-libros.yaml b/Libros/K8S/pv-local-libros.yaml new file mode 100644 index 0000000..2c503a2 --- /dev/null +++ b/Libros/K8S/pv-local-libros.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: libros-instance-folder + labels: + app: libros +spec: + capacity: + storage: 100Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/libros/instance" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: libros-migrations-folder + labels: + app: libros +spec: + capacity: + storage: 50Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/libros/migrations" + diff --git a/Libros/K8S/pv-local-repostajes.yaml b/Libros/K8S/pv-local-repostajes.yaml new file mode 100644 index 0000000..2c503a2 --- /dev/null +++ b/Libros/K8S/pv-local-repostajes.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: libros-instance-folder + labels: + app: libros +spec: + capacity: + storage: 100Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/libros/instance" +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: libros-migrations-folder + labels: + app: libros +spec: + capacity: + storage: 50Mi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/libros/migrations" + diff --git a/Libros/K8S/verImg.sh b/Libros/K8S/verImg.sh new file mode 100644 index 0000000..1b455b4 --- /dev/null +++ b/Libros/K8S/verImg.sh @@ -0,0 +1 @@ +docker run -it creylopez/libros:1.0 bash diff --git a/Libros/biblioteca/.env b/Libros/biblioteca/.env new file mode 100644 index 0000000..d53e27c --- /dev/null +++ b/Libros/biblioteca/.env @@ -0,0 +1 @@ +VERSION=1.0 diff --git a/Libros/biblioteca/Makefile b/Libros/biblioteca/Makefile new file mode 100644 index 0000000..e8aecc4 --- /dev/null +++ b/Libros/biblioteca/Makefile @@ -0,0 +1,8 @@ +install: + + echo "Creando imagen con version ${IMG_VERSION}" + + docker build --no-cache -t registry.reymota.es/libros:${IMG_VERSION} . + docker push registry.reymota.es/libros:${IMG_VERSION} + + diff --git a/Libros/biblioteca/libros.sqlite3 b/Libros/biblioteca/libros.sqlite3 index a710c9e..f9b9f4d 100644 Binary files a/Libros/biblioteca/libros.sqlite3 and b/Libros/biblioteca/libros.sqlite3 differ diff --git a/Libros/biblioteca/profile_images/nebraska.jpg b/Libros/biblioteca/profile_images/nebraska.jpg new file mode 100644 index 0000000..eebc1a5 Binary files /dev/null and b/Libros/biblioteca/profile_images/nebraska.jpg differ diff --git a/Libros/biblioteca/profile_images/theriver.jpg b/Libros/biblioteca/profile_images/theriver.jpg new file mode 100644 index 0000000..3caa7cd Binary files /dev/null and b/Libros/biblioteca/profile_images/theriver.jpg differ