Browse Source

Lo preparo (a medias) para kubernetes

politica
Celestino Rey 1 year ago
parent
commit
57c9e79e1d
12 changed files with 182 additions and 0 deletions
  1. +20
    -0
      Libros/K8S/Makefile
  2. +1
    -0
      Libros/K8S/entra.sh
  3. +65
    -0
      Libros/K8S/libros-deployment.yaml
  4. +30
    -0
      Libros/K8S/libros-prod-persistentvolumeclaim.yaml
  5. +28
    -0
      Libros/K8S/pv-local-libros.yaml
  6. +28
    -0
      Libros/K8S/pv-local-repostajes.yaml
  7. +1
    -0
      Libros/K8S/verImg.sh
  8. +1
    -0
      Libros/biblioteca/.env
  9. +8
    -0
      Libros/biblioteca/Makefile
  10. BIN
      Libros/biblioteca/libros.sqlite3
  11. BIN
      Libros/biblioteca/profile_images/nebraska.jpg
  12. BIN
      Libros/biblioteca/profile_images/theriver.jpg

+ 20
- 0
Libros/K8S/Makefile View File

@ -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)

+ 1
- 0
Libros/K8S/entra.sh View File

@ -0,0 +1 @@
kubectl exec -ti deployment.apps/libros -- /bin/bash

+ 65
- 0
Libros/K8S/libros-deployment.yaml View File

@ -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: {}

+ 30
- 0
Libros/K8S/libros-prod-persistentvolumeclaim.yaml View File

@ -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: {}

+ 28
- 0
Libros/K8S/pv-local-libros.yaml View File

@ -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"

+ 28
- 0
Libros/K8S/pv-local-repostajes.yaml View File

@ -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"

+ 1
- 0
Libros/K8S/verImg.sh View File

@ -0,0 +1 @@
docker run -it creylopez/libros:1.0 bash

+ 1
- 0
Libros/biblioteca/.env View File

@ -0,0 +1 @@
VERSION=1.0

+ 8
- 0
Libros/biblioteca/Makefile View File

@ -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}

BIN
Libros/biblioteca/libros.sqlite3 View File


BIN
Libros/biblioteca/profile_images/nebraska.jpg View File

Before After
Width: 320  |  Height: 320  |  Size: 34 KiB

BIN
Libros/biblioteca/profile_images/theriver.jpg View File

Before After
Width: 320  |  Height: 320  |  Size: 34 KiB

Loading…
Cancel
Save