From e9cde0aef2ef5300a737372753e536c120e5c6d1 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Mon, 19 Dec 2022 08:44:17 +0100 Subject: [PATCH] Cambios en Firefly para ajustar el directorio de la base de datos. Cambios en Firefly para crear un deployment de respaldo Cambios en PGO para crear una instancia de postgres Cambios en Mediawiki y otros --- Firefly/Respaldo/copyDBK8S | 23 ++++ Firefly/Respaldo/creaTodo.sh | 4 + Firefly/Respaldo/entra.sh | 1 + Firefly/Respaldo/exporta | 2 + Firefly/Respaldo/ff-namespace.yaml | 4 + Firefly/Respaldo/ff-secrets.yaml | 12 ++ Firefly/Respaldo/ff3Logs.sh | 1 + Firefly/Respaldo/firefly-deployment.yaml | 110 ++++++++++++++++++ Firefly/Respaldo/kustomization.yaml | 7 ++ Firefly/Respaldo/lanzaCron | 1 + Firefly/Respaldo/mysql-deployment.yaml | 72 ++++++++++++ Firefly/Respaldo/paraTodo.sh | 3 + Firefly/Respaldo/php-deployment.yaml | 54 +++++++++ Firefly/Respaldo/pruebaCron | 1 + Firefly/Respaldo/pv-local-ff.yaml | 11 ++ Firefly/Respaldo/pv-local-mysql.yaml | 11 ++ Firefly/k8s-cluster/creaTodo.sh | 2 +- Firefly/k8s-cluster/entraMysql.sh | 1 + Firefly/k8s-cluster/pv-local-mysql.yaml | 2 +- MDM/creaTodo.sh | 8 ++ MDM/entra.sh | 1 + MDM/paraTodo.sh | 6 + {PGO => MDM}/pgadmin-configmap.yaml | 3 + MDM/pgadmin-deployment.yaml | 52 +++++++++ {PGO => MDM}/pgadmin-secret.yaml | 2 +- MDM/pgadmin-service.yaml | 14 +++ {PGO => MDM}/pgadmin-statefulset.yaml | 0 MDM/pv-local-pgadmin-config.yaml | 11 ++ {PGO => MDM}/pv-local-pgadmin.yaml | 0 MDM/pvc-pgadmin-config.yaml | 14 +++ MDM/pvc-pgadmin.yaml | 14 +++ Mediawiki/creaTodo.sh | 2 +- ...rraNginsIngres.sh => borraNginxIngress.sh} | 0 NextCloud/creaTodo.sh | 2 +- PGO/creaTodo.sh | 9 ++ PGO/entrapsql.sh | 1 + PGO/paraTodo.sh | 13 ++- PGO/pgadmin-service.yaml | 13 --- PGO/pgadmin/pgadmin-configmap.yaml | 23 ++++ PGO/pgadmin/pgadmin-deployment.yaml | 52 +++++++++ PGO/pgadmin/pgadmin-deployment.yaml.copia | 48 ++++++++ PGO/pgadmin/pgadmin-secret.yaml | 8 ++ PGO/pgadmin/pgadmin-service.yaml | 14 +++ PGO/pgadmin/pgadmin-statefulset.yaml | 55 +++++++++ PGO/pgadmin/pv-local-pgadmin-config.yaml | 11 ++ PGO/pgadmin/pv-local-pgadmin.yaml | 11 ++ PGO/pgadmin/pvc-pgadmin-config.yaml | 14 +++ PGO/pgadmin/pvc-pgadmin.yaml | 14 +++ PGO/postgres-configmap.yaml | 9 +- PGO/postgres-deployment.yaml | 2 +- PGO/termina.sh | 1 + Wordpress/creaTodo.sh | 2 +- creaTodoTodo.sh | 7 ++ 53 files changed, 728 insertions(+), 30 deletions(-) create mode 100755 Firefly/Respaldo/copyDBK8S create mode 100755 Firefly/Respaldo/creaTodo.sh create mode 100755 Firefly/Respaldo/entra.sh create mode 100755 Firefly/Respaldo/exporta create mode 100644 Firefly/Respaldo/ff-namespace.yaml create mode 100644 Firefly/Respaldo/ff-secrets.yaml create mode 100644 Firefly/Respaldo/ff3Logs.sh create mode 100644 Firefly/Respaldo/firefly-deployment.yaml create mode 100644 Firefly/Respaldo/kustomization.yaml create mode 100755 Firefly/Respaldo/lanzaCron create mode 100644 Firefly/Respaldo/mysql-deployment.yaml create mode 100755 Firefly/Respaldo/paraTodo.sh create mode 100644 Firefly/Respaldo/php-deployment.yaml create mode 100755 Firefly/Respaldo/pruebaCron create mode 100644 Firefly/Respaldo/pv-local-ff.yaml create mode 100644 Firefly/Respaldo/pv-local-mysql.yaml create mode 100755 Firefly/k8s-cluster/entraMysql.sh create mode 100755 MDM/creaTodo.sh create mode 100755 MDM/entra.sh create mode 100755 MDM/paraTodo.sh rename {PGO => MDM}/pgadmin-configmap.yaml (81%) create mode 100644 MDM/pgadmin-deployment.yaml rename {PGO => MDM}/pgadmin-secret.yaml (74%) create mode 100644 MDM/pgadmin-service.yaml rename {PGO => MDM}/pgadmin-statefulset.yaml (100%) create mode 100644 MDM/pv-local-pgadmin-config.yaml rename {PGO => MDM}/pv-local-pgadmin.yaml (100%) create mode 100644 MDM/pvc-pgadmin-config.yaml create mode 100644 MDM/pvc-pgadmin.yaml rename Metallb/{borraNginsIngres.sh => borraNginxIngress.sh} (100%) create mode 100755 PGO/entrapsql.sh delete mode 100644 PGO/pgadmin-service.yaml create mode 100644 PGO/pgadmin/pgadmin-configmap.yaml create mode 100644 PGO/pgadmin/pgadmin-deployment.yaml create mode 100644 PGO/pgadmin/pgadmin-deployment.yaml.copia create mode 100644 PGO/pgadmin/pgadmin-secret.yaml create mode 100644 PGO/pgadmin/pgadmin-service.yaml create mode 100644 PGO/pgadmin/pgadmin-statefulset.yaml create mode 100644 PGO/pgadmin/pv-local-pgadmin-config.yaml create mode 100644 PGO/pgadmin/pv-local-pgadmin.yaml create mode 100644 PGO/pgadmin/pvc-pgadmin-config.yaml create mode 100644 PGO/pgadmin/pvc-pgadmin.yaml create mode 100644 PGO/termina.sh create mode 100644 creaTodoTodo.sh diff --git a/Firefly/Respaldo/copyDBK8S b/Firefly/Respaldo/copyDBK8S new file mode 100755 index 00000000..dfdc92d2 --- /dev/null +++ b/Firefly/Respaldo/copyDBK8S @@ -0,0 +1,23 @@ +# Backup date + +today=$(date "+%Y_%m_%d-%H_%M_%S") + +echo "Current date: $today" + +# build up filename + +# destination folder (change to your own needs) + +BACKUP_FOLDER=/tmp + +file_name=$BACKUP_FOLDER/bkup_fireflyiii +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n firefly|grep iii-mysql|cut -f1 -d' '` -n firefly -- /usr/bin/mysqldump -u root --password=Rey-1176 fireflyiii > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "FireflyIII backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/Firefly/Respaldo/creaTodo.sh b/Firefly/Respaldo/creaTodo.sh new file mode 100755 index 00000000..e744b5fb --- /dev/null +++ b/Firefly/Respaldo/creaTodo.sh @@ -0,0 +1,4 @@ +kubectl create -f pv-local-ff.yaml +kubectl create -f pv-local-mysql.yaml +kubectl create -k ./ +#watch kubectl get all -n firefly-res diff --git a/Firefly/Respaldo/entra.sh b/Firefly/Respaldo/entra.sh new file mode 100755 index 00000000..255f30b5 --- /dev/null +++ b/Firefly/Respaldo/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/firefly-iii -n firefly -- /bin/bash diff --git a/Firefly/Respaldo/exporta b/Firefly/Respaldo/exporta new file mode 100755 index 00000000..9684a20a --- /dev/null +++ b/Firefly/Respaldo/exporta @@ -0,0 +1,2 @@ +echo "Comando '$1'" +kubectl exec -ti `kubectl get pod -n firefly | grep -v mysql |grep -v phpmy |grep -v NAME|cut -c1-27` -n firefly -- runuser -u www-data "$1" diff --git a/Firefly/Respaldo/ff-namespace.yaml b/Firefly/Respaldo/ff-namespace.yaml new file mode 100644 index 00000000..a158a33e --- /dev/null +++ b/Firefly/Respaldo/ff-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: firefly-res diff --git a/Firefly/Respaldo/ff-secrets.yaml b/Firefly/Respaldo/ff-secrets.yaml new file mode 100644 index 00000000..bae66975 --- /dev/null +++ b/Firefly/Respaldo/ff-secrets.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: firefly-iii-res-secrets + namespace: firefly-res +type: Opaque +stringData: + db_password: Rey-1176 + app_key: 4VF2JAHT5PA9VCW7EUBUJCWAWV89G9PC + access_token: 4VF2JAHT5PA9VCW7EUBUJCWAWV89G9PC + mail_user: celestino_rey@ymail.com + mail_password: kbryvwxkockqckss diff --git a/Firefly/Respaldo/ff3Logs.sh b/Firefly/Respaldo/ff3Logs.sh new file mode 100644 index 00000000..a8c980df --- /dev/null +++ b/Firefly/Respaldo/ff3Logs.sh @@ -0,0 +1 @@ +kubectl logs deployment.apps/firefly-iii -n firefly diff --git a/Firefly/Respaldo/firefly-deployment.yaml b/Firefly/Respaldo/firefly-deployment.yaml new file mode 100644 index 00000000..0f310c3c --- /dev/null +++ b/Firefly/Respaldo/firefly-deployment.yaml @@ -0,0 +1,110 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-res-upload-claim + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii-res + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + type: NodePort + ports: + - name: firefly-res + port: 8080 + nodePort: 30580 + targetPort: firefly-iii-res + selector: + app: firefly-iii-res + tier: frontend +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii-res + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + selector: + matchLabels: + app: firefly-iii-res + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii-res + tier: frontend + spec: + containers: + - image: fireflyiii/core:latest + name: firefly-iii-res + env: + - name: APP_ENV + value: local + - name: APP_KEY + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: app_key + - name: DB_HOST + value: firefly-iii-res-mysql + - name: DB_CONNECTION + value: mysql + - name: DB_DATABASE + value: "firefly-resiii" + - name: DB_USERNAME + value: "root" + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: db_password + - name: TRUSTED_PROXIES + value: "**" + - name: MAIL_MAILER + value: smtp + - name: MAIL_HOST + value: "smtp.mail.yahoo.com" + - name: MAIL_PORT + value: "465" + - name: MAIL_FROM + value: "celestino_rey@ymail.com" + - name: MAIL_USERNAME + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: mail_user + - name: MAIL_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: mail_password + - name: MAIL_ENCRYPTION + value: "ssl" + ports: + - containerPort: 8080 + name: firefly-iii-res + volumeMounts: + - mountPath: "/var/www/html/firefly-iii-res/storage/upload" + name: firefly-iii-res-upload + imagePullPolicy: Always + volumes: + - name: firefly-iii-res-upload + persistentVolumeClaim: + claimName: firefly-iii-res-upload-claim diff --git a/Firefly/Respaldo/kustomization.yaml b/Firefly/Respaldo/kustomization.yaml new file mode 100644 index 00000000..e710b9e0 --- /dev/null +++ b/Firefly/Respaldo/kustomization.yaml @@ -0,0 +1,7 @@ +resources: +- ff-namespace.yaml +- ff-secrets.yaml +- mysql-deployment.yaml +- firefly-deployment.yaml +- php-deployment.yaml + diff --git a/Firefly/Respaldo/lanzaCron b/Firefly/Respaldo/lanzaCron new file mode 100755 index 00000000..d4212f76 --- /dev/null +++ b/Firefly/Respaldo/lanzaCron @@ -0,0 +1 @@ +kubectl exec deployment.apps/firefly-iii -n firefly -- runuser -u www-data /usr/local/bin/php /var/www/html/artisan firefly-iii:cron diff --git a/Firefly/Respaldo/mysql-deployment.yaml b/Firefly/Respaldo/mysql-deployment.yaml new file mode 100644 index 00000000..d899a7fc --- /dev/null +++ b/Firefly/Respaldo/mysql-deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-res-data-pvc + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 20Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii-res-mysql + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + type: NodePort + ports: + - name: mysql + port: 3306 + nodePort: 30581 + targetPort: mysql + selector: + app: firefly-iii-res + tier: mysql +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii-res-mysql + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + selector: + matchLabels: + app: firefly-iii-res + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii-res + tier: mysql + spec: + containers: + - image: mariadb:latest + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: db_password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: firefly-iii-res-data-pvc diff --git a/Firefly/Respaldo/paraTodo.sh b/Firefly/Respaldo/paraTodo.sh new file mode 100755 index 00000000..4cba2724 --- /dev/null +++ b/Firefly/Respaldo/paraTodo.sh @@ -0,0 +1,3 @@ +kubectl delete -k ./ +kubectl delete -f pv-local-ff.yaml +kubectl delete -f pv-local-mysql.yaml diff --git a/Firefly/Respaldo/php-deployment.yaml b/Firefly/Respaldo/php-deployment.yaml new file mode 100644 index 00000000..9d70d4f8 --- /dev/null +++ b/Firefly/Respaldo/php-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin-firefly-res + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + selector: + app: firefly-iii-res + tier: phpmyadmin + type: NodePort + ports: + - name: phpadmin + port: 80 + nodePort: 30588 + targetPort: phpmyadm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin-firefly-res + namespace: firefly-res + labels: + app: firefly-iii-res +spec: + selector: + matchLabels: + app: firefly-iii-res + tier: phpmyadmin + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii-res + tier: phpmyadmin + spec: + containers: + - name: phpmyadmin + image: phpmyadmin + ports: + - containerPort: 80 + name: phpmyadm + env: + - name: PMA_HOST + value: firefly-iii-res-mysql + - name: PMA_PORT + value: "3306" + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-res-secrets + key: db_password diff --git a/Firefly/Respaldo/pruebaCron b/Firefly/Respaldo/pruebaCron new file mode 100755 index 00000000..1b04ee22 --- /dev/null +++ b/Firefly/Respaldo/pruebaCron @@ -0,0 +1 @@ +kubectl exec -ti `kubectl get pod -n firefly | grep -v mysql |grep -v phpmy |grep -v NAME|cut -c1-27` -n firefly -- runuser -u www-data touch pepe diff --git a/Firefly/Respaldo/pv-local-ff.yaml b/Firefly/Respaldo/pv-local-ff.yaml new file mode 100644 index 00000000..5d734f99 --- /dev/null +++ b/Firefly/Respaldo/pv-local-ff.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii-res +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/firefly-res/firefly-uploads" diff --git a/Firefly/Respaldo/pv-local-mysql.yaml b/Firefly/Respaldo/pv-local-mysql.yaml new file mode 100644 index 00000000..cfc64dc1 --- /dev/null +++ b/Firefly/Respaldo/pv-local-mysql.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii-res-mysql +spec: + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/firefly-res/firefly-db" diff --git a/Firefly/k8s-cluster/creaTodo.sh b/Firefly/k8s-cluster/creaTodo.sh index f1579640..d6bf0e79 100755 --- a/Firefly/k8s-cluster/creaTodo.sh +++ b/Firefly/k8s-cluster/creaTodo.sh @@ -1,4 +1,4 @@ kubectl create -f pv-local-ff.yaml kubectl create -f pv-local-mysql.yaml kubectl create -k ./ -watch kubectl get all -n firefly +#watch kubectl get all -n firefly diff --git a/Firefly/k8s-cluster/entraMysql.sh b/Firefly/k8s-cluster/entraMysql.sh new file mode 100755 index 00000000..ee7c97ec --- /dev/null +++ b/Firefly/k8s-cluster/entraMysql.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/firefly-iii-mysql -n firefly -- /bin/bash diff --git a/Firefly/k8s-cluster/pv-local-mysql.yaml b/Firefly/k8s-cluster/pv-local-mysql.yaml index 9e189263..31830bb1 100644 --- a/Firefly/k8s-cluster/pv-local-mysql.yaml +++ b/Firefly/k8s-cluster/pv-local-mysql.yaml @@ -8,4 +8,4 @@ spec: accessModes: - ReadWriteOnce hostPath: - path: "/mnt/cluster/fireflyiii/firefly-uploads" + path: "/mnt/cluster/fireflyiii/firefly-db" diff --git a/MDM/creaTodo.sh b/MDM/creaTodo.sh new file mode 100755 index 00000000..5ba30495 --- /dev/null +++ b/MDM/creaTodo.sh @@ -0,0 +1,8 @@ +# pgadmin +kubectl create -f pv-local-pgadmin.yaml +kubectl create -f pvc-pgadmin.yaml +kubectl create -f pgadmin-secret.yaml +kubectl create -f pgadmin-service.yaml +kubectl create -f pgadmin-deployment.yaml +kubectl create -f pgadmin-configmap.yaml +watch kubectl get all -n postgres diff --git a/MDM/entra.sh b/MDM/entra.sh new file mode 100755 index 00000000..87f15102 --- /dev/null +++ b/MDM/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/postgres -n postgres -- /bin/bash diff --git a/MDM/paraTodo.sh b/MDM/paraTodo.sh new file mode 100755 index 00000000..b1cb43ad --- /dev/null +++ b/MDM/paraTodo.sh @@ -0,0 +1,6 @@ +kubectl delete -f pgadmin-configmap.yaml +kubectl delete -f pgadmin-secret.yaml +kubectl delete -f pgadmin-service.yaml +kubectl delete -f pgadmin-deployment.yaml +kubectl delete -f pvc-pgadmin.yaml +kubectl delete -f pv-local-pgadmin.yaml diff --git a/PGO/pgadmin-configmap.yaml b/MDM/pgadmin-configmap.yaml similarity index 81% rename from PGO/pgadmin-configmap.yaml rename to MDM/pgadmin-configmap.yaml index 83eeba6d..a4d05c96 100644 --- a/PGO/pgadmin-configmap.yaml +++ b/MDM/pgadmin-configmap.yaml @@ -18,3 +18,6 @@ data: } } } + config_local.py: | + SECURITY_EMAIL_VALIDATOR_ARGS={"check_deliverability": False} + diff --git a/MDM/pgadmin-deployment.yaml b/MDM/pgadmin-deployment.yaml new file mode 100644 index 00000000..541075b8 --- /dev/null +++ b/MDM/pgadmin-deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pgadmin + namespace: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: pgadmin + template: + metadata: + labels: + app: pgadmin + spec: + initContainers: + - name: pgadmin-init + image: alpine + args: [ "sh", "-c", "chown 5050:5050 /var/lib/pgadmin " ] + volumeMounts: + - name: pgadmin-data + mountPath: /var/lib/pgadmin + containers: + - name: pgadmin + image: ubuntu + imagePullPolicy: Always + env: + - name: PGADMIN_DEFAULT_EMAIL + value: creylopez@yahoo.es + - name: PGADMIN_DEFAULT_PASSWORD + valueFrom: + secretKeyRef: + name: pgadmin + key: pgadmin-password + volumeMounts: + - name: pgadmin-config + mountPath: /pgadmin4/servers.json + subPath: servers.json + readOnly: true + - name: pgadmin-config + mountPath: /pgadmin4/config_local.py + subPath: config_local.py + readOnly: true + - name: pgadmin-data + mountPath: /var/lib/pgadmin + volumes: + - name: pgadmin-config + configMap: + name: pgadmin-config + - name: pgadmin-data + persistentVolumeClaim: + claimName: pgadmin-pv-claim diff --git a/PGO/pgadmin-secret.yaml b/MDM/pgadmin-secret.yaml similarity index 74% rename from PGO/pgadmin-secret.yaml rename to MDM/pgadmin-secret.yaml index 96a37dba..aa3aa847 100644 --- a/PGO/pgadmin-secret.yaml +++ b/MDM/pgadmin-secret.yaml @@ -5,4 +5,4 @@ metadata: name: pgadmin namespace: postgres data: - pgadmin-password: UmV5LTExNzYK + pgadmin-password: UmV5MTE3Ngo= diff --git a/MDM/pgadmin-service.yaml b/MDM/pgadmin-service.yaml new file mode 100644 index 00000000..e6e6416b --- /dev/null +++ b/MDM/pgadmin-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service # Create service +metadata: + name: pgadmin # Sets the service name + namespace: postgres + labels: + app: pgadmin # Defines app to create service for +spec: + type: NodePort # Sets the service type + ports: + - port: 80 # Sets the port to run the postgres application + nodePort: 30200 + selector: + app: pgadmin diff --git a/PGO/pgadmin-statefulset.yaml b/MDM/pgadmin-statefulset.yaml similarity index 100% rename from PGO/pgadmin-statefulset.yaml rename to MDM/pgadmin-statefulset.yaml diff --git a/MDM/pv-local-pgadmin-config.yaml b/MDM/pv-local-pgadmin-config.yaml new file mode 100644 index 00000000..c2718b16 --- /dev/null +++ b/MDM/pv-local-pgadmin-config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pgadmin-config +spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/postgres/pgadmin-config" diff --git a/PGO/pv-local-pgadmin.yaml b/MDM/pv-local-pgadmin.yaml similarity index 100% rename from PGO/pv-local-pgadmin.yaml rename to MDM/pv-local-pgadmin.yaml diff --git a/MDM/pvc-pgadmin-config.yaml b/MDM/pvc-pgadmin-config.yaml new file mode 100644 index 00000000..9c7ec983 --- /dev/null +++ b/MDM/pvc-pgadmin-config.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pgadmin-config-pv-claim + namespace: postgres + labels: + app: postgres +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 1Gi diff --git a/MDM/pvc-pgadmin.yaml b/MDM/pvc-pgadmin.yaml new file mode 100644 index 00000000..6e862d01 --- /dev/null +++ b/MDM/pvc-pgadmin.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pgadmin-pv-claim + namespace: postgres + labels: + app: postgres +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 3Gi diff --git a/Mediawiki/creaTodo.sh b/Mediawiki/creaTodo.sh index 8b914d0f..5c97afdf 100755 --- a/Mediawiki/creaTodo.sh +++ b/Mediawiki/creaTodo.sh @@ -1,4 +1,4 @@ kubectl create -f pv-local-mysql-mw.yaml kubectl create -f pv-local-mediawiki.yaml kubectl create -k ./ -watch kubectl get all -n mediawiki +#watch kubectl get all -n mediawiki diff --git a/Metallb/borraNginsIngres.sh b/Metallb/borraNginxIngress.sh similarity index 100% rename from Metallb/borraNginsIngres.sh rename to Metallb/borraNginxIngress.sh diff --git a/NextCloud/creaTodo.sh b/NextCloud/creaTodo.sh index ff1607a0..28258c17 100755 --- a/NextCloud/creaTodo.sh +++ b/NextCloud/creaTodo.sh @@ -1,4 +1,4 @@ kubectl create -f pv-local-nextcloud.yaml kubectl create -f pv-local-mysql.yaml kubectl create -k ./ -watch kubectl get all -n nextcloud +#watch kubectl get all -n nextcloud diff --git a/PGO/creaTodo.sh b/PGO/creaTodo.sh index 09fc3198..4f0771b8 100755 --- a/PGO/creaTodo.sh +++ b/PGO/creaTodo.sh @@ -3,4 +3,13 @@ kubectl create -f pvc-pg.yaml kubectl create -f postgres-configmap.yaml kubectl create -f postgres-deployment.yaml kubectl create -f postgres-service.yaml +# pgadmin +#kubectl create -f pv-local-pgadmin.yaml +#kubectl create -f pvc-pgadmin.yaml +#kubectl create -f pgadmin-secret.yaml +#kubectl create -f pgadmin-service.yaml +#kubectl create -f pgadmin-deployment.yaml +#kubectl create -f pgadmin-configmap.yaml +kubectl create -f pv-local-phppgadmin.yaml +kubectl create -f phppgadmin-deployment.yaml watch kubectl get all -n postgres diff --git a/PGO/entrapsql.sh b/PGO/entrapsql.sh new file mode 100755 index 00000000..c40ab79e --- /dev/null +++ b/PGO/entrapsql.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/postgres -n postgres -- psql -h localhost -U postgres --password -p 5432 postgresdb diff --git a/PGO/paraTodo.sh b/PGO/paraTodo.sh index 0a0d9a28..ed19ce5f 100755 --- a/PGO/paraTodo.sh +++ b/PGO/paraTodo.sh @@ -3,8 +3,11 @@ kubectl delete -f postgres-deployment.yaml kubectl delete -f postgres-configmap.yaml kubectl delete -f pvc-pg.yaml kubectl delete -f pv-local-pg.yaml -kubectl delete -f pgadmin-configmap.yaml -kubectl delete -f pgadmin-secret.yaml -kubectl delete -f pgadmin-service.yaml -kubectl delete -f pgadmin-statefulset.yaml -kubectl delete -f pv-local-pgadmin.yaml +#kubectl delete -f pgadmin-configmap.yaml +#kubectl delete -f pgadmin-secret.yaml +#kubectl delete -f pgadmin-service.yaml +#kubectl delete -f pgadmin-deployment.yaml +#kubectl delete -f pvc-pgadmin.yaml +#kubectl delete -f pv-local-pgadmin.yaml +kubectl delete -f phppgadmin-deployment.yaml +kubectl delete -f pv-local-phppgadmin.yaml diff --git a/PGO/pgadmin-service.yaml b/PGO/pgadmin-service.yaml deleted file mode 100644 index 4da00433..00000000 --- a/PGO/pgadmin-service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: pgadmin-service - namespace: postgres -spec: - ports: - - protocol: TCP - port: 80 - targetPort: http - selector: - app: pgadmin - type: NodePort diff --git a/PGO/pgadmin/pgadmin-configmap.yaml b/PGO/pgadmin/pgadmin-configmap.yaml new file mode 100644 index 00000000..a4d05c96 --- /dev/null +++ b/PGO/pgadmin/pgadmin-configmap.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: pgadmin-config + namespace: postgres +data: + servers.json: | + { + "Servers": { + "1": { + "Name": "PostgreSQL DB", + "Group": "Servers", + "Port": 5432, + "Username": "postgres", + "Host": "postgres", + "SSLMode": "prefer", + "MaintenanceDB": "postgres" + } + } + } + config_local.py: | + SECURITY_EMAIL_VALIDATOR_ARGS={"check_deliverability": False} + diff --git a/PGO/pgadmin/pgadmin-deployment.yaml b/PGO/pgadmin/pgadmin-deployment.yaml new file mode 100644 index 00000000..0d5f2cd3 --- /dev/null +++ b/PGO/pgadmin/pgadmin-deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pgadmin + namespace: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: pgadmin + template: + metadata: + labels: + app: pgadmin + spec: + initContainers: + - name: pgadmin-init + image: alpine + args: [ "sh", "-c", "chown 5050:5050 /var/lib/pgadmin " ] + volumeMounts: + - name: pgadmin-data + mountPath: /var/lib/pgadmin + containers: + - name: pgadmin + image: dpage/pgadmin4:6.17 + imagePullPolicy: Always + env: + - name: PGADMIN_DEFAULT_EMAIL + value: creylopez@yahoo.es + - name: PGADMIN_DEFAULT_PASSWORD + valueFrom: + secretKeyRef: + name: pgadmin + key: pgadmin-password + volumeMounts: + - name: pgadmin-config + mountPath: /pgadmin4/servers.json + subPath: servers.json + readOnly: true + - name: pgadmin-config + mountPath: /pgadmin4/config_local.py + subPath: config_local.py + readOnly: true + - name: pgadmin-data + mountPath: /var/lib/pgadmin + volumes: + - name: pgadmin-config + configMap: + name: pgadmin-config + - name: pgadmin-data + persistentVolumeClaim: + claimName: pgadmin-pv-claim diff --git a/PGO/pgadmin/pgadmin-deployment.yaml.copia b/PGO/pgadmin/pgadmin-deployment.yaml.copia new file mode 100644 index 00000000..12d095af --- /dev/null +++ b/PGO/pgadmin/pgadmin-deployment.yaml.copia @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pgadmin + namespace: postgres +spec: + replicas: 1 + selector: + matchLabels: + app: pgadmin + template: + metadata: + labels: + app: pgadmin + spec: + initContainers: + - name: pgadmin-init + image: alpine + args: [ "sh", "-c", "chown 5050:5050 /var/lib/pgadmin " ] + volumeMounts: + - name: pgadmin-data + mountPath: /var/lib/pgadmin + containers: + - name: pgadmin + image: dpage/pgadmin4:5.5 + imagePullPolicy: Always + env: + - name: PGADMIN_DEFAULT_EMAIL + value: celestino.rey@gmail.com + - name: PGADMIN_DEFAULT_PASSWORD + valueFrom: + secretKeyRef: + name: pgadmin + key: pgadmin-password + volumeMounts: + - name: pgadmin-config + mountPath: /pgadmin4/servers.json + subPath: servers.json + readOnly: true + - name: pgadmin-data + mountPath: /var/lib/pgadmin + volumes: + - name: pgadmin-config + configMap: + name: pgadmin-config + - name: pgadmin-data + persistentVolumeClaim: + claimName: pgadmin-pv-claim diff --git a/PGO/pgadmin/pgadmin-secret.yaml b/PGO/pgadmin/pgadmin-secret.yaml new file mode 100644 index 00000000..aa3aa847 --- /dev/null +++ b/PGO/pgadmin/pgadmin-secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: pgadmin + namespace: postgres +data: + pgadmin-password: UmV5MTE3Ngo= diff --git a/PGO/pgadmin/pgadmin-service.yaml b/PGO/pgadmin/pgadmin-service.yaml new file mode 100644 index 00000000..e6e6416b --- /dev/null +++ b/PGO/pgadmin/pgadmin-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service # Create service +metadata: + name: pgadmin # Sets the service name + namespace: postgres + labels: + app: pgadmin # Defines app to create service for +spec: + type: NodePort # Sets the service type + ports: + - port: 80 # Sets the port to run the postgres application + nodePort: 30200 + selector: + app: pgadmin diff --git a/PGO/pgadmin/pgadmin-statefulset.yaml b/PGO/pgadmin/pgadmin-statefulset.yaml new file mode 100644 index 00000000..78ba5dd4 --- /dev/null +++ b/PGO/pgadmin/pgadmin-statefulset.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: pgadmin + namespace: postgres +spec: + serviceName: pgadmin-service + podManagementPolicy: Parallel + replicas: 1 + updateStrategy: + type: RollingUpdate + selector: + matchLabels: + app: pgadmin + template: + metadata: + labels: + app: pgadmin + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: pgadmin + image: dpage/pgadmin4:5.4 + imagePullPolicy: Always + env: + - name: PGADMIN_DEFAULT_EMAIL + value: celestino.rey@gmail.com + - name: PGADMIN_DEFAULT_PASSWORD + valueFrom: + secretKeyRef: + name: pgadmin + key: pgadmin-password + ports: + - name: http + containerPort: 80 + protocol: TCP + volumeMounts: + - name: pgadmin-config + mountPath: /pgadmin4/servers.json + subPath: servers.json + readOnly: true + - name: pgadmin-data + mountPath: /var/lib/pgadmin + volumes: + - name: pgadmin-config + configMap: + name: pgadmin-config + volumeClaimTemplates: + - metadata: + name: pgadmin-data + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 3Gi diff --git a/PGO/pgadmin/pv-local-pgadmin-config.yaml b/PGO/pgadmin/pv-local-pgadmin-config.yaml new file mode 100644 index 00000000..c2718b16 --- /dev/null +++ b/PGO/pgadmin/pv-local-pgadmin-config.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pgadmin-config +spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/postgres/pgadmin-config" diff --git a/PGO/pgadmin/pv-local-pgadmin.yaml b/PGO/pgadmin/pv-local-pgadmin.yaml new file mode 100644 index 00000000..f24d0fba --- /dev/null +++ b/PGO/pgadmin/pv-local-pgadmin.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pgadmin-data +spec: + capacity: + storage: 3Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/postgres/pgadmin" diff --git a/PGO/pgadmin/pvc-pgadmin-config.yaml b/PGO/pgadmin/pvc-pgadmin-config.yaml new file mode 100644 index 00000000..9c7ec983 --- /dev/null +++ b/PGO/pgadmin/pvc-pgadmin-config.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pgadmin-config-pv-claim + namespace: postgres + labels: + app: postgres +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 1Gi diff --git a/PGO/pgadmin/pvc-pgadmin.yaml b/PGO/pgadmin/pvc-pgadmin.yaml new file mode 100644 index 00000000..6e862d01 --- /dev/null +++ b/PGO/pgadmin/pvc-pgadmin.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pgadmin-pv-claim + namespace: postgres + labels: + app: postgres +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 3Gi diff --git a/PGO/postgres-configmap.yaml b/PGO/postgres-configmap.yaml index 2f3b1d13..2ce72465 100644 --- a/PGO/postgres-configmap.yaml +++ b/PGO/postgres-configmap.yaml @@ -1,13 +1,12 @@ -# Create ConfigMap postgres-secret for the postgres app -# Define default database name, user, and password apiVersion: v1 kind: ConfigMap metadata: - name: postgres-secret + name: postgres-config namespace: postgres labels: app: postgres data: - POSTGRES_DB: productos - POSTGRES_USER: creylopez + POSTGRES_DB: postgresdb + POSTGRES_USER: postgres POSTGRES_PASSWORD: Rey-1176 + diff --git a/PGO/postgres-deployment.yaml b/PGO/postgres-deployment.yaml index 2b597f9e..6e774252 100644 --- a/PGO/postgres-deployment.yaml +++ b/PGO/postgres-deployment.yaml @@ -21,7 +21,7 @@ spec: - containerPort: 5432 # Exposing the container port 5432 for PostgreSQL client connections. envFrom: - configMapRef: - name: postgres-secret # Using the ConfigMap postgres-secret + name: postgres-config # Using the ConfigMap postgres-secret volumeMounts: - mountPath: /var/lib/postgresql/data name: postgresdata diff --git a/PGO/termina.sh b/PGO/termina.sh new file mode 100644 index 00000000..cd8b1b07 --- /dev/null +++ b/PGO/termina.sh @@ -0,0 +1 @@ +kubectl patch pv pgadmin-data -p '{"metadata":{"finalizers":null}}' diff --git a/Wordpress/creaTodo.sh b/Wordpress/creaTodo.sh index 286979f5..4b98cc0b 100755 --- a/Wordpress/creaTodo.sh +++ b/Wordpress/creaTodo.sh @@ -1,4 +1,4 @@ kubectl create -f pv-local-mysql.yaml kubectl create -f pv-local-wordpress.yaml kubectl create -k ./ -watch kubectl get all -n wordpress +#watch kubectl get all -n wordpress diff --git a/creaTodoTodo.sh b/creaTodoTodo.sh new file mode 100644 index 00000000..b7ec39bf --- /dev/null +++ b/creaTodoTodo.sh @@ -0,0 +1,7 @@ +raiz=$PWD +for i in Mediawiki Firefly/k8s-cluster Nginx Wordpress NextCloud +do + cd $i + sh creaTodo.sh + cd $raiz +done