From 268977a606f6719c09c30642a1b1de224610149a Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Tue, 8 Jun 2021 14:49:46 +0200 Subject: [PATCH 1/4] =?UTF-8?q?A=C3=B1ado=20sitio=20de=20reevolution=20y?= =?UTF-8?q?=20adapto=20Wordpress=20para=20trabajo=20en=20cluster=20k8s=20d?= =?UTF-8?q?e=20las=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Prometheus/kube-state-metrics-configs | 1 + Reevolution/kustomization.yaml | 8 +++ Reevolution/mysql-deployment.yaml | 68 +++++++++++++++++++++++++ Reevolution/pv-mysql.yaml | 12 +++++ Reevolution/pv-wordpress.yaml | 13 +++++ Reevolution/wordpress-deployment.yaml | 73 +++++++++++++++++++++++++++ Wordpress/kustomization.yaml | 2 +- Wordpress/mysql-deployment.yaml | 2 +- Wordpress/pv-mysql.yaml | 4 +- Wordpress/pv-wordpress.yaml | 4 +- Wordpress/wordpress-deployment.yaml | 2 +- 11 files changed, 182 insertions(+), 7 deletions(-) create mode 160000 Prometheus/kube-state-metrics-configs create mode 100644 Reevolution/kustomization.yaml create mode 100755 Reevolution/mysql-deployment.yaml create mode 100644 Reevolution/pv-mysql.yaml create mode 100644 Reevolution/pv-wordpress.yaml create mode 100755 Reevolution/wordpress-deployment.yaml diff --git a/Prometheus/kube-state-metrics-configs b/Prometheus/kube-state-metrics-configs new file mode 160000 index 00000000..fd114884 --- /dev/null +++ b/Prometheus/kube-state-metrics-configs @@ -0,0 +1 @@ +Subproject commit fd1148841aebfee2fd09347c4f2511a62b879915 diff --git a/Reevolution/kustomization.yaml b/Reevolution/kustomization.yaml new file mode 100644 index 00000000..69ca86e0 --- /dev/null +++ b/Reevolution/kustomization.yaml @@ -0,0 +1,8 @@ +secretGenerator: +- name: reevolution-pass + namespace: reevolution + literals: + - password=Rey-1176 +resources: + - mysql-deployment.yaml + - wordpress-deployment.yaml diff --git a/Reevolution/mysql-deployment.yaml b/Reevolution/mysql-deployment.yaml new file mode 100755 index 00000000..13659807 --- /dev/null +++ b/Reevolution/mysql-deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: v1 +kind: Service +metadata: + name: reevolution-mysql + namespace: reevolution + labels: + app: reevolution +spec: + ports: + - port: 3306 + selector: + app: reevolution + tier: mysql + clusterIP: None +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-reevolution-pv-claim + namespace: reevolution + labels: + app: reevolution +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 20Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: reevolution-mysql + namespace: reevolution + labels: + app: reevolution +spec: + selector: + matchLabels: + app: reevolution + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: reevolution + tier: mysql + spec: + containers: + - image: mariadb + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: reevolution-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-reevolution-pv-claim diff --git a/Reevolution/pv-mysql.yaml b/Reevolution/pv-mysql.yaml new file mode 100644 index 00000000..5a60676d --- /dev/null +++ b/Reevolution/pv-mysql.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: reevolution-data +spec: + capacity: + storage: 20Gi + accessModes: + - ReadWriteMany + nfs: + server: k8s-router + path: "/media/discoexterno/reevolution-db" diff --git a/Reevolution/pv-wordpress.yaml b/Reevolution/pv-wordpress.yaml new file mode 100644 index 00000000..8688a8c9 --- /dev/null +++ b/Reevolution/pv-wordpress.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: reevolution-folder +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + nfs: + server: k8s-router + path: "/media/discoexterno/reevolution-wp" + diff --git a/Reevolution/wordpress-deployment.yaml b/Reevolution/wordpress-deployment.yaml new file mode 100755 index 00000000..08a7eeaf --- /dev/null +++ b/Reevolution/wordpress-deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: v1 +kind: Service +metadata: + name: reevolution + namespace: reevolution + labels: + app: reevolution +spec: + type: NodePort + ports: + - port: 80 + nodePort: 30089 + targetPort: reevolution + selector: + app: reevolution + tier: frontend +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: reevolution-pv-claim + namespace: reevolution + labels: + app: reevolution +spec: + accessModes: + - ReadWriteMany + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: reevolution + namespace: reevolution + labels: + app: reevolution +spec: + selector: + matchLabels: + app: reevolution + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: reevolution + tier: frontend + spec: + containers: + - image: wordpress:4.8-apache + name: reevolution + env: + - name: WORDPRESS_DB_HOST + value: reevolution-mysql + - name: WORDPRESS_DB_PASSWORD + valueFrom: + secretKeyRef: + name: reevolution-pass + key: password + ports: + - containerPort: 80 + name: reevolution + volumeMounts: + - name: reevolution-persistent-storage + mountPath: /var/www/html + volumes: + - name: reevolution-persistent-storage + persistentVolumeClaim: + claimName: reevolution-pv-claim diff --git a/Wordpress/kustomization.yaml b/Wordpress/kustomization.yaml index 52893b6d..7d18a080 100644 --- a/Wordpress/kustomization.yaml +++ b/Wordpress/kustomization.yaml @@ -1,5 +1,5 @@ secretGenerator: -- name: mysql-pass +- name: mysqlwp-pass literals: - password=Dsa-0213 resources: diff --git a/Wordpress/mysql-deployment.yaml b/Wordpress/mysql-deployment.yaml index d733a18c..b0bd5e9d 100755 --- a/Wordpress/mysql-deployment.yaml +++ b/Wordpress/mysql-deployment.yaml @@ -51,7 +51,7 @@ spec: - name: MYSQL_ROOT_PASSWORD valueFrom: secretKeyRef: - name: mysql-pass + name: mysqlwp-pass key: password ports: - containerPort: 3306 diff --git a/Wordpress/pv-mysql.yaml b/Wordpress/pv-mysql.yaml index 52ddc0b3..9a1a8fe4 100644 --- a/Wordpress/pv-mysql.yaml +++ b/Wordpress/pv-mysql.yaml @@ -8,5 +8,5 @@ spec: accessModes: - ReadWriteMany nfs: - server: crl-rbp-400 - path: "/mnt/data/wordpress-db" + server: k8s-router + path: "/media/discoexterno/wordpress-db" diff --git a/Wordpress/pv-wordpress.yaml b/Wordpress/pv-wordpress.yaml index 6d49fc4f..60c4a4f7 100644 --- a/Wordpress/pv-wordpress.yaml +++ b/Wordpress/pv-wordpress.yaml @@ -8,6 +8,6 @@ spec: accessModes: - ReadWriteMany nfs: - server: crl-rbp-400 - path: "/mnt/data/wordpress-wp" + server: k8s-router + path: "/media/discoexterno/wordpress-wp" diff --git a/Wordpress/wordpress-deployment.yaml b/Wordpress/wordpress-deployment.yaml index 7fabe35a..c7fc886c 100755 --- a/Wordpress/wordpress-deployment.yaml +++ b/Wordpress/wordpress-deployment.yaml @@ -56,7 +56,7 @@ spec: - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: - name: mysql-pass + name: mysqlwp-pass key: password ports: - containerPort: 80 From c78008eadedf4de11c3f6408f2c7715dfdcf040f Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Wed, 9 Jun 2021 11:34:24 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Cambios=20en=20Wordpress=20para=20cluster?= =?UTF-8?q?=20y=20copio=20aqu=C3=AD=20Firefly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Firefly/k8s-cluster/ff-namespace.yaml | 4 + Firefly/k8s-cluster/ff-secrets.yaml | 12 ++ Firefly/k8s-cluster/firefly-deployment.yaml | 110 ++++++++++++++++++ Firefly/k8s-cluster/kustomization.yaml | 7 ++ Firefly/k8s-cluster/mysql-deployment.yaml | 69 +++++++++++ Firefly/k8s-cluster/php-deployment.yaml | 52 +++++++++ Firefly/k8s-cluster/pv-firefly-iii-mysql.yaml | 21 ++++ Firefly/k8s-cluster/pv-firefly-iii.yaml | 21 ++++ Firefly/k8s-cluster/pv-nfs-ff.yaml | 12 ++ Firefly/k8s-cluster/pv-nfs-mysql.yaml | 12 ++ Firefly/rbp400/ff-namespace.yaml | 4 + Firefly/rbp400/ff-secrets.yaml | 12 ++ Firefly/rbp400/firefly-deployment.yaml | 110 ++++++++++++++++++ Firefly/rbp400/kustomization.yaml | 5 + Firefly/rbp400/mysql-deployment.yaml | 69 +++++++++++ Firefly/rbp400/pv-firefly-iii-mysql.yaml | 21 ++++ Firefly/rbp400/pv-firefly-iii.yaml | 21 ++++ Wordpress/creaTodo.sh | 3 + Wordpress/kustomization.yaml | 1 + Wordpress/mysql-deployment.yaml | 3 + Wordpress/pvc-nginx.yaml | 1 + Wordpress/pvc-wordpress.yaml | 1 + Wordpress/wordpress-deployment.yaml | 5 +- 23 files changed, 575 insertions(+), 1 deletion(-) create mode 100644 Firefly/k8s-cluster/ff-namespace.yaml create mode 100644 Firefly/k8s-cluster/ff-secrets.yaml create mode 100644 Firefly/k8s-cluster/firefly-deployment.yaml create mode 100644 Firefly/k8s-cluster/kustomization.yaml create mode 100644 Firefly/k8s-cluster/mysql-deployment.yaml create mode 100644 Firefly/k8s-cluster/php-deployment.yaml create mode 100644 Firefly/k8s-cluster/pv-firefly-iii-mysql.yaml create mode 100644 Firefly/k8s-cluster/pv-firefly-iii.yaml create mode 100644 Firefly/k8s-cluster/pv-nfs-ff.yaml create mode 100644 Firefly/k8s-cluster/pv-nfs-mysql.yaml create mode 100644 Firefly/rbp400/ff-namespace.yaml create mode 100644 Firefly/rbp400/ff-secrets.yaml create mode 100644 Firefly/rbp400/firefly-deployment.yaml create mode 100644 Firefly/rbp400/kustomization.yaml create mode 100644 Firefly/rbp400/mysql-deployment.yaml create mode 100644 Firefly/rbp400/pv-firefly-iii-mysql.yaml create mode 100644 Firefly/rbp400/pv-firefly-iii.yaml create mode 100644 Wordpress/creaTodo.sh diff --git a/Firefly/k8s-cluster/ff-namespace.yaml b/Firefly/k8s-cluster/ff-namespace.yaml new file mode 100644 index 00000000..9be2fe1d --- /dev/null +++ b/Firefly/k8s-cluster/ff-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: firefly diff --git a/Firefly/k8s-cluster/ff-secrets.yaml b/Firefly/k8s-cluster/ff-secrets.yaml new file mode 100644 index 00000000..2e33ce52 --- /dev/null +++ b/Firefly/k8s-cluster/ff-secrets.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: firefly-iii-secrets + namespace: firefly +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/k8s-cluster/firefly-deployment.yaml b/Firefly/k8s-cluster/firefly-deployment.yaml new file mode 100644 index 00000000..9932b2ff --- /dev/null +++ b/Firefly/k8s-cluster/firefly-deployment.yaml @@ -0,0 +1,110 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-upload-claim + namespace: firefly + labels: + app: firefly-iii +spec: + accessModes: + - ReadWriteMany + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii + namespace: firefly + labels: + app: firefly-iii +spec: + type: NodePort + ports: + - name: firefly + port: 8080 + nodePort: 30880 + targetPort: firefly-iii + selector: + app: firefly-iii + tier: frontend +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii + namespace: firefly + labels: + app: firefly-iii +spec: + selector: + matchLabels: + app: firefly-iii + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii + tier: frontend + spec: + containers: + - image: jc5x/firefly-iii:latest + name: firefly-iii + env: + - name: APP_ENV + value: local + - name: APP_KEY + valueFrom: + secretKeyRef: + name: firefly-iii-secrets + key: app_key + - name: DB_HOST + value: firefly-iii-mysql + - name: DB_CONNECTION + value: mysql + - name: DB_DATABASE + value: "fireflyiii" + - name: DB_USERNAME + value: "root" + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-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-secrets + key: mail_user + - name: MAIL_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-secrets + key: mail_password + - name: MAIL_ENCRYPTION + value: "ssl" + ports: + - containerPort: 8080 + name: firefly-iii + volumeMounts: + - mountPath: "/var/www/html/firefly-iii/storage/upload" + name: firefly-iii-upload + imagePullPolicy: Always + volumes: + - name: firefly-iii-upload + persistentVolumeClaim: + claimName: firefly-iii-upload-claim diff --git a/Firefly/k8s-cluster/kustomization.yaml b/Firefly/k8s-cluster/kustomization.yaml new file mode 100644 index 00000000..e710b9e0 --- /dev/null +++ b/Firefly/k8s-cluster/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/k8s-cluster/mysql-deployment.yaml b/Firefly/k8s-cluster/mysql-deployment.yaml new file mode 100644 index 00000000..d2fcb337 --- /dev/null +++ b/Firefly/k8s-cluster/mysql-deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-data-pvc + namespace: firefly + labels: + app: firefly-iii +spec: + accessModes: + - ReadWriteMany + storageClassName: "" + resources: + requests: + storage: 20Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii-mysql + namespace: firefly + labels: + app: firefly-iii +spec: + ports: + - port: 3306 + selector: + app: firefly-iii + tier: mysql + clusterIP: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii-mysql + namespace: firefly + labels: + app: firefly-iii +spec: + selector: + matchLabels: + app: firefly-iii + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii + tier: mysql + spec: + containers: + - image: mariadb:latest + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-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-data-pvc diff --git a/Firefly/k8s-cluster/php-deployment.yaml b/Firefly/k8s-cluster/php-deployment.yaml new file mode 100644 index 00000000..2f77263b --- /dev/null +++ b/Firefly/k8s-cluster/php-deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin-firefly + labels: + app: firefly-iii +spec: + selector: + app: firefly-iii + tier: phpmyadmin + type: NodePort + ports: + - name: phpadmin + port: 80 + nodePort: 30180 + targetPort: phpmyadm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin-firefly + labels: + app: firefly-iii +spec: + selector: + matchLabels: + app: firefly-iii + tier: phpmyadmin + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii + tier: phpmyadmin + spec: + containers: + - name: phpmyadmin + image: arm64v8/phpmyadmin + ports: + - containerPort: 80 + name: phpmyadm + env: + - name: PMA_HOST + value: firefly-iii-mysql + - name: PMA_PORT + value: "3306" + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-secrets + key: db_password diff --git a/Firefly/k8s-cluster/pv-firefly-iii-mysql.yaml b/Firefly/k8s-cluster/pv-firefly-iii-mysql.yaml new file mode 100644 index 00000000..d1908cf3 --- /dev/null +++ b/Firefly/k8s-cluster/pv-firefly-iii-mysql.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii-mysql +spec: + capacity: + storage: 20Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + local: + path: /mnt/data/firefly-iii-mysql/ + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - crl-rbp-400 diff --git a/Firefly/k8s-cluster/pv-firefly-iii.yaml b/Firefly/k8s-cluster/pv-firefly-iii.yaml new file mode 100644 index 00000000..54ba24a8 --- /dev/null +++ b/Firefly/k8s-cluster/pv-firefly-iii.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii +spec: + capacity: + storage: 10Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + local: + path: /mnt/data/firefly-iii + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - crl-rbp-400 diff --git a/Firefly/k8s-cluster/pv-nfs-ff.yaml b/Firefly/k8s-cluster/pv-nfs-ff.yaml new file mode 100644 index 00000000..95a06ecf --- /dev/null +++ b/Firefly/k8s-cluster/pv-nfs-ff.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + nfs: + server: k8s-router + path: "/media/discoexterno/firefly-uploads" diff --git a/Firefly/k8s-cluster/pv-nfs-mysql.yaml b/Firefly/k8s-cluster/pv-nfs-mysql.yaml new file mode 100644 index 00000000..4f3b1a1c --- /dev/null +++ b/Firefly/k8s-cluster/pv-nfs-mysql.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii-mysql +spec: + capacity: + storage: 20Gi + accessModes: + - ReadWriteMany + nfs: + server: k8s-router + path: "/media/discoexterno/firefly-db" diff --git a/Firefly/rbp400/ff-namespace.yaml b/Firefly/rbp400/ff-namespace.yaml new file mode 100644 index 00000000..9be2fe1d --- /dev/null +++ b/Firefly/rbp400/ff-namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: firefly diff --git a/Firefly/rbp400/ff-secrets.yaml b/Firefly/rbp400/ff-secrets.yaml new file mode 100644 index 00000000..2e33ce52 --- /dev/null +++ b/Firefly/rbp400/ff-secrets.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: firefly-iii-secrets + namespace: firefly +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/rbp400/firefly-deployment.yaml b/Firefly/rbp400/firefly-deployment.yaml new file mode 100644 index 00000000..746de81d --- /dev/null +++ b/Firefly/rbp400/firefly-deployment.yaml @@ -0,0 +1,110 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-upload-claim + namespace: firefly + labels: + app: firefly-iii +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 10Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii + namespace: firefly + labels: + app: firefly-iii +spec: + type: NodePort + ports: + - name: firefly + port: 8080 + nodePort: 30880 + targetPort: firefly-iii + selector: + app: firefly-iii + tier: frontend +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii + namespace: firefly + labels: + app: firefly-iii +spec: + selector: + matchLabels: + app: firefly-iii + tier: frontend + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii + tier: frontend + spec: + containers: + - image: jc5x/firefly-iii:latest + name: firefly-iii + env: + - name: APP_ENV + value: local + - name: APP_KEY + valueFrom: + secretKeyRef: + name: firefly-iii-secrets + key: app_key + - name: DB_HOST + value: firefly-iii-mysql + - name: DB_CONNECTION + value: mysql + - name: DB_DATABASE + value: "fireflyiii" + - name: DB_USERNAME + value: "root" + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-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-secrets + key: mail_user + - name: MAIL_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-secrets + key: mail_password + - name: MAIL_ENCRYPTION + value: "ssl" + ports: + - containerPort: 8080 + name: firefly-iii + volumeMounts: + - mountPath: "/var/www/html/firefly-iii/storage/upload" + name: firefly-iii-upload + imagePullPolicy: Always + volumes: + - name: firefly-iii-upload + persistentVolumeClaim: + claimName: firefly-iii-upload-claim diff --git a/Firefly/rbp400/kustomization.yaml b/Firefly/rbp400/kustomization.yaml new file mode 100644 index 00000000..0414f13e --- /dev/null +++ b/Firefly/rbp400/kustomization.yaml @@ -0,0 +1,5 @@ +resources: +- ff-namespace.yaml +- ff-secrets.yaml +- mysql-deployment.yaml +- firefly-deployment.yaml diff --git a/Firefly/rbp400/mysql-deployment.yaml b/Firefly/rbp400/mysql-deployment.yaml new file mode 100644 index 00000000..bce00a13 --- /dev/null +++ b/Firefly/rbp400/mysql-deployment.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: firefly-iii-data-pvc + namespace: firefly + labels: + app: firefly-iii +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 20Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: firefly-iii-mysql + namespace: firefly + labels: + app: firefly-iii +spec: + ports: + - port: 3306 + selector: + app: firefly-iii + tier: mysql + clusterIP: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: firefly-iii-mysql + namespace: firefly + labels: + app: firefly-iii +spec: + selector: + matchLabels: + app: firefly-iii + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: firefly-iii + tier: mysql + spec: + containers: + - image: mariadb:latest + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: firefly-iii-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-data-pvc diff --git a/Firefly/rbp400/pv-firefly-iii-mysql.yaml b/Firefly/rbp400/pv-firefly-iii-mysql.yaml new file mode 100644 index 00000000..d1908cf3 --- /dev/null +++ b/Firefly/rbp400/pv-firefly-iii-mysql.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii-mysql +spec: + capacity: + storage: 20Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + local: + path: /mnt/data/firefly-iii-mysql/ + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - crl-rbp-400 diff --git a/Firefly/rbp400/pv-firefly-iii.yaml b/Firefly/rbp400/pv-firefly-iii.yaml new file mode 100644 index 00000000..54ba24a8 --- /dev/null +++ b/Firefly/rbp400/pv-firefly-iii.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: data-firefly-iii +spec: + capacity: + storage: 10Gi + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Delete + local: + path: /mnt/data/firefly-iii + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - crl-rbp-400 diff --git a/Wordpress/creaTodo.sh b/Wordpress/creaTodo.sh new file mode 100644 index 00000000..33286dc2 --- /dev/null +++ b/Wordpress/creaTodo.sh @@ -0,0 +1,3 @@ +kubectl create -f pv-mysql.yaml +kubectl create -f pv-wordpress.yaml +kubectl create -k ./ diff --git a/Wordpress/kustomization.yaml b/Wordpress/kustomization.yaml index 7d18a080..c4d71da4 100644 --- a/Wordpress/kustomization.yaml +++ b/Wordpress/kustomization.yaml @@ -1,5 +1,6 @@ secretGenerator: - name: mysqlwp-pass + namespace: wordpress literals: - password=Dsa-0213 resources: diff --git a/Wordpress/mysql-deployment.yaml b/Wordpress/mysql-deployment.yaml index b0bd5e9d..40998260 100755 --- a/Wordpress/mysql-deployment.yaml +++ b/Wordpress/mysql-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: wordpress-mysql + namespace: wordpress labels: app: wordpress spec: @@ -16,6 +17,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-wp-pv-claim + namespace: wordpress labels: app: wordpress spec: @@ -29,6 +31,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: wordpress-mysql + namespace: wordpress labels: app: wordpress spec: diff --git a/Wordpress/pvc-nginx.yaml b/Wordpress/pvc-nginx.yaml index a8d80ec0..00a7a6c3 100644 --- a/Wordpress/pvc-nginx.yaml +++ b/Wordpress/pvc-nginx.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: nginx-pv-claim + namespace: wordpress labels: app: nginx spec: diff --git a/Wordpress/pvc-wordpress.yaml b/Wordpress/pvc-wordpress.yaml index dc02d293..37cebcdb 100644 --- a/Wordpress/pvc-wordpress.yaml +++ b/Wordpress/pvc-wordpress.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: wp-pv-claim + namespace: wordpress labels: app: wordpress spec: diff --git a/Wordpress/wordpress-deployment.yaml b/Wordpress/wordpress-deployment.yaml index c7fc886c..e4a08f20 100755 --- a/Wordpress/wordpress-deployment.yaml +++ b/Wordpress/wordpress-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: wordpress + namespace: wordpress labels: app: wordpress spec: @@ -18,6 +19,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: wp-pv-claim + namespace: wordpress labels: app: wordpress spec: @@ -32,6 +34,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: wordpress + namespace: wordpress labels: app: wordpress spec: @@ -48,7 +51,7 @@ spec: tier: frontend spec: containers: - - image: wordpress:4.8-apache + - image: wordpress:5.7.2-php7.4-apache name: wordpress env: - name: WORDPRESS_DB_HOST From 1ea7516db7f71e04cc15bbcc5ec6e61489e39e3d Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Sun, 13 Jun 2021 18:50:34 +0200 Subject: [PATCH 3/4] =?UTF-8?q?A=C3=B1ado=20phpmyadmin=20a=20Wordpress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Firefly/k8s-cluster/php-deployment.yaml | 2 + Wordpress/kustomization.yaml | 1 + Wordpress/php-deployment.yaml | 54 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 Wordpress/php-deployment.yaml diff --git a/Firefly/k8s-cluster/php-deployment.yaml b/Firefly/k8s-cluster/php-deployment.yaml index 2f77263b..8bc5e37e 100644 --- a/Firefly/k8s-cluster/php-deployment.yaml +++ b/Firefly/k8s-cluster/php-deployment.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Service metadata: name: phpmyadmin-firefly + namespace: firefly labels: app: firefly-iii spec: @@ -19,6 +20,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: phpmyadmin-firefly + namespace: firefly labels: app: firefly-iii spec: diff --git a/Wordpress/kustomization.yaml b/Wordpress/kustomization.yaml index c4d71da4..c025212e 100644 --- a/Wordpress/kustomization.yaml +++ b/Wordpress/kustomization.yaml @@ -6,3 +6,4 @@ secretGenerator: resources: - mysql-deployment.yaml - wordpress-deployment.yaml + - php-deployment.yaml diff --git a/Wordpress/php-deployment.yaml b/Wordpress/php-deployment.yaml new file mode 100644 index 00000000..09d8294d --- /dev/null +++ b/Wordpress/php-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin-wordpress + namespace: wordpress + labels: + app: wordpress +spec: + selector: + app: wordpress + tier: phpmyadmin + type: NodePort + ports: + - name: phpadmin + port: 80 + nodePort: 30280 + targetPort: phpmyadm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin-wordpress + namespace: wordpress + labels: + app: wordpress +spec: + selector: + matchLabels: + app: wordpress + tier: phpmyadmin + strategy: + type: Recreate + template: + metadata: + labels: + app: wordpress + tier: phpmyadmin + spec: + containers: + - name: phpmyadmin + image: arm64v8/phpmyadmin + ports: + - containerPort: 80 + name: phpmyadm + env: + - name: PMA_HOST + value: wordpress-mysql + - name: PMA_PORT + value: "3306" + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysqlwp-pass + key: password From c16c78bf8a98618ad2cbb9dfe115b3fa002bbe3e Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Thu, 15 Jul 2021 16:21:03 +0200 Subject: [PATCH 4/4] =?UTF-8?q?A=C3=B1ado=20un=20ejemplo=20de=20Statefulse?= =?UTF-8?q?t=20con=20mysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StatefulSet/mysql-configmap.yaml | 17 +++ StatefulSet/mysql-services.yaml | 31 ++++++ StatefulSet/mysql-statefulset.yaml | 167 +++++++++++++++++++++++++++++ StatefulSet/pv-mysql-01.yaml | 12 +++ StatefulSet/pv-mysql-02.yaml | 12 +++ StatefulSet/pv-mysql-03.yaml | 12 +++ 6 files changed, 251 insertions(+) create mode 100644 StatefulSet/mysql-configmap.yaml create mode 100644 StatefulSet/mysql-services.yaml create mode 100644 StatefulSet/mysql-statefulset.yaml create mode 100644 StatefulSet/pv-mysql-01.yaml create mode 100644 StatefulSet/pv-mysql-02.yaml create mode 100644 StatefulSet/pv-mysql-03.yaml diff --git a/StatefulSet/mysql-configmap.yaml b/StatefulSet/mysql-configmap.yaml new file mode 100644 index 00000000..43769248 --- /dev/null +++ b/StatefulSet/mysql-configmap.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql + 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 + + diff --git a/StatefulSet/mysql-services.yaml b/StatefulSet/mysql-services.yaml new file mode 100644 index 00000000..8e72897c --- /dev/null +++ b/StatefulSet/mysql-services.yaml @@ -0,0 +1,31 @@ +# Headless service for stable DNS entries of StatefulSet members. +apiVersion: v1 +kind: Service +metadata: + name: mysql + 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 + labels: + app: mysql +spec: + ports: + - name: mysql + port: 3306 + selector: + app: mysql + + diff --git a/StatefulSet/mysql-statefulset.yaml b/StatefulSet/mysql-statefulset.yaml new file mode 100644 index 00000000..79ac7ade --- /dev/null +++ b/StatefulSet/mysql-statefulset.yaml @@ -0,0 +1,167 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mysql +spec: + selector: + matchLabels: + app: mysql + serviceName: mysql + replicas: 3 + template: + metadata: + labels: + app: mysql + spec: + initContainers: + - name: init-mysql + image: mysql:5.7 + 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: mysql:5.7 + 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$( 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 "$(