diff --git a/helm/rrt-sales-wizard/Chart.yaml b/helm/rrt-sales-wizard/Chart.yaml new file mode 100644 index 0000000..a82d43f --- /dev/null +++ b/helm/rrt-sales-wizard/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +name: rrt-sales-wizard +description: Helm chart per RRT Sales Wizard - App React per raccolta requisiti +type: application +version: 0.1.0 +appVersion: "1.0.0" +maintainers: + - name: RRT Team +keywords: + - react + - wizard + - sales + - requirements diff --git a/helm/rrt-sales-wizard/templates/NOTES.txt b/helm/rrt-sales-wizard/templates/NOTES.txt new file mode 100644 index 0000000..b9f3192 --- /dev/null +++ b/helm/rrt-sales-wizard/templates/NOTES.txt @@ -0,0 +1,26 @@ +RRT Sales Wizard installato correttamente! + +Per accedere all'applicazione: + +{{- if .Values.ingress.enabled }} + L'applicazione e' raggiungibile tramite Ingress: + {{- range $host := .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }} + {{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "rrt-sales-wizard.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTA: Potrebbe volerci qualche minuto per ottenere l'IP del LoadBalancer. + Controlla lo stato con: + kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "rrt-sales-wizard.fullname" . }} + + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "rrt-sales-wizard.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + Esegui il port-forward per accedere all'applicazione: + kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "rrt-sales-wizard.fullname" . }} 8080:{{ .Values.service.port }} + + Poi apri: http://localhost:8080 +{{- end }} diff --git a/helm/rrt-sales-wizard/templates/_helpers.tpl b/helm/rrt-sales-wizard/templates/_helpers.tpl new file mode 100644 index 0000000..27271be --- /dev/null +++ b/helm/rrt-sales-wizard/templates/_helpers.tpl @@ -0,0 +1,60 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rrt-sales-wizard.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "rrt-sales-wizard.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "rrt-sales-wizard.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rrt-sales-wizard.labels" -}} +helm.sh/chart: {{ include "rrt-sales-wizard.chart" . }} +{{ include "rrt-sales-wizard.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rrt-sales-wizard.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rrt-sales-wizard.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rrt-sales-wizard.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rrt-sales-wizard.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/rrt-sales-wizard/templates/deployment.yaml b/helm/rrt-sales-wizard/templates/deployment.yaml new file mode 100644 index 0000000..00f7210 --- /dev/null +++ b/helm/rrt-sales-wizard/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "rrt-sales-wizard.fullname" . }} + labels: + {{- include "rrt-sales-wizard.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "rrt-sales-wizard.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "rrt-sales-wizard.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.serviceAccount.create }} + serviceAccountName: {{ include "rrt-sales-wizard.serviceAccountName" . }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/rrt-sales-wizard/templates/hpa.yaml b/helm/rrt-sales-wizard/templates/hpa.yaml new file mode 100644 index 0000000..6a5a3fa --- /dev/null +++ b/helm/rrt-sales-wizard/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "rrt-sales-wizard.fullname" . }} + labels: + {{- include "rrt-sales-wizard.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "rrt-sales-wizard.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm/rrt-sales-wizard/templates/ingress.yaml b/helm/rrt-sales-wizard/templates/ingress.yaml new file mode 100644 index 0000000..b659721 --- /dev/null +++ b/helm/rrt-sales-wizard/templates/ingress.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "rrt-sales-wizard.fullname" . }} + labels: + {{- include "rrt-sales-wizard.labels" . | nindent 4 }} + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "rrt-sales-wizard.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/rrt-sales-wizard/templates/service.yaml b/helm/rrt-sales-wizard/templates/service.yaml new file mode 100644 index 0000000..a5b0d9e --- /dev/null +++ b/helm/rrt-sales-wizard/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rrt-sales-wizard.fullname" . }} + labels: + {{- include "rrt-sales-wizard.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "rrt-sales-wizard.selectorLabels" . | nindent 4 }} diff --git a/helm/rrt-sales-wizard/values.yaml b/helm/rrt-sales-wizard/values.yaml new file mode 100644 index 0000000..70f193d --- /dev/null +++ b/helm/rrt-sales-wizard/values.yaml @@ -0,0 +1,83 @@ +replicaCount: 1 + +image: + repository: rrt-sales-wizard + pullPolicy: IfNotPresent + tag: "latest" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: false + automount: true + annotations: {} + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + +securityContext: + readOnlyRootFilesystem: false + runAsNonRoot: true + runAsUser: 101 # nginx user + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + labels: {} + # dns-scope: public + annotations: {} + # kubernetes.io/ingress.class: nginx + # cert-manager.io/cluster-issuer: letsencrypt-prod + hosts: + - host: rrt-sales-wizard.local + paths: + - path: / + pathType: Prefix + tls: [] + # - secretName: rrt-sales-wizard-tls + # hosts: + # - rrt-sales-wizard.local + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 50m + memory: 64Mi + +livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + +readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 5 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 5 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}