Browse Source

Añado NextCloud

main
Celestino Rey 4 years ago
parent
commit
7bed99d5fb
26 changed files with 402 additions and 3 deletions
  1. +9
    -0
      Cifs/crey@k8s-currante-01
  2. +9
    -0
      Cifs/crey@k8s-currante-02
  3. +9
    -0
      Cifs/instalaCifs
  4. +0
    -0
      NextCloud/Readme.md
  5. +0
    -0
      NextCloud/creaTodo.sh
  6. +0
    -0
      NextCloud/kustomization.yaml
  7. +0
    -0
      NextCloud/nextcloud-deployment.yaml
  8. +0
    -0
      NextCloud/paraTodo.sh
  9. +0
    -0
      NextCloud/pv-nextcloud.yaml
  10. +0
    -0
      NextCloud/pvc-nextcloud.yaml
  11. +2
    -0
      Nginx/kustomization.yaml
  12. +60
    -0
      Nginx/miweb-deployment.yaml
  13. +2
    -2
      Nginx/pv-nginx.yaml
  14. +3
    -0
      Reevolution/creaTodo.sh
  15. +3
    -0
      Reevolution/kustomization.yaml
  16. +3
    -0
      Reevolution/paraTodo.sh
  17. +54
    -0
      Reevolution/php-deployment.yaml
  18. +6
    -1
      Reevolution/wordpress-deployment.yaml
  19. +2
    -0
      Wordpress/kustomization.yaml
  20. +3
    -0
      Wordpress/paraTodo.sh
  21. +5
    -0
      Wordpress/wordpress-deployment.yaml
  22. +4
    -0
      statefulset/kustomization.yaml
  23. +17
    -0
      statefulset/mysql-configmap.yaml
  24. +32
    -0
      statefulset/mysql-services.yaml
  25. +167
    -0
      statefulset/mysql-statefulset.yaml
  26. +12
    -0
      statefulset/pv-mysql.yaml

+ 9
- 0
Cifs/crey@k8s-currante-01 View File

@ -0,0 +1,9 @@
sudo apt install cifs-utils
sudo apt install jq
VOLUME_PLUGIN_DIR="/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
mkdir -p "$VOLUME_PLUGIN_DIR/fstab~cifs"
cd "$VOLUME_PLUGIN_DIR/fstab~cifs"
curl -L -O https://raw.githubusercontent.com/fstab/cifs/master/cifs
chmod 755 cifs

+ 9
- 0
Cifs/crey@k8s-currante-02 View File

@ -0,0 +1,9 @@
sudo apt install cifs-utils
sudo apt install jq
VOLUME_PLUGIN_DIR="/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
mkdir -p "$VOLUME_PLUGIN_DIR/fstab~cifs"
cd "$VOLUME_PLUGIN_DIR/fstab~cifs"
curl -L -O https://raw.githubusercontent.com/fstab/cifs/master/cifs
chmod 755 cifs

+ 9
- 0
Cifs/instalaCifs View File

@ -0,0 +1,9 @@
sudo apt install cifs-utils
sudo apt install jq
VOLUME_PLUGIN_DIR="/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
mkdir -p "$VOLUME_PLUGIN_DIR/fstab~cifs"
cd "$VOLUME_PLUGIN_DIR/fstab~cifs"
curl -L -O https://raw.githubusercontent.com/fstab/cifs/master/cifs
chmod 755 cifs

ownCloud/Readme.md → NextCloud/Readme.md View File


ownCloud/creaTodo.sh → NextCloud/creaTodo.sh View File


ownCloud/kustomization.yaml → NextCloud/kustomization.yaml View File


ownCloud/nextcloud-deployment.yaml → NextCloud/nextcloud-deployment.yaml View File


ownCloud/paraTodo.sh → NextCloud/paraTodo.sh View File


ownCloud/pv-nextcloud.yaml → NextCloud/pv-nextcloud.yaml View File


ownCloud/pvc-nextcloud.yaml → NextCloud/pvc-nextcloud.yaml View File


+ 2
- 0
Nginx/kustomization.yaml View File

@ -0,0 +1,2 @@
resources:
- miweb-deployment.yaml

+ 60
- 0
Nginx/miweb-deployment.yaml View File

@ -0,0 +1,60 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-example
spec:
type: NodePort
ports:
- name: http
port: 80
nodePort: 30080
targetPort: nginx-http
selector:
app: nginx
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-pv-claim
labels:
app: nginx
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-example
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: nginx
tier: frontend
spec:
containers:
- name: nginx
image: linuxserver/nginx
ports:
- containerPort: 80
name: "nginx-http"
volumeMounts:
- name: nginx-www-folder
mountPath: /config/www
volumes:
- name: nginx-www-folder
persistentVolumeClaim:
claimName: nginx-pv-claim

+ 2
- 2
Nginx/pv-nginx.yaml View File

@ -8,5 +8,5 @@ spec:
accessModes: accessModes:
- ReadWriteMany - ReadWriteMany
nfs: nfs:
server: haproxy-a-01
path: "/media/discodatos/nginx"
server: k8s-router
path: "/media/discoexterno/nginx"

+ 3
- 0
Reevolution/creaTodo.sh View File

@ -0,0 +1,3 @@
kubectl create -f pv-mysql.yaml
kubectl create -f pv-wordpress.yaml
kubectl create -k ./

+ 3
- 0
Reevolution/kustomization.yaml View File

@ -3,6 +3,9 @@ secretGenerator:
namespace: reevolution namespace: reevolution
literals: literals:
- password=Rey-1176 - password=Rey-1176
- db_user=root
- db_passwd=Rey-1176
resources: resources:
- mysql-deployment.yaml - mysql-deployment.yaml
- wordpress-deployment.yaml - wordpress-deployment.yaml
- php-deployment.yaml

+ 3
- 0
Reevolution/paraTodo.sh View File

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

+ 54
- 0
Reevolution/php-deployment.yaml View File

@ -0,0 +1,54 @@
apiVersion: v1
kind: Service
metadata:
name: phpmyadmin-reevolution
namespace: reevolution
labels:
app: reevolution
spec:
selector:
app: reevolution
tier: phpmyadmin
type: NodePort
ports:
- name: phpadmin
port: 80
nodePort: 30289
targetPort: phpmyadm
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin-reevolution
namespace: reevolution
labels:
app: reevolution
spec:
selector:
matchLabels:
app: reevolution
tier: phpmyadmin
strategy:
type: Recreate
template:
metadata:
labels:
app: reevolution
tier: phpmyadmin
spec:
containers:
- name: phpmyadmin
image: arm64v8/phpmyadmin
ports:
- containerPort: 80
name: phpmyadm
env:
- name: PMA_HOST
value: reevolution-mysql
- name: PMA_PORT
value: "3306"
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: reevolution-pass
key: password

+ 6
- 1
Reevolution/wordpress-deployment.yaml View File

@ -51,7 +51,7 @@ spec:
tier: frontend tier: frontend
spec: spec:
containers: containers:
- image: wordpress:4.8-apache
- image: wordpress:5.7.2-php7.4-apache
name: reevolution name: reevolution
env: env:
- name: WORDPRESS_DB_HOST - name: WORDPRESS_DB_HOST
@ -61,6 +61,11 @@ spec:
secretKeyRef: secretKeyRef:
name: reevolution-pass name: reevolution-pass
key: password key: password
- name: WORDPRESS_DB_USER
valueFrom:
secretKeyRef:
name: reevolution-pass
key: db_user
ports: ports:
- containerPort: 80 - containerPort: 80
name: reevolution name: reevolution


+ 2
- 0
Wordpress/kustomization.yaml View File

@ -3,6 +3,8 @@ secretGenerator:
namespace: wordpress namespace: wordpress
literals: literals:
- password=Dsa-0213 - password=Dsa-0213
- db_user=root
- db_passwd=Dsa-0213
resources: resources:
- mysql-deployment.yaml - mysql-deployment.yaml
- wordpress-deployment.yaml - wordpress-deployment.yaml


+ 3
- 0
Wordpress/paraTodo.sh View File

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

+ 5
- 0
Wordpress/wordpress-deployment.yaml View File

@ -61,6 +61,11 @@ spec:
secretKeyRef: secretKeyRef:
name: mysqlwp-pass name: mysqlwp-pass
key: password key: password
- name: WORDPRESS_DB_USER
valueFrom:
secretKeyRef:
name: mysqlwp-pass
key: db_user
ports: ports:
- containerPort: 80 - containerPort: 80
name: wordpress name: wordpress


+ 4
- 0
statefulset/kustomization.yaml View File

@ -0,0 +1,4 @@
resources:
- mysql-configmap.yaml
- mysql-services.yaml
- mysql-statefulset.yaml

+ 17
- 0
statefulset/mysql-configmap.yaml View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql
namespace: my-statefulset
labels:
app: mysql
data:
primary.cnf: |
# Apply this config only on the primary.
[mysqld]
log-bin
replica.cnf: |
# Apply this config only on replicas.
[mysqld]
super-read-only

+ 32
- 0
statefulset/mysql-services.yaml View File

@ -0,0 +1,32 @@
# Headless service for stable DNS entries of StatefulSet members.
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: my-statefulset
labels:
app: mysql
spec:
ports:
- name: mysql
port: 3306
clusterIP: None
selector:
app: mysql
---
# Client service for connecting to any MySQL instance for reads.
# For writes, you must instead connect to the primary: mysql-0.mysql.
apiVersion: v1
kind: Service
metadata:
name: mysql-read
namespace: my-statefulset
labels:
app: mysql
spec:
ports:
- name: mysql
port: 3306
selector:
app: mysql

+ 167
- 0
statefulset/mysql-statefulset.yaml View File

@ -0,0 +1,167 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: my-statefulset
spec:
selector:
matchLabels:
app: mysql
serviceName: mysql
replicas: 3
template:
metadata:
labels:
app: mysql
spec:
initContainers:
- name: init-mysql
image: biarms/mysql:5.7.30
command:
- bash
- "-c"
- |
set -ex
# Generate mysql server-id from pod ordinal index.
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1
ordinal=${BASH_REMATCH[1]}
echo [mysqld] > /mnt/conf.d/server-id.cnf
# Add an offset to avoid reserved server-id=0 value.
echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
# Copy appropriate conf.d files from config-map to emptyDir.
if [[ $ordinal -eq 0 ]]; then
cp /mnt/config-map/primary.cnf /mnt/conf.d/
else
cp /mnt/config-map/replica.cnf /mnt/conf.d/
fi
volumeMounts:
- name: conf
mountPath: /mnt/conf.d
- name: config-map
mountPath: /mnt/config-map
- name: clone-mysql
image: gcr.io/google-samples/xtrabackup:1.0
command:
- bash
- "-c"
- |
set -ex
# Skip the clone if data already exists.
[[ -d /var/lib/mysql/mysql ]] && exit 0
# Skip the clone on primary (ordinal index 0).
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1
ordinal=${BASH_REMATCH[1]}
[[ $ordinal -eq 0 ]] && exit 0
# Clone data from previous peer.
ncat --recv-only mysql-$(($ordinal-1)).mysql 3307 | xbstream -x -C /var/lib/mysql
# Prepare the backup.
xtrabackup --prepare --target-dir=/var/lib/mysql
volumeMounts:
- name: data
mountPath: /var/lib/mysql
subPath: mysql
- name: conf
mountPath: /etc/mysql/conf.d
containers:
- name: mysql
image: biarms/mysql:5.7.30
env:
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "1"
ports:
- name: mysql
containerPort: 3306
volumeMounts:
- name: data
mountPath: /var/lib/mysql
subPath: mysql
- name: conf
mountPath: /etc/mysql/conf.d
resources:
requests:
cpu: 500m
memory: 1Gi
livenessProbe:
exec:
command: ["mysqladmin", "ping"]
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
readinessProbe:
exec:
# Check we can execute queries over TCP (skip-networking is off).
command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
initialDelaySeconds: 5
periodSeconds: 2
timeoutSeconds: 1
- name: xtrabackup
image: gcr.io/google-samples/xtrabackup:1.0
ports:
- name: xtrabackup
containerPort: 3307
command:
- bash
- "-c"
- |
set -ex
cd /var/lib/mysql
# Determine binlog position of cloned data, if any.
if [[ -f xtrabackup_slave_info && "x$(<xtrabackup_slave_info)" != "x" ]]; then
# XtraBackup already generated a partial "CHANGE MASTER TO" query
# because we're cloning from an existing replica. (Need to remove the tailing semicolon!)
cat xtrabackup_slave_info | sed -E 's/;$//g' > change_master_to.sql.in
# Ignore xtrabackup_binlog_info in this case (it's useless).
rm -f xtrabackup_slave_info xtrabackup_binlog_info
elif [[ -f xtrabackup_binlog_info ]]; then
# We're cloning directly from primary. Parse binlog position.
[[ `cat xtrabackup_binlog_info` =~ ^(.*?)[[:space:]]+(.*?)$ ]] || exit 1
rm -f xtrabackup_binlog_info xtrabackup_slave_info
echo "CHANGE MASTER TO MASTER_LOG_FILE='${BASH_REMATCH[1]}',\
MASTER_LOG_POS=${BASH_REMATCH[2]}" > change_master_to.sql.in
fi
# Check if we need to complete a clone by starting replication.
if [[ -f change_master_to.sql.in ]]; then
echo "Waiting for mysqld to be ready (accepting connections)"
until mysql -h 127.0.0.1 -e "SELECT 1"; do sleep 1; done
echo "Initializing replication from clone position"
mysql -h 127.0.0.1 \
-e "$(<change_master_to.sql.in), \
MASTER_HOST='mysql-0.mysql', \
MASTER_USER='root', \
MASTER_PASSWORD='', \
MASTER_CONNECT_RETRY=10; \
START SLAVE;" || exit 1
# In case of container restart, attempt this at-most-once.
mv change_master_to.sql.in change_master_to.sql.orig
fi
# Start a server to send backups when requested by peers.
exec ncat --listen --keep-open --send-only --max-conns=1 3307 -c \
"xtrabackup --backup --slave-info --stream=xbstream --host=127.0.0.1 --user=root"
volumeMounts:
- name: data
mountPath: /var/lib/mysql
subPath: mysql
- name: conf
mountPath: /etc/mysql/conf.d
resources:
requests:
cpu: 100m
memory: 100Mi
volumes:
- name: conf
emptyDir: {}
- name: config-map
configMap:
name: mysql
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi

+ 12
- 0
statefulset/pv-mysql.yaml View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-state-data
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
nfs:
server: k8s-router
path: "/media/discoexterno/my-statefulset"

Loading…
Cancel
Save