feat: add postgres and more templates
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
6a1dce43fd
commit
8d97ebd6d3
@ -89,14 +89,14 @@ impl Component for PostgresDatabase {
|
||||
format!("{}.yaml", self.name().replace("/", "-")),
|
||||
r#"
|
||||
{%- if environment == "dev" %}
|
||||
{% set port = 5433 %}
|
||||
{% else %}
|
||||
{% set port = 5432 %}
|
||||
{%- set port = 5433 %}
|
||||
{%- else %}
|
||||
{%- set port = 5432 %}
|
||||
{%- endif %}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ vars.cuddle_crdb.file_name(vars.cuddle_vars.service) }}
|
||||
name: {{ vars.cuddle_postgres.file_name(vars.cuddle_vars.service) }}
|
||||
namespace: {{ vars.cluster_vars.namespace }}
|
||||
data:
|
||||
DATABASE_TYPE: postgresql
|
||||
@ -104,6 +104,7 @@ data:
|
||||
DATABASE_PORT: {{ port }}
|
||||
DATABASE_USER: {{ vars.cuddle_vars.service | replace("_", "-") }}
|
||||
DATABASE_DB: {{ vars.cuddle_vars.service | replace("_", "-") }}
|
||||
|
||||
"#
|
||||
.into(),
|
||||
)));
|
||||
|
@ -354,6 +354,12 @@ async fn process_render_template(
|
||||
vars => variables
|
||||
})?;
|
||||
|
||||
let rendered = if rendered.is_empty() || rendered.ends_with("\n") {
|
||||
rendered
|
||||
} else {
|
||||
format!("{rendered}\n")
|
||||
};
|
||||
|
||||
dest_file.write_all(rendered.as_bytes()).await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: service-cuddle-postgres
|
||||
namespace: dev
|
||||
data:
|
||||
DATABASE_TYPE: postgresql
|
||||
DATABASE_HOST: dev.postgresql.kjuulh.app
|
||||
DATABASE_PORT: 5433
|
||||
DATABASE_USER: service
|
||||
DATABASE_DB: service
|
@ -1,9 +0,0 @@
|
||||
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: service-cuddle-crdb
|
||||
namespace: dev
|
||||
data:
|
||||
DATABASE_URL: postgresql://root@dev-cluster:26257/service
|
||||
|
@ -25,11 +25,26 @@ spec:
|
||||
- configMapRef:
|
||||
name: service-config
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
- name: DATABASE_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: service-cuddle-crdb
|
||||
key: DATABASE_URL
|
||||
name: service-cuddle-postgres
|
||||
key: DATABASE_HOST
|
||||
- name: DATABASE_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: service-cuddle-postgres
|
||||
key: DATABASE_PORT
|
||||
- name: DATABASE_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: service-cuddle-postgres
|
||||
key: DATABASE_USER
|
||||
- name: DATABASE_DB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: service-cuddle-postgres
|
||||
key: DATABASE_DB
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: external-http
|
||||
|
@ -26,7 +26,7 @@ spec:
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: {{service_name}}-config
|
||||
{%- if vars.vault_secret.has_values or vars.cuddle_crdb.has_values %}
|
||||
{%- if vars.vault_secret.has_values or vars.cuddle_postgres.has_values %}
|
||||
env:
|
||||
{%- if vars.vault_secret.has_values %}
|
||||
{%- for secret in vars.vault_secret.secrets %}
|
||||
|
Loading…
Reference in New Issue
Block a user