helm-test

by carlosmartz1995

Helm chartv1.0.0App 1.0.0Verified publisher

Helm chart para un despliegue de backend y frontend con configuración dinámica.

About this chart

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

  • Environment Variable Configuration: Configure your deployment dynamically using a .env file.
  • Automated Deployment Script: Use the provided deploy.sh script for hassle-free deployments.
  • Namespace Isolation: Deploy your resources in a dedicated namespace for better organization and control.
  • Scalable Services: Includes backend and frontend services that can scale as needed.

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

  • Namespace: Defined in values.yaml or passed via --namespace during deployment.
  • Environment Variables: API_SERVER and NODE_ENV are set dynamically from the .env file.

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

  • Verify the .env file is correctly configured.
  • Ensure the deploy.sh script is in the root directory and executable.
  • To simulate a deployment without applying changes, run:
    ./deploy.sh --dry-run
    
  • If issues persist, check the logs of the deployed pods using:
    kubectl logs -n <namespace> <pod-name>
    

Enjoy deploying your simple backend and frontend app with Helm!

Deploy helm-test with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has helm-test on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthelm-test is pinned at v1.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply