# Calcolatore Prezzi Software - Helm Chart Questo è un Helm chart semplificato per il deploy del Calcolatore Prezzi Software che utilizza il [base-helm](https://git.commandware.com/GitOps/base-helm.git) come chart comune. ## Prerequisiti - Kubernetes 1.19+ - Helm 3.0+ - Nginx Ingress Controller (opzionale, per l'ingress) - Cert-manager (opzionale, per i certificati SSL) ## Installazione ### 1. Aggiornare le dipendenze Prima di installare il chart, è necessario aggiornare le dipendenze per scaricare il base-helm: ```bash cd helm-chart helm dependency update ``` ### 2. Installazione base ```bash helm install calcolatore-prezzi ./helm-chart ``` ### 3. Installazione con valori personalizzati ```bash helm install calcolatore-prezzi ./helm-chart -f custom-values.yaml ``` ### 4. Installazione con file HTML personalizzati Per iniettare i tuoi file HTML durante l'installazione: ```bash helm install calcolatore-prezzi ./helm-chart \ --set-file configMaps.html-content.data.index\.html=./index.html \ --set-file configMaps.html-content.data.shop-mode\.html=./shop-mode.html ``` ### 5. Installazione in un namespace specifico ```bash kubectl create namespace calcolatore helm install calcolatore-prezzi ./helm-chart -n calcolatore ``` ## Configurazione I seguenti parametri possono essere configurati nel file `values.yaml`: ### Parametri Applicazione | Parametro | Descrizione | Default | |-----------|-------------|---------| | `replicaCount` | Numero di repliche del pod | `2` | | `image.repository` | Repository dell'immagine Docker | `nginx` | | `image.tag` | Tag dell'immagine Docker | `alpine` | | `image.pullPolicy` | Policy di pull dell'immagine | `IfNotPresent` | ### Parametri Service | Parametro | Descrizione | Default | |-----------|-------------|---------| | `service.type` | Tipo di service Kubernetes | `ClusterIP` | | `service.port` | Porta del service | `80` | | `service.targetPort` | Porta target del container | `80` | ### Parametri Ingress | Parametro | Descrizione | Default | |-----------|-------------|---------| | `ingress.enabled` | Abilita l'ingress | `true` | | `ingress.className` | Classe dell'ingress controller | `nginx` | | `ingress.hosts[0].host` | Hostname per l'ingress | `calcolatore.example.com` | | `ingress.tls[0].secretName` | Nome del secret TLS | `calcolatore-tls` | ### Parametri Risorse | Parametro | Descrizione | Default | |-----------|-------------|---------| | `resources.limits.cpu` | Limite CPU | `200m` | | `resources.limits.memory` | Limite memoria | `256Mi` | | `resources.requests.cpu` | Request CPU | `100m` | | `resources.requests.memory` | Request memoria | `128Mi` | ### Parametri Autoscaling | Parametro | Descrizione | Default | |-----------|-------------|---------| | `autoscaling.enabled` | Abilita l'HPA | `false` | | `autoscaling.minReplicas` | Numero minimo di repliche | `2` | | `autoscaling.maxReplicas` | Numero massimo di repliche | `5` | | `autoscaling.targetCPUUtilizationPercentage` | Target CPU per scaling | `80` | ## Esempi di Configurazione ### values-production.yaml ```yaml replicaCount: 3 image: repository: your-registry.io/calcolatore-prezzi tag: "1.0.0" pullPolicy: Always ingress: enabled: true className: "nginx" annotations: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/rate-limit: "100" hosts: - host: calcolatore.yourdomain.com paths: - path: / pathType: Prefix tls: - secretName: calcolatore-prod-tls hosts: - calcolatore.yourdomain.com resources: limits: cpu: 500m memory: 512Mi requests: cpu: 250m memory: 256Mi autoscaling: enabled: true minReplicas: 3 maxReplicas: 10 targetCPUUtilizationPercentage: 70 podDisruptionBudget: enabled: true minAvailable: 2 ``` ### values-development.yaml ```yaml replicaCount: 1 image: repository: nginx tag: "alpine" pullPolicy: IfNotPresent ingress: enabled: true className: "nginx" hosts: - host: calcolatore.dev.local paths: - path: / pathType: Prefix tls: [] resources: limits: cpu: 100m memory: 128Mi requests: cpu: 50m memory: 64Mi autoscaling: enabled: false ``` ## Aggiornamento Per aggiornare il deployment: ```bash helm upgrade calcolatore-prezzi ./helm-chart ``` Con file HTML aggiornati: ```bash helm upgrade calcolatore-prezzi ./helm-chart \ --set-file configMaps.html-content.data.index\.html=./index.html \ --set-file configMaps.html-content.data.shop-mode\.html=./shop-mode.html ``` ## Disinstallazione ```bash helm uninstall calcolatore-prezzi ``` ## Testing Per testare il chart senza installarlo: ```bash # Dry run helm install calcolatore-prezzi ./helm-chart --dry-run --debug # Template rendering helm template calcolatore-prezzi ./helm-chart # Lint helm lint ./helm-chart ``` ## Deploy con CI/CD ### GitLab CI Example ```yaml deploy: stage: deploy image: alpine/helm:latest script: - helm dependency update ./helm-chart - helm upgrade --install calcolatore-prezzi ./helm-chart --namespace production --create-namespace --set image.tag=$CI_COMMIT_SHA --set-file configMaps.html-content.data.index\.html=./index.html --set-file configMaps.html-content.data.shop-mode\.html=./shop-mode.html only: - main ``` ### GitHub Actions Example ```yaml name: Deploy to Kubernetes on: push: branches: [ main ] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Install Helm uses: azure/setup-helm@v1 with: version: '3.9.0' - name: Deploy run: | helm dependency update ./helm-chart helm upgrade --install calcolatore-prezzi ./helm-chart \ --namespace production \ --create-namespace \ --set-file configMaps.html-content.data.index\.html=./index.html \ --set-file configMaps.html-content.data.shop-mode\.html=./shop-mode.html ``` ## Troubleshooting ### Verificare lo stato del deployment ```bash kubectl get pods -l app.kubernetes.io/name=calcolatore-prezzi kubectl describe pod kubectl logs ``` ### Verificare la configurazione ```bash helm get values calcolatore-prezzi helm get manifest calcolatore-prezzi ``` ### Verificare l'ingress ```bash kubectl get ingress kubectl describe ingress calcolatore-prezzi ``` ## Note - Questo chart usa il base-helm come dipendenza per standardizzare le risorse Kubernetes - I file HTML vengono iniettati tramite ConfigMap - Per ambienti di produzione, considera l'uso di un registry Docker privato e immagini custom - Assicurati di configurare correttamente i certificati SSL per la produzione ## Supporto Per problemi o domande, apri una issue nel repository del progetto.