feat: Support tls enabled by default on rust web app
Some checks failed
Run Check Script / check (pull_request) Failing after 15s
Some checks failed
Run Check Script / check (pull_request) Failing after 15s
This commit is contained in:
parent
b0ad7bb4c4
commit
69a159711a
@ -471,52 +471,53 @@ impl RustWebapp {
|
|||||||
|
|
||||||
let (image_repo, image_tag) = image_url.rsplit_once(':').unwrap_or((image_url, "latest"));
|
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
|
// Create Chart.yaml
|
||||||
let chart_yaml = format!(
|
let chart_yaml = format!(
|
||||||
r#"
|
r#"
|
||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: {}
|
name: {chart_name}
|
||||||
description: A Helm chart for the {} web application.
|
description: A Helm chart for the {app_name} web application.
|
||||||
type: application
|
type: application
|
||||||
version: 0.1.0
|
version: 0.2.0
|
||||||
appVersion: "{}"
|
appVersion: "{image_tag}"
|
||||||
"#,
|
"#,
|
||||||
chart_name, self.name, image_tag
|
|
||||||
);
|
);
|
||||||
fs::write(chart_dir.join("Chart.yaml"), chart_yaml)?;
|
fs::write(chart_dir.join("Chart.yaml"), chart_yaml)?;
|
||||||
|
|
||||||
// Create values.yaml
|
// Create values.yaml
|
||||||
let values_yaml = format!(
|
let values_yaml = format!(
|
||||||
r#"
|
r#"
|
||||||
# Default values for {}.
|
# Default values for {chart_name}.
|
||||||
# This is a YAML-formatted file.
|
# This is a YAML-formatted file.
|
||||||
# Declare variables to be passed into your templates.
|
# Declare variables to be passed into your templates.
|
||||||
|
|
||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
image:
|
image:
|
||||||
repository: {}
|
repository: {image_repo}
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
# Overridden by the chart's appVersion
|
# Overridden by the chart's appVersion
|
||||||
tag: "{}"
|
tag: "{image_tag}"
|
||||||
|
|
||||||
service:
|
service:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
port: {}
|
port: {service_port}
|
||||||
|
|
||||||
ingress:
|
ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
tls: true
|
||||||
# Annotations for cert-manager to handle SSL.
|
# Annotations for cert-manager to handle SSL.
|
||||||
annotations:
|
annotations:
|
||||||
# Add other annotations like nginx ingress class if needed
|
# Add other annotations like nginx ingress class if needed
|
||||||
# kubernetes.io/ingress.class: nginx
|
# kubernetes.io/ingress.class: nginx
|
||||||
hosts:
|
hosts:
|
||||||
- host: {}
|
- host: {domain}
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
pathType: ImplementationSpecific
|
pathType: ImplementationSpecific
|
||||||
"#,
|
"#,
|
||||||
chart_name, image_repo, image_tag, self.service_port, domain,
|
|
||||||
);
|
);
|
||||||
fs::write(chart_dir.join("values.yaml"), values_yaml)?;
|
fs::write(chart_dir.join("values.yaml"), values_yaml)?;
|
||||||
|
|
||||||
@ -593,7 +594,11 @@ spec:
|
|||||||
);
|
);
|
||||||
fs::write(templates_dir.join("deployment.yaml"), deployment_yaml)?;
|
fs::write(templates_dir.join("deployment.yaml"), deployment_yaml)?;
|
||||||
|
|
||||||
|
let service_port = self.service_port;
|
||||||
|
|
||||||
// Create templates/ingress.yaml
|
// 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!(
|
let ingress_yaml = format!(
|
||||||
r#"
|
r#"
|
||||||
{{{{- if $.Values.ingress.enabled -}}}}
|
{{{{- if $.Values.ingress.enabled -}}}}
|
||||||
@ -606,13 +611,11 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
{{{{- if $.Values.ingress.tls }}}}
|
{{{{- if $.Values.ingress.tls }}}}
|
||||||
tls:
|
tls:
|
||||||
{{{{- range $.Values.ingress.tls }}}}
|
- secretName: {{{{ include "chart.fullname" . }}}}-tls
|
||||||
- hosts:
|
hosts:
|
||||||
{{{{- range .hosts }}}}
|
{{{{- range $.Values.ingress.hosts }}}}
|
||||||
- {{{{ . | quote }}}}
|
- {{{{ .host | quote }}}}
|
||||||
{{{{- end }}}}
|
{{{{- end }}}}
|
||||||
secretName: {{{{ .secretName }}}}
|
|
||||||
{{{{- end }}}}
|
|
||||||
{{{{- end }}}}
|
{{{{- end }}}}
|
||||||
rules:
|
rules:
|
||||||
{{{{- range $.Values.ingress.hosts }}}}
|
{{{{- range $.Values.ingress.hosts }}}}
|
||||||
@ -626,12 +629,11 @@ spec:
|
|||||||
service:
|
service:
|
||||||
name: {{{{ include "chart.fullname" $ }}}}
|
name: {{{{ include "chart.fullname" $ }}}}
|
||||||
port:
|
port:
|
||||||
number: {{{{ $.Values.service.port | default {} }}}}
|
number: {{{{ $.Values.service.port | default {service_port} }}}}
|
||||||
{{{{- end }}}}
|
{{{{- end }}}}
|
||||||
{{{{- end }}}}
|
{{{{- end }}}}
|
||||||
{{{{- end }}}}
|
{{{{- end }}}}
|
||||||
"#,
|
"#,
|
||||||
self.service_port
|
|
||||||
);
|
);
|
||||||
fs::write(templates_dir.join("ingress.yaml"), ingress_yaml)?;
|
fs::write(templates_dir.join("ingress.yaml"), ingress_yaml)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user