diff --git a/harmony/src/modules/application/rust.rs b/harmony/src/modules/application/rust.rs index 4cd0739..ea9a1f2 100644 --- a/harmony/src/modules/application/rust.rs +++ b/harmony/src/modules/application/rust.rs @@ -471,52 +471,53 @@ impl RustWebapp { let (image_repo, image_tag) = image_url.rsplit_once(':').unwrap_or((image_url, "latest")); + let app_name = &self.name; + let service_port = self.service_port; // Create Chart.yaml let chart_yaml = format!( r#" apiVersion: v2 -name: {} -description: A Helm chart for the {} web application. +name: {chart_name} +description: A Helm chart for the {app_name} web application. type: application -version: 0.1.0 -appVersion: "{}" +version: 0.2.0 +appVersion: "{image_tag}" "#, - chart_name, self.name, image_tag ); fs::write(chart_dir.join("Chart.yaml"), chart_yaml)?; // Create values.yaml let values_yaml = format!( r#" -# Default values for {}. +# Default values for {chart_name}. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: - repository: {} + repository: {image_repo} pullPolicy: IfNotPresent # Overridden by the chart's appVersion - tag: "{}" + tag: "{image_tag}" service: type: ClusterIP - port: {} + port: {service_port} ingress: enabled: true + tls: true # Annotations for cert-manager to handle SSL. annotations: # Add other annotations like nginx ingress class if needed # kubernetes.io/ingress.class: nginx hosts: - - host: {} + - host: {domain} paths: - path: / pathType: ImplementationSpecific "#, - chart_name, image_repo, image_tag, self.service_port, domain, ); fs::write(chart_dir.join("values.yaml"), values_yaml)?; @@ -593,7 +594,11 @@ spec: ); fs::write(templates_dir.join("deployment.yaml"), deployment_yaml)?; + let service_port = self.service_port; + // Create templates/ingress.yaml + // TODO get issuer name and tls config from topology as it may be different from one + // cluster to another, also from one version to another let ingress_yaml = format!( r#" {{{{- if $.Values.ingress.enabled -}}}} @@ -606,13 +611,11 @@ metadata: spec: {{{{- if $.Values.ingress.tls }}}} tls: - {{{{- range $.Values.ingress.tls }}}} - - hosts: - {{{{- range .hosts }}}} - - {{{{ . | quote }}}} + - secretName: {{{{ include "chart.fullname" . }}}}-tls + hosts: + {{{{- range $.Values.ingress.hosts }}}} + - {{{{ .host | quote }}}} {{{{- end }}}} - secretName: {{{{ .secretName }}}} - {{{{- end }}}} {{{{- end }}}} rules: {{{{- range $.Values.ingress.hosts }}}} @@ -626,12 +629,11 @@ spec: service: name: {{{{ include "chart.fullname" $ }}}} port: - number: {{{{ $.Values.service.port | default {} }}}} + number: {{{{ $.Values.service.port | default {service_port} }}}} {{{{- end }}}} {{{{- end }}}} {{{{- end }}}} "#, - self.service_port ); fs::write(templates_dir.join("ingress.yaml"), ingress_yaml)?;