Browse Source

Creación de Drupal

main
Celestino Rey 3 years ago
parent
commit
d47de5235a
11 changed files with 296 additions and 0 deletions
  1. +23
    -0
      Drupal/copyMediawikiDB
  2. +4
    -0
      Drupal/creaTodo.sh
  3. +101
    -0
      Drupal/drupal-deployment.yaml
  4. +4
    -0
      Drupal/drupal-namespace.yaml
  5. +1
    -0
      Drupal/entra.sh
  6. +12
    -0
      Drupal/kustomization.yaml
  7. +71
    -0
      Drupal/mysql-deployment-drupal.yaml
  8. +3
    -0
      Drupal/paraTodo.sh
  9. +54
    -0
      Drupal/php-myadmin-drupal-deployment.yaml
  10. +12
    -0
      Drupal/pv-local-drupal.yaml
  11. +11
    -0
      Drupal/pv-local-mysql-drupal.yaml

+ 23
- 0
Drupal/copyMediawikiDB View File

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

+ 4
- 0
Drupal/creaTodo.sh View File

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

+ 101
- 0
Drupal/drupal-deployment.yaml View File

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

+ 4
- 0
Drupal/drupal-namespace.yaml View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: drupal

+ 1
- 0
Drupal/entra.sh View File

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

+ 12
- 0
Drupal/kustomization.yaml View File

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

+ 71
- 0
Drupal/mysql-deployment-drupal.yaml View File

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

+ 3
- 0
Drupal/paraTodo.sh View File

@ -0,0 +1,3 @@
kubectl delete -k ./
kubectl delete -f pv-local-mysql-drupal.yaml
kubectl delete -f pv-local-drupal.yaml

+ 54
- 0
Drupal/php-myadmin-drupal-deployment.yaml View File

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

+ 12
- 0
Drupal/pv-local-drupal.yaml View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: drupal-folder
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/cluster/drupal/drupal"

+ 11
- 0
Drupal/pv-local-mysql-drupal.yaml View File

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

Loading…
Cancel
Save