diff --git a/Drupal/copyMediawikiDB b/Drupal/copyMediawikiDB new file mode 100755 index 00000000..7a882042 --- /dev/null +++ b/Drupal/copyMediawikiDB @@ -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_drupal +new_name=$file_name-$today.sql +echo "Backup file name: " "$new_name" + +sudo docker exec `sudo docker container ls | grep mysql_drupal | cut -f1 -d' '` /usr/bin/mysqldump -u root --password=Dsa-0213 drupal > $new_name + +message="Backup stored "$today + +sudo -u creylopez cat $new_name | mail -s "Drupal backup finished" "creylopez@yahoo.es" + +sudo rm $new_name diff --git a/Drupal/creaTodo.sh b/Drupal/creaTodo.sh new file mode 100755 index 00000000..a3e03c8b --- /dev/null +++ b/Drupal/creaTodo.sh @@ -0,0 +1,4 @@ +kubectl create -f pv-local-mysql-drupal.yaml +kubectl create -f pv-local-drupal.yaml +kubectl create -k ./ +watch kubectl get all -n drupal diff --git a/Drupal/drupal-deployment.yaml b/Drupal/drupal-deployment.yaml new file mode 100644 index 00000000..5f3cdfea --- /dev/null +++ b/Drupal/drupal-deployment.yaml @@ -0,0 +1,101 @@ +apiVersion: v1 +kind: Service +metadata: + name: drupal + namespace: drupal + labels: + app: drupal +spec: + type: NodePort + ports: + - port: 80 + nodePort: 30898 + targetPort: drupal + selector: + app: drupal + tier: frontend +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: drupal-pv-claim + namespace: drupal + labels: + app: drupal +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: drupal + namespace: drupal + labels: + app: drupal +spec: + selector: + matchLabels: + app: drupal + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: drupal + tier: frontend + spec: + initContainers: + - + name: init-sites-volume + image: drupal:latest + command: ['/bin/bash', '-c'] + args: ['cp -r /var/www/html/sites/ /data/; chown www-data:www-data /data/ -R'] + volumeMounts: + - mountPath: /data + name: drupal-persistent-storage + containers: + - image: drupal:latest + name: drupal + env: + - name: DB_TYPE + value: mysql + - name: DB_NAME + value: drupal + - name: DB_HOST + value: drupal-mysql + - name: DB_PASS + valueFrom: + secretKeyRef: + name: mysqldrupal-pass + key: password + - name: DB_USER + valueFrom: + secretKeyRef: + name: mysqldrupal-pass + key: db_user + ports: + - containerPort: 80 + name: drupal + volumeMounts: + - name: drupal-persistent-storage + mountPath: /var/www/html/modules + subPath: modules + - name: drupal-persistent-storage + mountPath: /var/www/html/profiles + subPath: profiles + - name: drupal-persistent-storage + mountPath: /var/www/html/sites + subPath: sites + - name: drupal-persistent-storage + mountPath: /var/www/html/themes + subPath: themes + volumes: + - name: drupal-persistent-storage + persistentVolumeClaim: + claimName: drupal-pv-claim diff --git a/Drupal/drupal-namespace.yaml b/Drupal/drupal-namespace.yaml new file mode 100644 index 00000000..b65d3f50 --- /dev/null +++ b/Drupal/drupal-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: drupal diff --git a/Drupal/entra.sh b/Drupal/entra.sh new file mode 100755 index 00000000..46164227 --- /dev/null +++ b/Drupal/entra.sh @@ -0,0 +1 @@ +kubectl exec -ti deployment.apps/drupal -n drupal -- /bin/bash diff --git a/Drupal/kustomization.yaml b/Drupal/kustomization.yaml new file mode 100644 index 00000000..e8dc4c7d --- /dev/null +++ b/Drupal/kustomization.yaml @@ -0,0 +1,12 @@ +secretGenerator: +- name: mysqldrupal-pass + namespace: drupal + literals: + - password=Dsa-0213 + - db_user=root + - db_passwd=Dsa-0213 +resources: + - drupal-namespace.yaml + - mysql-deployment-drupal.yaml + - drupal-deployment.yaml + - php-myadmin-drupal-deployment.yaml diff --git a/Drupal/mysql-deployment-drupal.yaml b/Drupal/mysql-deployment-drupal.yaml new file mode 100644 index 00000000..ee2be658 --- /dev/null +++ b/Drupal/mysql-deployment-drupal.yaml @@ -0,0 +1,71 @@ +apiVersion: v1 +kind: Service +metadata: + name: drupal-mysql + namespace: drupal + labels: + app: drupal +spec: + type: NodePort + ports: + - name: mysql + port: 3306 + nodePort: 30382 + targetPort: mysql + selector: + app: drupal + tier: mysql +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-drupal-pv-claim + namespace: drupal + labels: + app: drupal +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 20Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: drupal-mysql + namespace: drupal + labels: + app: drupal +spec: + selector: + matchLabels: + app: drupal + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: drupal + tier: mysql + spec: + containers: + - image: mariadb + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysqldrupal-pass + key: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-drupal-pv-claim diff --git a/Drupal/paraTodo.sh b/Drupal/paraTodo.sh new file mode 100755 index 00000000..45dcc666 --- /dev/null +++ b/Drupal/paraTodo.sh @@ -0,0 +1,3 @@ +kubectl delete -k ./ +kubectl delete -f pv-local-mysql-drupal.yaml +kubectl delete -f pv-local-drupal.yaml diff --git a/Drupal/php-myadmin-drupal-deployment.yaml b/Drupal/php-myadmin-drupal-deployment.yaml new file mode 100644 index 00000000..ee0e494a --- /dev/null +++ b/Drupal/php-myadmin-drupal-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin-drupal + namespace: drupal + labels: + app: drupal +spec: + selector: + app: drupal + tier: phpmyadmin + type: NodePort + ports: + - name: phpadmin + port: 80 + nodePort: 30580 + targetPort: phpmyadm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin-drupal + namespace: drupal + labels: + app: drupal +spec: + selector: + matchLabels: + app: drupal + tier: phpmyadmin + strategy: + type: Recreate + template: + metadata: + labels: + app: drupal + tier: phpmyadmin + spec: + containers: + - name: phpmyadmin + image: phpmyadmin + ports: + - containerPort: 80 + name: phpmyadm + env: + - name: PMA_HOST + value: drupal-mysql + - name: PMA_PORT + value: "3306" + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysqldrupal-pass + key: password diff --git a/Drupal/pv-local-drupal.yaml b/Drupal/pv-local-drupal.yaml new file mode 100644 index 00000000..366d6f1e --- /dev/null +++ b/Drupal/pv-local-drupal.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: drupal-folder +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/drupal/drupal" + diff --git a/Drupal/pv-local-mysql-drupal.yaml b/Drupal/pv-local-mysql-drupal.yaml new file mode 100644 index 00000000..256542a4 --- /dev/null +++ b/Drupal/pv-local-mysql-drupal.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: drupal-data +spec: + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/cluster/drupal/drupal-db"