Compare commits
4 Commits
feat/add-p
...
main
Author | SHA1 | Date | |
---|---|---|---|
b70f3f4f72 | |||
29a98b5ef5 | |||
a9c81a8f1b | |||
3956366d28 |
81
CHANGELOG.md
81
CHANGELOG.md
@ -6,6 +6,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.2.0] - 2024-11-29
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- feat/add-postgres-database (#20)
|
||||||
|
|
||||||
|
feat: add postgres database
|
||||||
|
|
||||||
|
Signed-off-by: kjuulh <contact@kjuulh.io>
|
||||||
|
|
||||||
|
feat: add postgres and more templates
|
||||||
|
|
||||||
|
Signed-off-by: kjuulh <contact@kjuulh.io>
|
||||||
|
|
||||||
|
Reviewed-on: https://git.front.kjuulh.io/kjuulh/cuddle-clusters/pulls/20
|
||||||
|
Co-authored-by: kjuulh <contact@kjuulh.io>
|
||||||
|
Co-committed-by: kjuulh <contact@kjuulh.io>
|
||||||
|
|
||||||
|
- add support for raw reading of variables
|
||||||
|
- add replicas
|
||||||
|
- set interval down to a minute
|
||||||
|
- with native roots
|
||||||
|
- with explicit install
|
||||||
|
- with install
|
||||||
|
- with ring
|
||||||
|
- enable stuff
|
||||||
|
- update packages
|
||||||
|
- update packages
|
||||||
|
- add actual grpc service
|
||||||
|
- fix typo
|
||||||
|
- revert to actual label
|
||||||
|
- fix scheme
|
||||||
|
- trying with h2c service
|
||||||
|
- add grpc ports as well
|
||||||
|
- fix name
|
||||||
|
- rename
|
||||||
|
- remove suffix
|
||||||
|
- add ingress
|
||||||
|
- add ingress wip
|
||||||
|
- use lower case
|
||||||
|
- use actual service name
|
||||||
|
- cannot use lowe case
|
||||||
|
- update filename
|
||||||
|
- add namespace
|
||||||
|
- update env
|
||||||
|
- add crdb
|
||||||
|
- add webroots
|
||||||
|
- with tls
|
||||||
|
- use new tokio stream
|
||||||
|
- update client
|
||||||
|
- more debugging
|
||||||
|
- update
|
||||||
|
- update flux releaser
|
||||||
|
- actually set registry
|
||||||
|
- add option for releaser
|
||||||
|
- add slot for upload strategy
|
||||||
|
- add user variables to input
|
||||||
|
- without remove all
|
||||||
|
- plan -> base
|
||||||
|
- add sync
|
||||||
|
- add send
|
||||||
|
- use arc instead
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- *(deps)* update rust crate serde to v1.0.215
|
||||||
|
- *(deps)* update rust crate futures to v0.3.31
|
||||||
|
- *(deps)* update rust crate minijinja to v2.3.1
|
||||||
|
- *(deps)* update rust crate minijinja to v2.3.0
|
||||||
|
- *(deps)* update rust crate serde to v1.0.203
|
||||||
|
- only create vault secret template if actual secret found
|
||||||
|
|
||||||
|
### Other
|
||||||
|
- *(deps)* update rust crate tracing to v0.1.41
|
||||||
|
- *(deps)* update all dependencies
|
||||||
|
- *(deps)* update rust crate clap to v4.5.20
|
||||||
|
- *(deps)* update rust crate clap to v4.5.19
|
||||||
|
- *(deps)* update rust crate clap to v4.5.18
|
||||||
|
- *(deps)* update rust crate anyhow to v1.0.89
|
||||||
|
- *(deps)* update rust crate anyhow to v1.0.88
|
||||||
|
- *(deps)* update all dependencies
|
||||||
|
- move crdb to own file
|
||||||
|
|
||||||
## [0.1.1] - 2024-05-25
|
## [0.1.1] - 2024-05-25
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
@ -111,9 +111,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.93"
|
version = "1.0.94"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-channel"
|
name = "async-channel"
|
||||||
@ -854,9 +854,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.21"
|
version = "4.5.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
|
checksum = "69371e34337c4c984bbe322360c2547210bf632eb2814bbe78a6e87a2935bd2b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@ -864,9 +864,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.21"
|
version = "4.5.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
|
checksum = "6e24c1b4099818523236a8ca881d2b45db98dadfb4625cf6608c12069fcbbde1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
@ -3605,9 +3605,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.41.1"
|
version = "1.42.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33"
|
checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
@ -3802,9 +3802,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-subscriber"
|
name = "tracing-subscriber"
|
||||||
version = "0.3.18"
|
version = "0.3.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
|
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"matchers",
|
"matchers",
|
||||||
"nu-ansi-term",
|
"nu-ansi-term",
|
||||||
|
@ -14,4 +14,4 @@ dotenv = { version = "0.15" }
|
|||||||
flux-releaser = { git = "https://git.front.kjuulh.io/kjuulh/flux-releaser", branch = "main" }
|
flux-releaser = { git = "https://git.front.kjuulh.io/kjuulh/flux-releaser", branch = "main" }
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.1"
|
version = "0.2.0"
|
||||||
|
@ -2,4 +2,5 @@ pub mod cluster_vars;
|
|||||||
pub mod crdb_database;
|
pub mod crdb_database;
|
||||||
pub mod cuddle_vars;
|
pub mod cuddle_vars;
|
||||||
pub mod ingress;
|
pub mod ingress;
|
||||||
|
pub mod postgres_database;
|
||||||
pub mod vault_secret;
|
pub mod vault_secret;
|
||||||
|
@ -81,10 +81,6 @@ impl Component for ClusterVars {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// vars.raw = match value.clone().try_into() {
|
|
||||||
// Ok(o) => o,
|
|
||||||
// Err(e) => panic!("{}", e),
|
|
||||||
// };
|
|
||||||
vars.raw = value.into();
|
vars.raw = value.into();
|
||||||
|
|
||||||
vars.name = environment.into();
|
vars.name = environment.into();
|
||||||
|
146
crates/cuddle-clusters/src/catalog/postgres_database.rs
Normal file
146
crates/cuddle-clusters/src/catalog/postgres_database.rs
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use minijinja::{value::Object, Value};
|
||||||
|
|
||||||
|
use crate::Component;
|
||||||
|
|
||||||
|
use super::cuddle_vars::{load_cuddle_file, CuddleVariable, CuddleVariables};
|
||||||
|
|
||||||
|
pub struct PostgresDatabase {
|
||||||
|
variables: CuddleVariables,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PostgresDatabase {
|
||||||
|
pub async fn new(path: &Path) -> anyhow::Result<Self> {
|
||||||
|
let variables = load_cuddle_file(path).await?;
|
||||||
|
|
||||||
|
Ok(Self { variables })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Component for PostgresDatabase {
|
||||||
|
fn name(&self) -> String {
|
||||||
|
"cuddle/postgres".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_value(
|
||||||
|
&self,
|
||||||
|
environment: &str,
|
||||||
|
_value: &serde_yaml::Value,
|
||||||
|
) -> Option<anyhow::Result<minijinja::Value>> {
|
||||||
|
if let Some(true) = self
|
||||||
|
.variables
|
||||||
|
.0
|
||||||
|
.get("database")
|
||||||
|
.and_then(|v| match v {
|
||||||
|
CuddleVariable::Object(o) => Some(o),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.and_then(|o| o.0.get("postgres"))
|
||||||
|
.and_then(|o| match o {
|
||||||
|
CuddleVariable::String(o) => {
|
||||||
|
if o == "true" {
|
||||||
|
Some(true)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return Some(Ok(minijinja::Value::from_object(PostgresDatabaseValues {
|
||||||
|
name: self.name(),
|
||||||
|
enabled: true,
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(Ok(minijinja::Value::from_object(PostgresDatabaseValues {
|
||||||
|
name: self.name(),
|
||||||
|
enabled: false,
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(
|
||||||
|
&self,
|
||||||
|
environment: &str,
|
||||||
|
_value: &serde_yaml::Value,
|
||||||
|
) -> Option<anyhow::Result<(String, String)>> {
|
||||||
|
if let Some(true) = self
|
||||||
|
.variables
|
||||||
|
.0
|
||||||
|
.get("database")
|
||||||
|
.and_then(|v| match v {
|
||||||
|
CuddleVariable::Object(o) => Some(o),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
.and_then(|o| o.0.get("postgres"))
|
||||||
|
.and_then(|o| match o {
|
||||||
|
CuddleVariable::String(o) => {
|
||||||
|
if o == "true" {
|
||||||
|
Some(true)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return Some(Ok((
|
||||||
|
format!("{}.yaml", self.name().replace("/", "-")),
|
||||||
|
r#"
|
||||||
|
{%- if environment == "dev" %}
|
||||||
|
{%- set port = 5433 %}
|
||||||
|
{%- else %}
|
||||||
|
{%- set port = 5432 %}
|
||||||
|
{%- endif %}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ vars.cuddle_postgres.file_name(vars.cuddle_vars.service) }}
|
||||||
|
namespace: {{ vars.cluster_vars.namespace }}
|
||||||
|
data:
|
||||||
|
DATABASE_TYPE: postgresql
|
||||||
|
DATABASE_HOST: {{ environment }}.postgresql.kjuulh.app
|
||||||
|
DATABASE_PORT: {{ port }}
|
||||||
|
DATABASE_USER: {{ vars.cuddle_vars.service | replace("_", "-") }}
|
||||||
|
DATABASE_DB: {{ vars.cuddle_vars.service | replace("_", "-") }}
|
||||||
|
|
||||||
|
"#
|
||||||
|
.into(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct PostgresDatabaseValues {
|
||||||
|
name: String,
|
||||||
|
enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for PostgresDatabaseValues {
|
||||||
|
fn get_value(self: &std::sync::Arc<Self>, key: &minijinja::Value) -> Option<minijinja::Value> {
|
||||||
|
let name = self.name.clone();
|
||||||
|
match key.as_str()? {
|
||||||
|
"has_values" => {
|
||||||
|
if self.enabled {
|
||||||
|
Some(minijinja::Value::from_serialize(true))
|
||||||
|
} else {
|
||||||
|
Some(minijinja::Value::from_serialize(false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"file_name" => Some(Value::from_function(move |file_name: String| {
|
||||||
|
format!("{}-{}", file_name, name.replace("/", "-"))
|
||||||
|
})),
|
||||||
|
"env" => Some(Value::from_serialize(vec![
|
||||||
|
"DATABASE_HOST",
|
||||||
|
"DATABASE_PORT",
|
||||||
|
"DATABASE_USER",
|
||||||
|
"DATABASE_DB",
|
||||||
|
])),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -354,6 +354,12 @@ async fn process_render_template(
|
|||||||
vars => variables
|
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?;
|
dest_file.write_all(rendered.as_bytes()).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
some = {
|
some = {
|
||||||
thing = "some"
|
thing = "some"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
env: dev
|
env: dev
|
||||||
|
@ -1 +1 @@
|
|||||||
env: prod
|
env: prod
|
||||||
|
@ -1 +1 @@
|
|||||||
some_file: 4
|
some_file: 4
|
||||||
|
@ -1 +1 @@
|
|||||||
service
|
service
|
||||||
|
@ -1 +1 @@
|
|||||||
service
|
service
|
||||||
|
@ -1 +1 @@
|
|||||||
service
|
service
|
||||||
|
@ -6,7 +6,7 @@ mod cuddle_vars;
|
|||||||
use cuddle_clusters::{
|
use cuddle_clusters::{
|
||||||
catalog::{
|
catalog::{
|
||||||
cluster_vars::ClusterVars, crdb_database::CockroachDB, cuddle_vars::CuddleVars,
|
cluster_vars::ClusterVars, crdb_database::CockroachDB, cuddle_vars::CuddleVars,
|
||||||
ingress::Ingress, vault_secret::VaultSecret,
|
ingress::Ingress, postgres_database::PostgresDatabase, vault_secret::VaultSecret,
|
||||||
},
|
},
|
||||||
IntoComponent,
|
IntoComponent,
|
||||||
};
|
};
|
||||||
@ -125,3 +125,21 @@ async fn with_ingress() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn with_postgres_databse() -> anyhow::Result<()> {
|
||||||
|
let current_dir = std::env::current_dir()?.join("tests/with_postgres_database");
|
||||||
|
|
||||||
|
run_test_with_components(
|
||||||
|
"with_postgres_database",
|
||||||
|
vec![
|
||||||
|
CuddleVars::new(¤t_dir).await?.into_component(),
|
||||||
|
ClusterVars::default().into_component(),
|
||||||
|
VaultSecret::default().into_component(),
|
||||||
|
PostgresDatabase::new(¤t_dir).await?.into_component(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
@ -6,4 +6,4 @@ metadata:
|
|||||||
namespace: dev
|
namespace: dev
|
||||||
data:
|
data:
|
||||||
DATABASE_URL: postgresql://root@dev-cluster:26257/service
|
DATABASE_URL: postgresql://root@dev-cluster:26257/service
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ spec:
|
|||||||
- containerPort: 3001
|
- containerPort: 3001
|
||||||
name: internal-http
|
name: internal-http
|
||||||
- containerPort: 3002
|
- containerPort: 3002
|
||||||
name: internal-grpc
|
name: internal-grpc
|
||||||
|
@ -118,4 +118,4 @@ spec:
|
|||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- grpc.service.dev.internal.kjuulh.app
|
- grpc.service.dev.internal.kjuulh.app
|
||||||
secretName: tls-service-kjuulh-app-internal-grpc-ingress-dns
|
secretName: tls-service-kjuulh-app-internal-grpc-ingress-dns
|
||||||
|
@ -27,4 +27,4 @@ spec:
|
|||||||
- containerPort: 3001
|
- containerPort: 3001
|
||||||
name: internal-http
|
name: internal-http
|
||||||
- containerPort: 3002
|
- containerPort: 3002
|
||||||
name: internal-grpc
|
name: internal-grpc
|
||||||
|
@ -118,4 +118,4 @@ spec:
|
|||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- grpc.service.prod.internal.kjuulh.app
|
- grpc.service.prod.internal.kjuulh.app
|
||||||
secretName: tls-service-kjuulh-app-internal-grpc-ingress-dns
|
secretName: tls-service-kjuulh-app-internal-grpc-ingress-dns
|
||||||
|
@ -27,4 +27,4 @@ spec:
|
|||||||
- containerPort: 3001
|
- containerPort: 3001
|
||||||
name: internal-http
|
name: internal-http
|
||||||
- containerPort: 3002
|
- containerPort: 3002
|
||||||
name: internal-grpc
|
name: internal-grpc
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
vars:
|
||||||
|
service: service
|
||||||
|
database:
|
||||||
|
postgres: "true"
|
||||||
|
|
||||||
|
cuddle/clusters:
|
||||||
|
dev:
|
@ -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
|
@ -0,0 +1,54 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: service
|
||||||
|
name: service
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: service
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: service
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- serve
|
||||||
|
command:
|
||||||
|
- service
|
||||||
|
image: kasperhermansen/service:main-1715336504
|
||||||
|
name: service
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: service-config
|
||||||
|
env:
|
||||||
|
- name: DATABASE_HOST
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
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
|
||||||
|
- containerPort: 3001
|
||||||
|
name: internal-http
|
||||||
|
- containerPort: 3002
|
||||||
|
name: internal-grpc
|
@ -0,0 +1,56 @@
|
|||||||
|
{%- set service_name = vars.cuddle_vars.service -%}
|
||||||
|
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ service_name }}
|
||||||
|
name: {{ service_name }}
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ service_name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ service_name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- args:
|
||||||
|
- serve
|
||||||
|
command:
|
||||||
|
- {{ service_name }}
|
||||||
|
image: kasperhermansen/{{ service_name }}:main-1715336504
|
||||||
|
name: {{ service_name }}
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: {{service_name}}-config
|
||||||
|
{%- 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 %}
|
||||||
|
- name: {{secret | upper | replace(".", "_") | replace("-", "_") }}
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ vars.vault_secret.file_name(service_name) }}
|
||||||
|
key: {{ secret }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- if vars.cuddle_postgres.has_values %}
|
||||||
|
{%- for env in vars.cuddle_postgres.env %}
|
||||||
|
- name: {{ env }}
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ vars.cuddle_postgres.file_name(service_name) }}
|
||||||
|
key: {{ env }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
name: external-http
|
||||||
|
- containerPort: 3001
|
||||||
|
name: internal-http
|
||||||
|
- containerPort: 3002
|
||||||
|
name: internal-grpc
|
@ -36,4 +36,4 @@ spec:
|
|||||||
- containerPort: 3001
|
- containerPort: 3001
|
||||||
name: internal-http
|
name: internal-http
|
||||||
- containerPort: 3002
|
- containerPort: 3002
|
||||||
name: internal-grpc
|
name: internal-grpc
|
||||||
|
@ -10,4 +10,4 @@ spec:
|
|||||||
mount: kvv2
|
mount: kvv2
|
||||||
path: service/dev
|
path: service/dev
|
||||||
refreshAfter: 30s
|
refreshAfter: 30s
|
||||||
type: kv-v2
|
type: kv-v2
|
||||||
|
Loading…
Reference in New Issue
Block a user