Last active
December 2, 2025 11:28
-
-
Save germanviscuso/edf759801412ea810ef953cfb5e085f2 to your computer and use it in GitHub Desktop.
Lab k8s cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: broker-deployment | |
| labels: | |
| app: broker | |
| spec: | |
| replicas: 1 | |
| selector: | |
| matchLabels: | |
| app: broker | |
| template: | |
| metadata: | |
| labels: | |
| app: broker | |
| spec: | |
| containers: | |
| - name: broker-container | |
| image: gerpux/broker-file-manager:v1 | |
| ports: | |
| - containerPort: 32002 | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: broker-service | |
| spec: | |
| type: NodePort | |
| selector: | |
| app: broker | |
| ports: | |
| - name: tcp-port | |
| port: 32002 # Puerto virtual del ClusterIP | |
| targetPort: 32002 # Apunta al puerto real del binario | |
| nodePort: 32002 # Puerto externo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usamos Ubuntu 20.04 para asegurar compatibilidad con las librerías del binario | |
| FROM ubuntu:20.04 | |
| # Instalamos dependencias básicas y limpiamos caché para reducir peso | |
| RUN apt-get update && \ | |
| apt-get install -y software-properties-common && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Copiamos el binario a la raíz del contenedor | |
| COPY brokerFileManager /brokerFileManager | |
| # Damos permisos de ejecución | |
| RUN chmod +x /brokerFileManager | |
| # Documentamos que el contenedor escucha en el puerto 3000 | |
| # (Kubernetes luego mapeará el 32002 externo a este 3000 interno) | |
| EXPOSE 32002 | |
| # Ejecutamos el broker | |
| CMD ["/brokerFileManager"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Usamos Ubuntu 20.04 para asegurar compatibilidad con las librerías del binario | |
| FROM ubuntu:20.04 | |
| # 1. Instalamos dependencias básicas incluido curl | |
| RUN apt-get update && \ | |
| apt-get install -y software-properties-common && \ | |
| apt-get install -y curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Copiamos el binario a la raíz | |
| COPY serverFileManager /serverFileManager | |
| # Damos permisos de ejecución | |
| RUN chmod +x /serverFileManager | |
| # Documentamos el puerto (informativo) | |
| EXPOSE 32001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| kind: PersistentVolumeClaim | |
| metadata: | |
| name: s3-claim | |
| spec: | |
| accessModes: | |
| - ReadWriteMany | |
| storageClassName: "" # Vacío para forzar el PV estático | |
| resources: | |
| requests: | |
| storage: 5Gi | |
| volumeName: s3-pv | |
| --- | |
| apiVersion: v1 | |
| kind: PersistentVolume | |
| metadata: | |
| name: s3-pv | |
| spec: | |
| capacity: | |
| storage: 5Gi | |
| accessModes: | |
| - ReadWriteMany | |
| persistentVolumeReclaimPolicy: Retain | |
| mountOptions: | |
| - allow-delete | |
| - allow-other | |
| csi: | |
| driver: s3.csi.aws.com | |
| volumeHandle: s3-data-volume | |
| volumeAttributes: | |
| bucketName: "my-bucket-utad" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: server-deployment | |
| labels: | |
| app: server-hp | |
| spec: | |
| replicas: 2 | |
| selector: | |
| matchLabels: | |
| app: server-hp | |
| template: | |
| metadata: | |
| labels: | |
| app: server-hp | |
| spec: | |
| containers: | |
| - name: server-container | |
| image: gerpux/server-file-manager:v3-curl | |
| imagePullPolicy: Always | |
| # 1. Sobrescribimos el comando para usar un shell | |
| command: ["/bin/sh", "-c"] | |
| # 2. Ejecutamos la lógica secuencialmente: | |
| # a) Curl para obtener IP | |
| # b) Exportar variable | |
| # c) Ejecutar tu binario usando esa variable | |
| args: | |
| - | | |
| # 1. Obtener IP Publica del server via servicio de Amazon | |
| export PUBLIC_IP=$(curl -s https://checkip.amazonaws.com) | |
| # 2. Imprimir variables para debug | |
| echo "DEBUG: Variable PUBLIC_IP = '$PUBLIC_IP'" | |
| echo "DEBUG: Variable BROKER_HOST = '$BROKER_SERVICE_SERVICE_HOST'" | |
| CMD="/serverFileManager $BROKER_SERVICE_SERVICE_HOST 32002 $PUBLIC_IP 32001" | |
| exec $CMD | |
| ports: | |
| - containerPort: 32001 | |
| volumeMounts: | |
| - mountPath: /FileManagerDir | |
| name: shared-data | |
| volumes: | |
| - name: shared-data | |
| hostPath: | |
| path: /mnt/data-shared | |
| type: DirectoryOrCreate | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: server-hp-svc | |
| spec: | |
| type: NodePort | |
| selector: | |
| app: server-hp | |
| ports: | |
| - port: 32001 | |
| targetPort: 32001 | |
| nodePort: 32001 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment