Celestino Rey 3 years ago
parent
commit
e418b8e7c9
30 changed files with 419 additions and 42 deletions
  1. +84
    -0
      CreaCluster/10-prepara.sh
  2. +0
    -0
      CreaCluster/20-borraCluster.sh
  3. +0
    -0
      CreaCluster/30-inicializaCluster.sh
  4. +0
    -0
      CreaCluster/40-creaConfigCluster.sh
  5. +0
    -0
      CreaCluster/50-creaCalico.sh
  6. +0
    -0
      CreaCluster/60-masterEsWorker.sh
  7. +0
    -0
      CreaCluster/70-confirmaRunning.sh
  8. +1
    -0
      CreaCluster/shell.sh
  9. +6
    -0
      PGO/creaTodo.sh
  10. +1
    -0
      PGO/entra.sh
  11. +10
    -0
      PGO/paraTodo.sh
  12. +20
    -0
      PGO/pgadmin-configmap.yaml
  13. +8
    -0
      PGO/pgadmin-secret.yaml
  14. +13
    -0
      PGO/pgadmin-service.yaml
  15. +55
    -0
      PGO/pgadmin-statefulset.yaml
  16. +13
    -0
      PGO/postgres-configmap.yaml
  17. +31
    -0
      PGO/postgres-deployment.yaml
  18. +13
    -0
      PGO/postgres-service.yaml
  19. +11
    -0
      PGO/pv-local-pg.yaml
  20. +11
    -0
      PGO/pv-local-pgadmin.yaml
  21. +14
    -0
      PGO/pvc-pg.yaml
  22. +11
    -0
      ownCloud/creaTodo.sh
  23. +8
    -0
      ownCloud/docker-compose.yml
  24. +1
    -1
      ownCloud/kustomization.yaml
  25. +48
    -0
      ownCloud/nextcloud-deployment.yaml
  26. +23
    -40
      ownCloud/owncloud-deployment.yaml
  27. +22
    -0
      ownCloud/owncloud-service.yaml
  28. +1
    -0
      ownCloud/paraTodo.sh
  29. +1
    -1
      ownCloud/php-deployment.yaml
  30. +13
    -0
      ownCloud/pvc-owncloud.yaml

+ 84
- 0
CreaCluster/10-prepara.sh View File

@ -0,0 +1,84 @@
read -p "Voy a quitar swap. Pulsa ENTER para seguir:" mainmenuinput
# disable swap
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
read -p "Cargar kernel modules. Pulsa ENTER para seguir:" mainmenuinput
# Load the following kernel modules on all the nodes
sudo tee /etc/modules-load.d/containerd.conf <<EOF
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
read -p "Parametros del kernel. Pulsa ENTER para seguir:" mainmenuinput
# Set the following Kernel parameters for Kubernetes
sudo tee /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
# Reload the above changes
sudo sysctl --system
read -p "Instalar dependencias de containerd. Pulsa ENTER para seguir:" mainmenuinput
# Install containerd run time
# dependencies
sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
read -p "Enable docker repository. Pulsa ENTER para seguir:" mainmenuinput
# Enable docker repository
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
read -p "Instalar containerd. Pulsa ENTER para seguir:" mainmenuinput
# install containerd
sudo apt update
sudo apt install -y containerd.io
read -p "Configurar containerd. Pulsa ENTER para seguir:" mainmenuinput
# Configure containerd so that it starts using systemd as cgroup.
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
read -p "Enable containerd. Pulsa ENTER para seguir:" mainmenuinput
# Restart and enable containerd service
sudo systemctl restart containerd
sudo systemctl enable containerd
read -p "Añade repository de Kubernetes. Pulsa ENTER para seguir:" mainmenuinput
# Add apt repository for Kubernetes
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
# Install Kubernetes components Kubectl, kubeadm & kubelet
read -p "Instalar componentes de kubernetes. Pulsa ENTER para seguir:" mainmenuinput
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

CreaCluster/00-borraCluster.sh → CreaCluster/20-borraCluster.sh View File


CreaCluster/01-inicializaCluster.sh → CreaCluster/30-inicializaCluster.sh View File


CreaCluster/02-creaConfigCluster.sh → CreaCluster/40-creaConfigCluster.sh View File


CreaCluster/03-creaCalico.sh → CreaCluster/50-creaCalico.sh View File


CreaCluster/04-masterEsWorker.sh → CreaCluster/60-masterEsWorker.sh View File


CreaCluster/05-confirmaRunning.sh → CreaCluster/70-confirmaRunning.sh View File


+ 1
- 0
CreaCluster/shell.sh View File

@ -0,0 +1 @@
read -p "Pulsa ENTER para seguir:" mainmenuinput

+ 6
- 0
PGO/creaTodo.sh View File

@ -0,0 +1,6 @@
kubectl create -f pv-local-pg.yaml
kubectl create -f pvc-pg.yaml
kubectl create -f postgres-configmap.yaml
kubectl create -f postgres-deployment.yaml
kubectl create -f postgres-service.yaml
watch kubectl get all -n postgres

+ 1
- 0
PGO/entra.sh View File

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

+ 10
- 0
PGO/paraTodo.sh View File

@ -0,0 +1,10 @@
kubectl delete -f postgres-service.yaml
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

+ 20
- 0
PGO/pgadmin-configmap.yaml View File

@ -0,0 +1,20 @@
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"
}
}
}

+ 8
- 0
PGO/pgadmin-secret.yaml View File

@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: pgadmin
namespace: postgres
data:
pgadmin-password: UmV5LTExNzYK

+ 13
- 0
PGO/pgadmin-service.yaml View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: pgadmin-service
namespace: postgres
spec:
ports:
- protocol: TCP
port: 80
targetPort: http
selector:
app: pgadmin
type: NodePort

+ 55
- 0
PGO/pgadmin-statefulset.yaml View File

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

+ 13
- 0
PGO/postgres-configmap.yaml View File

@ -0,0 +1,13 @@
# Create ConfigMap postgres-secret for the postgres app
# Define default database name, user, and password
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-secret
namespace: postgres
labels:
app: postgres
data:
POSTGRES_DB: productos
POSTGRES_USER: creylopez
POSTGRES_PASSWORD: Rey-1176

+ 31
- 0
PGO/postgres-deployment.yaml View File

@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment # Create a deployment
metadata:
name: postgres # Set the name of the deployment
namespace: postgres
spec:
replicas: 1 # Set 3 deployment replicas
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:12.10 # Docker image
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432 # Exposing the container port 5432 for PostgreSQL client connections.
envFrom:
- configMapRef:
name: postgres-secret # Using the ConfigMap postgres-secret
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgresdata
volumes:
- name: postgresdata
persistentVolumeClaim:
claimName: pg-pv-claim

+ 13
- 0
PGO/postgres-service.yaml View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service # Create service
metadata:
name: postgres # Sets the service name
namespace: postgres
labels:
app: postgres # Defines app to create service for
spec:
type: NodePort # Sets the service type
ports:
- port: 5432 # Sets the port to run the postgres application
selector:
app: postgres

+ 11
- 0
PGO/pv-local-pg.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: pg-data
spec:
capacity:
storage: 20Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/cluster/postgres/postgres-db"

+ 11
- 0
PGO/pv-local-pgadmin.yaml View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: pgadmin-data
spec:
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/cluster/postgres/pgadmin"

+ 14
- 0
PGO/pvc-pg.yaml View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pg-pv-claim
namespace: postgres
labels:
app: postgres
spec:
accessModes:
- ReadWriteOnce
storageClassName: ""
resources:
requests:
storage: 10Gi

+ 11
- 0
ownCloud/creaTodo.sh View File

@ -1,4 +1,15 @@
#
# crea el namespace
#
kubectl create -f oc-namespace.yaml
#
# crea los voluenes persistentes
#
kubectl create -f pv-local-owncloud.yaml
kubectl create -f pv-local-mysql.yaml
kubectl create -k ./
#
# observa hasta que arranque todo
#
watch kubectl get all -n owncloud

+ 8
- 0
ownCloud/docker-compose.yml View File

@ -0,0 +1,8 @@
version: '3.1'
services:
owncloud:
# use the latest version of owncloud
image: owncloud:latest
ports:
# bind ownCloud's port 80 to port 8080
- 8080:80

+ 1
- 1
ownCloud/kustomization.yaml View File

@ -6,7 +6,7 @@ secretGenerator:
- db_user=root
- db_passwd=Dsa-0213
resources:
- oc-namespace.yaml
- pvc-owncloud.yaml
- mysql-deployment.yaml
- php-deployment.yaml
- owncloud-deployment.yaml

+ 48
- 0
ownCloud/nextcloud-deployment.yaml View File

@ -0,0 +1,48 @@
apiVersion: v1
kind: Service
metadata:
name: nextcloud-server
namespace: nextcloud
labels:
app: nextcloud
spec:
selector:
pod-label: nextcloud-server-pod
type: NodePort
ports:
- port: 80
nodePort: 30289
targetPort: nextcloud
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nextcloud-server
namespace: nextcloud
labels:
app: nextcloud
spec:
replicas: 1
selector:
matchLabels:
pod-label: nextcloud-server-pod
template:
metadata:
labels:
pod-label: nextcloud-server-pod
spec:
containers:
- name: nextcloud
image: nextcloud
volumeMounts:
- name: server-storage
mountPath: /var/www/html
subPath: server-data
ports:
- containerPort: 80
name: nextcloud
volumes:
- name: server-storage
persistentVolumeClaim:
claimName: dbnc-pv-claim

+ 23
- 40
ownCloud/owncloud-deployment.yaml View File

@ -1,61 +1,44 @@
apiVersion: v1
kind: Service
metadata:
name: owncloud-server
namespace: owncloud
labels:
app: owncloud
spec:
selector:
pod-label: owncloud-server-pod
type: NodePort
ports:
- port: 8080
nodePort: 30689
targetPort: owncloud
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dboc-pv-claim
namespace: owncloud
labels:
app: owncloud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: owncloud-server
namespace: owncloud
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
app: owncloud
io.kompose.service: owncloud
name: owncloud
namespace: owncloud
spec:
replicas: 1
selector:
matchLabels:
pod-label: owncloud-server-pod
io.kompose.service: owncloud
strategy: {}
template:
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
pod-label: owncloud-server-pod
io.kompose.service: owncloud
spec:
containers:
- name: owncloud
image: 'owncloud/server:latest'
- image: owncloud:latest
imagePullPolicy: ""
name: owncloud
volumeMounts:
- name: server-storage
mountPath: /mnt/data
mountPath: /var/www/html/data
ports:
- containerPort: 8080
name: owncloud
- containerPort: 80
resources: {}
restartPolicy: Always
serviceAccountName: ""
volumes:
- name: server-storage
persistentVolumeClaim:
claimName: dboc-pv-claim
status: {}

+ 22
- 0
ownCloud/owncloud-service.yaml View File

@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: /snap/kompose/19/kompose-linux-amd64 convert
kompose.version: 1.21.0 (992df58d8)
creationTimestamp: null
labels:
io.kompose.service: owncloud
name: owncloud
namespace: owncloud
spec:
type: NodePort
ports:
- name: "8080"
port: 8080
nodePort: 30289
targetPort: 80
selector:
io.kompose.service: owncloud
status:
loadBalancer: {}

+ 1
- 0
ownCloud/paraTodo.sh View File

@ -1,3 +1,4 @@
kubectl delete -k ./
kubectl delete -f pvc-owncloud.yaml
kubectl delete -f pv-local-owncloud.yaml
kubectl delete -f pv-local-mysql.yaml

+ 1
- 1
ownCloud/php-deployment.yaml View File

@ -13,7 +13,7 @@ spec:
ports:
- name: phpadmin
port: 80
nodePort: 30680
nodePort: 30480
targetPort: phpmyadm
---
apiVersion: apps/v1


+ 13
- 0
ownCloud/pvc-owncloud.yaml View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dboc-pv-claim
# namespace: owncloud
labels:
app: owncloud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi

Loading…
Cancel
Save