helm-test
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
.envfile. - Automated Deployment Script: Use the provided
deploy.shscript 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
- A Kubernetes cluster is up and running.
- Helm is installed and configured to interact with your cluster.
- 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:
-
Make the script executable:
chmod +x deploy.sh -
Execute the script:
./deploy.sh
Deployment Details
- Namespace: Defined in
values.yamlor passed via--namespaceduring deployment. - Environment Variables:
API_SERVERandNODE_ENVare set dynamically from the.envfile.
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
-
Retrieve the external IP address:
kubectl get svc frontend-service -n <namespace> -
Open the service in your browser:
http://<EXTERNAL-IP>Replace
<EXTERNAL-IP>with the value obtained from the command above.
Troubleshooting
- Verify the
.envfile is correctly configured. - Ensure the
deploy.shscript 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the charthelm-test is pinned at v1.0.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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