Files
calcolatore_prezzi_software/helm-chart/README.md
d.viti 23ec5d5f32
All checks were successful
Build and Deploy / build (push) Successful in 46s
Add multi-mode HTML, Docker, Helm chart, and deploy script
- Add shop-mode.html and project-mode.html for separate calculation
modes - Refactor index.html as a landing page for mode selection - Add
Dockerfile with optimized nginx config and healthcheck - Add
.dockerignore for cleaner Docker builds - Add deploy.sh for
Helm/Kubernetes deployment automation - Add helm-chart/ with
values.yaml, Chart.yaml, templates, and documentation - Update README.md
with full instructions, features, and CI/CD examples
2025-10-13 23:25:33 +02:00

6.8 KiB

Calcolatore Prezzi Software - Helm Chart

Questo è un Helm chart semplificato per il deploy del Calcolatore Prezzi Software che utilizza il base-helm 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:

cd helm-chart
helm dependency update

2. Installazione base

helm install calcolatore-prezzi ./helm-chart

3. Installazione con valori personalizzati

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:

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

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

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

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:

helm upgrade calcolatore-prezzi ./helm-chart

Con file HTML aggiornati:

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

helm uninstall calcolatore-prezzi

Testing

Per testare il chart senza installarlo:

# 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

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

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

kubectl get pods -l app.kubernetes.io/name=calcolatore-prezzi
kubectl describe pod <pod-name>
kubectl logs <pod-name>

Verificare la configurazione

helm get values calcolatore-prezzi
helm get manifest calcolatore-prezzi

Verificare l'ingress

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.