TestHelmAPI

Helm Chart: Simple Backend and Frontend App Deployment

This Helm chart facilitates the deployment of a simple backend and frontend application in a Kubernetes cluster. It automates the configuration of necessary resources, ensuring a smooth and reliable setup process.


Features


Prerequisites

  1. A Kubernetes cluster is up and running.
  2. Helm is installed and configured to interact with your cluster.
  3. Basic knowledge of Kubernetes and Helm.

Installation Guide

1. Clone the Repository

git clone https://github.com/2730538920101/TestHelmAPI.git
cd chart

2. Create a .env File

In the root directory of the chart, create a .env file with the following content:

API_SERVER=http://backend-service.helm-test.svc.cluster.local:5000/api
NODE_ENV=production

3. Add the Deployment Script

Ensure the deploy.sh script is in the root directory of the chart. This script automates the deployment process.


set -a
source .env

# Simulación del despliegue con dry-run
helm install helm-test . \
  --set secrets.apiServer="$API_SERVER" \
  --set configMap.nodeEnv="$NODE_ENV" \
  --dry-run

# Preguntar si se desea proceder con el despliegue real
read -p "¿Deseas ejecutar el despliegue real? (S/N): " respuesta

if [[ "$respuesta" =~ ^[Ss|Yy]$ ]]; then
  echo "Ejecutando despliegue real en el cluster..."
  helm install helm-test . \
    --set secrets.apiServer="$API_SERVER" \
    --set configMap.nodeEnv="$NODE_ENV"
  echo "¡Despliegue completado exitosamente!"
elif [[ "$respuesta" =~ ^[Nn]$ ]]; then
  echo "Has cancelado el despliegue. No se aplicaron cambios."
else
  echo "Respuesta no válida. Cancelando el despliegue."
fi


4. Deploy the Chart

Run the following commands to deploy the chart:

  1. Make the script executable:
    chmod +x deploy.sh
    
  2. Execute the script:
    ./deploy.sh
    

Deployment Details


Accessing the Application

Backend Service

The backend service will be available at the following internal URL within the cluster:

http://backend-service.helm-test.svc.cluster.local:5000/api

Frontend Service

  1. Retrieve the external IP address:
    kubectl get svc frontend-service -n <namespace>
    
  2. Open the service in your browser:
    http://<EXTERNAL-IP>
    

    Replace <EXTERNAL-IP> with the value obtained from the command above.


Troubleshooting


Enjoy deploying your simple backend and frontend app with Helm!