From 84064e7022d1b5b70b4787d289f48a55fa2805db Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Thu, 22 Aug 2024 15:44:30 +0200 Subject: [PATCH] Gitea en k8s. No funciona --- Gitea-old/creaTodo.sh | 4 ++ {Gitea => Gitea-old}/gitea-deployment.yaml | 0 {Gitea => Gitea-old}/gitea-namespace.yaml | 0 Gitea-old/kustomization.yaml | 13 ++++ Gitea-old/mysql-deployment-gitea.yaml | 73 +++++++++++++++++++++ Gitea-old/paraTodo.sh | 3 + Gitea-old/php-myadmin-gitea-deployment.yaml | 57 ++++++++++++++++ {Gitea => Gitea-old}/pv-local-gitea.yaml | 0 Gitea-old/pv-local-mysql-gitea.yaml | 11 ++++ {Gitea => Gitea-old}/registry-secrets.yaml | 0 Gitea-old/terminapv.sh | 3 + Gitea/010-deployment.yaml | 44 +++++++++++++ Gitea/020-volumes.yaml | 34 ++++++++++ Gitea/030-network.yaml | 17 +++++ Gitea/README.md | 8 +++ Gitea/creaTodo.sh | 2 - Gitea/kustomization.yaml | 11 ++-- Gitea/mysql-deployment-gitea.yaml | 6 +- Gitea/nginx-deployment.yaml | 34 ++++++++++ Gitea/nginx-service.yaml | 20 ++++++ Gitea/nginx/Dockerfile | 4 ++ Gitea/nginx/Makefile | 11 ++++ Gitea/nginx/nginx.conf | 17 +++++ Gitea/paraTodo.sh | 1 - Gitea/php-myadmin-gitea-deployment.yaml | 4 +- Gitea/reg-secret.yaml | 8 +++ NginxConf202311/README.md | 2 + 27 files changed, 375 insertions(+), 12 deletions(-) create mode 100755 Gitea-old/creaTodo.sh rename {Gitea => Gitea-old}/gitea-deployment.yaml (100%) rename {Gitea => Gitea-old}/gitea-namespace.yaml (100%) create mode 100644 Gitea-old/kustomization.yaml create mode 100644 Gitea-old/mysql-deployment-gitea.yaml create mode 100755 Gitea-old/paraTodo.sh create mode 100644 Gitea-old/php-myadmin-gitea-deployment.yaml rename {Gitea => Gitea-old}/pv-local-gitea.yaml (100%) create mode 100644 Gitea-old/pv-local-mysql-gitea.yaml rename {Gitea => Gitea-old}/registry-secrets.yaml (100%) create mode 100644 Gitea-old/terminapv.sh create mode 100644 Gitea/010-deployment.yaml create mode 100644 Gitea/020-volumes.yaml create mode 100644 Gitea/030-network.yaml create mode 100644 Gitea/README.md create mode 100644 Gitea/nginx-deployment.yaml create mode 100644 Gitea/nginx-service.yaml create mode 100644 Gitea/nginx/Dockerfile create mode 100644 Gitea/nginx/Makefile create mode 100644 Gitea/nginx/nginx.conf create mode 100644 Gitea/reg-secret.yaml diff --git a/Gitea-old/creaTodo.sh b/Gitea-old/creaTodo.sh new file mode 100755 index 00000000..c2ff902c --- /dev/null +++ b/Gitea-old/creaTodo.sh @@ -0,0 +1,4 @@ +kubectl create -f pv-local-mysql-gitea.yaml +kubectl create -f pv-local-gitea.yaml +kubectl create -k ./ +#watch kubectl get all -n gitea diff --git a/Gitea/gitea-deployment.yaml b/Gitea-old/gitea-deployment.yaml similarity index 100% rename from Gitea/gitea-deployment.yaml rename to Gitea-old/gitea-deployment.yaml diff --git a/Gitea/gitea-namespace.yaml b/Gitea-old/gitea-namespace.yaml similarity index 100% rename from Gitea/gitea-namespace.yaml rename to Gitea-old/gitea-namespace.yaml diff --git a/Gitea-old/kustomization.yaml b/Gitea-old/kustomization.yaml new file mode 100644 index 00000000..289a29ca --- /dev/null +++ b/Gitea-old/kustomization.yaml @@ -0,0 +1,13 @@ +secretGenerator: +- name: mysqlgitea-pass + namespace: gitea + literals: + - password=Dsa-0213 + - db_user=root + - db_passwd=Dsa-0213 +resources: + - gitea-namespace.yaml + - registry-secrets.yaml + - mysql-deployment-gitea.yaml + - gitea-deployment.yaml + - php-myadmin-gitea-deployment.yaml diff --git a/Gitea-old/mysql-deployment-gitea.yaml b/Gitea-old/mysql-deployment-gitea.yaml new file mode 100644 index 00000000..1a96b024 --- /dev/null +++ b/Gitea-old/mysql-deployment-gitea.yaml @@ -0,0 +1,73 @@ +apiVersion: v1 +kind: Service +metadata: + name: gitea-mysql + namespace: gitea + labels: + app: gitea +spec: + type: NodePort + ports: + - name: mysql + port: 3306 + nodePort: 30782 + targetPort: mysql + selector: + app: gitea + tier: mysql +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-gitea-pv-claim + namespace: gitea + labels: + app: gitea +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 20Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gitea-mysql + namespace: gitea + labels: + app: gitea +spec: + selector: + matchLabels: + app: gitea + tier: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: gitea + tier: mysql + spec: + containers: + - image: mariadb:latest + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysqlgitea-pass + key: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + imagePullSecrets: + - name: reg-cred-secret + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-gitea-pv-claim diff --git a/Gitea-old/paraTodo.sh b/Gitea-old/paraTodo.sh new file mode 100755 index 00000000..91a25253 --- /dev/null +++ b/Gitea-old/paraTodo.sh @@ -0,0 +1,3 @@ +kubectl delete -k ./ +kubectl delete -f pv-local-mysql-gitea.yaml +kubectl delete -f pv-local-gitea.yaml diff --git a/Gitea-old/php-myadmin-gitea-deployment.yaml b/Gitea-old/php-myadmin-gitea-deployment.yaml new file mode 100644 index 00000000..a6e66966 --- /dev/null +++ b/Gitea-old/php-myadmin-gitea-deployment.yaml @@ -0,0 +1,57 @@ +apiVersion: v1 +kind: Service +metadata: + name: phpmyadmin-gitea + namespace: gitea + labels: + app: gitea +spec: + selector: + app: gitea + tier: phpmyadmin + type: NodePort + ports: + - name: phpadmin + port: 80 + nodePort: 30781 + targetPort: phpmyadm +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: phpmyadmin-gitea + namespace: gitea + labels: + app: gitea +spec: + selector: + matchLabels: + app: gitea + tier: phpmyadmin + strategy: + type: Recreate + template: + metadata: + labels: + app: gitea + tier: phpmyadmin + spec: + containers: + - name: phpmyadmin + image: phpmyadmin + ports: + - containerPort: 80 + name: phpmyadm + env: + - name: PMA_HOST + value: gitea-mysql + - name: PMA_PORT + value: "3306" + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysqlgitea-pass + key: password + imagePullSecrets: + - name: reg-cred-secret + diff --git a/Gitea/pv-local-gitea.yaml b/Gitea-old/pv-local-gitea.yaml similarity index 100% rename from Gitea/pv-local-gitea.yaml rename to Gitea-old/pv-local-gitea.yaml diff --git a/Gitea-old/pv-local-mysql-gitea.yaml b/Gitea-old/pv-local-mysql-gitea.yaml new file mode 100644 index 00000000..9ccdbe0c --- /dev/null +++ b/Gitea-old/pv-local-mysql-gitea.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: gitea-data +spec: + capacity: + storage: 20Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/Externo/gitea/gitea-db" diff --git a/Gitea/registry-secrets.yaml b/Gitea-old/registry-secrets.yaml similarity index 100% rename from Gitea/registry-secrets.yaml rename to Gitea-old/registry-secrets.yaml diff --git a/Gitea-old/terminapv.sh b/Gitea-old/terminapv.sh new file mode 100644 index 00000000..9b1dd5cf --- /dev/null +++ b/Gitea-old/terminapv.sh @@ -0,0 +1,3 @@ + +kubectl patch pv gitea-folder -p '{"metadata":{"finalizers":null}}' +kubectl patch pv gitea-data -p '{"metadata":{"finalizers":null}}' diff --git a/Gitea/010-deployment.yaml b/Gitea/010-deployment.yaml new file mode 100644 index 00000000..48c4ab11 --- /dev/null +++ b/Gitea/010-deployment.yaml @@ -0,0 +1,44 @@ +################################################### +# Namespace Gitea +################################################### +apiVersion: v1 +kind: Namespace +metadata: + name: gitea-repo + +############################### +# Deplyoment Gitea +############################### +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gitea + namespace: gitea-repo + labels: + app: gitea +spec: + replicas: 1 + selector: + matchLabels: + app: gitea + template: + metadata: + labels: + app: gitea + spec: + containers: + - name: gitea + image: gitea/gitea:1.13.2 + ports: + - containerPort: 3000 + name: gitea + - containerPort: 22 + name: git-ssh + volumeMounts: + - mountPath: /data + name: git-data + volumes: + - name: git-data + persistentVolumeClaim: + claimName: git-pvc diff --git a/Gitea/020-volumes.yaml b/Gitea/020-volumes.yaml new file mode 100644 index 00000000..71ccbcba --- /dev/null +++ b/Gitea/020-volumes.yaml @@ -0,0 +1,34 @@ +--- +################################################### +# Persistence Volume Claim +################################################### +kind: PersistentVolume +apiVersion: v1 +metadata: + name: git-pv + namespace: gitea-repo +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + claimRef: + namespace: gitea-repo + name: git-pvc + hostPath: + path: /mnt/Externo/gitea/data + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: git-pvc + namespace: gitea-repo +spec: + accessModes: + - ReadWriteOnce + storageClassName: "" + resources: + requests: + storage: 5Gi + volumeName: "git-pv" diff --git a/Gitea/030-network.yaml b/Gitea/030-network.yaml new file mode 100644 index 00000000..750f409e --- /dev/null +++ b/Gitea/030-network.yaml @@ -0,0 +1,17 @@ +############################### +# Service +############################### +--- +kind: Service +apiVersion: v1 +metadata: + name: gitea + namespace: gitea-repo +spec: + selector: + app: gitea + ports: + - name: gitea-http + port: 3000 + - name: gitea-ssh + port: 22 diff --git a/Gitea/README.md b/Gitea/README.md new file mode 100644 index 00000000..b8b506ba --- /dev/null +++ b/Gitea/README.md @@ -0,0 +1,8 @@ +# Fuente + +https://ralph.blog.imixs.com/2021/02/25/running-gitea-on-kubernetes/ + + +# habilitar ssh + +https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey#verify-the-public-key-is-attached-to-your-account diff --git a/Gitea/creaTodo.sh b/Gitea/creaTodo.sh index c2ff902c..bffdd158 100755 --- a/Gitea/creaTodo.sh +++ b/Gitea/creaTodo.sh @@ -1,4 +1,2 @@ kubectl create -f pv-local-mysql-gitea.yaml -kubectl create -f pv-local-gitea.yaml kubectl create -k ./ -#watch kubectl get all -n gitea diff --git a/Gitea/kustomization.yaml b/Gitea/kustomization.yaml index 289a29ca..0e546a71 100644 --- a/Gitea/kustomization.yaml +++ b/Gitea/kustomization.yaml @@ -1,13 +1,16 @@ secretGenerator: - name: mysqlgitea-pass - namespace: gitea + namespace: gitea-repo literals: - password=Dsa-0213 - db_user=root - db_passwd=Dsa-0213 resources: - - gitea-namespace.yaml - - registry-secrets.yaml + - reg-secret.yaml - mysql-deployment-gitea.yaml - - gitea-deployment.yaml - php-myadmin-gitea-deployment.yaml + - 010-deployment.yaml + - 020-volumes.yaml + - 030-network.yaml + - nginx-deployment.yaml + - nginx-service.yaml diff --git a/Gitea/mysql-deployment-gitea.yaml b/Gitea/mysql-deployment-gitea.yaml index 1a96b024..56e45b47 100644 --- a/Gitea/mysql-deployment-gitea.yaml +++ b/Gitea/mysql-deployment-gitea.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: gitea-mysql - namespace: gitea + namespace: gitea-repo labels: app: gitea spec: @@ -20,7 +20,7 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-gitea-pv-claim - namespace: gitea + namespace: gitea-repo labels: app: gitea spec: @@ -34,7 +34,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: gitea-mysql - namespace: gitea + namespace: gitea-repo labels: app: gitea spec: diff --git a/Gitea/nginx-deployment.yaml b/Gitea/nginx-deployment.yaml new file mode 100644 index 00000000..61116695 --- /dev/null +++ b/Gitea/nginx-deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + name: nginx + namespace: gitea-repo +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: nginx + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + spec: + containers: + - image: registry.reymota.es/nginx-gitea-x86_64:1.18 + name: nginx + ports: + - containerPort: 80 + protocol: TCP + imagePullSecrets: + - name: myregistrykey + restartPolicy: Always diff --git a/Gitea/nginx-service.yaml b/Gitea/nginx-service.yaml new file mode 100644 index 00000000..a21da20d --- /dev/null +++ b/Gitea/nginx-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert + kompose.version: 1.34.0 (cbf2835db) + labels: + io.kompose.service: nginx + name: nginx + namespace: gitea-repo +spec: + type: NodePort + ports: + - name: "80" + port: 80 + nodePort: 30780 + targetPort: 80 + selector: + io.kompose.service: nginx + diff --git a/Gitea/nginx/Dockerfile b/Gitea/nginx/Dockerfile new file mode 100644 index 00000000..8328a0e5 --- /dev/null +++ b/Gitea/nginx/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:1.25 + +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d diff --git a/Gitea/nginx/Makefile b/Gitea/nginx/Makefile new file mode 100644 index 00000000..778014ab --- /dev/null +++ b/Gitea/nginx/Makefile @@ -0,0 +1,11 @@ +export ARQUITECTURA := $(shell lscpu |grep itectur | tr -d ' '| cut -f2 -d':') +export IMG_NGINX_VERSION = 1.18 + +install: + + echo "Creando imagen con version ${IMG_NGINX_VERSION} para la arquitectura ${ARQUITECTURA}" + + docker build --no-cache -t registry.reymota.es/nginx-gitea-${ARQUITECTURA}:${IMG_NGINX_VERSION} . + docker push registry.reymota.es/nginx-gitea-${ARQUITECTURA}:${IMG_NGINX_VERSION} + + diff --git a/Gitea/nginx/nginx.conf b/Gitea/nginx/nginx.conf new file mode 100644 index 00000000..315fba80 --- /dev/null +++ b/Gitea/nginx/nginx.conf @@ -0,0 +1,17 @@ +upstream gitea { + server gitea:3000; +} + +server { + + listen 80; + + location / { + proxy_pass http://gitea; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + client_max_body_size 100M; + } + +} diff --git a/Gitea/paraTodo.sh b/Gitea/paraTodo.sh index 91a25253..5b879dd8 100755 --- a/Gitea/paraTodo.sh +++ b/Gitea/paraTodo.sh @@ -1,3 +1,2 @@ kubectl delete -k ./ kubectl delete -f pv-local-mysql-gitea.yaml -kubectl delete -f pv-local-gitea.yaml diff --git a/Gitea/php-myadmin-gitea-deployment.yaml b/Gitea/php-myadmin-gitea-deployment.yaml index a6e66966..12604338 100644 --- a/Gitea/php-myadmin-gitea-deployment.yaml +++ b/Gitea/php-myadmin-gitea-deployment.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: phpmyadmin-gitea - namespace: gitea + namespace: gitea-repo labels: app: gitea spec: @@ -20,7 +20,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: phpmyadmin-gitea - namespace: gitea + namespace: gitea-repo labels: app: gitea spec: diff --git a/Gitea/reg-secret.yaml b/Gitea/reg-secret.yaml new file mode 100644 index 00000000..1f5faf93 --- /dev/null +++ b/Gitea/reg-secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: myregistrykey + namespace: gitea-repo +data: + .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5yZXltb3RhLmVzIjogewoJCQkiYXV0aCI6ICJZM0psZVd4dmNHVjZPbEpsZVMweE1UYzIiCgkJfQoJfQp9 +type: kubernetes.io/dockerconfigjson diff --git a/NginxConf202311/README.md b/NginxConf202311/README.md index 9c57e23c..459875e0 100644 --- a/NginxConf202311/README.md +++ b/NginxConf202311/README.md @@ -57,6 +57,8 @@ Listo. El resultado se ha escrito en un fichero en el mismo directorio desde don Debería de estar en /root/dydns. El fichero se llama settings.txt y tiene que tener todos los dominios que hemos asociado a la ip pública. +¡ojo! el fichero settings.txt se borra antes de rellenarlo con el nuevo valor. hay que ejecutar el comando fuera del directorio /root/dynds y luego añadir el resultado al fichero /root/dyndns/settings.txt + finalmente, hay que estar vigilando que las ip pública no cambie y que si lo hace se ajuste oportunamente. Para ello se añade un crontab