Compare commits

...

53 Commits

Author SHA1 Message Date
a1985d38d5 chore(deps): update rust crate clap to v4.5.18
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-21 00:47:20 +00:00
07a083ed7e chore(deps): update rust crate anyhow to v1.0.89
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-15 04:23:26 +00:00
0575c92a71 chore(deps): update rust crate anyhow to v1.0.88
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-12 00:25:24 +00:00
aeba0f00c6
feat: include port as well
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-09-08 12:54:42 +02:00
a74225d9da
feat: update image
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-09-08 12:45:59 +02:00
64a8ff073e
feat: now with explicit run
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-09-07 23:51:28 +02:00
5b5ac71a1e chore(deps): update rust crate anyhow to v1.0.87
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-07 00:23:09 +00:00
5a68e8bbdf chore(deps): update rust crate clap to v4.5.17
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-05 00:23:29 +00:00
5967fe9e1d fix(deps): update rust crate async-trait to v0.1.82
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-09-03 00:21:02 +00:00
312515157c chore(deps): update rust crate tokio to v1.40.0
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-08-30 08:20:19 +00:00
05821b0f23 chore(deps): update all dependencies
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-08-21 20:51:13 +00:00
e9abbfb266
feat: update service
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-08-01 23:04:53 +02:00
56c01088b8 chore(deps): update rust crate clap to v4.5.8
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-07-06 13:32:21 +00:00
1d76c7b826
feat: update url
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-07-05 23:23:23 +02:00
39a73ee4f0
feat: update stuff
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-06-01 14:47:02 +02:00
3baff7fe7c
feat: add grpc service
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 23:01:03 +02:00
b016bfcc5d
feat: adding to service instead
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 22:45:17 +02:00
63e7ef1c63
feat: update grpc service as well
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 21:49:40 +02:00
b7dfb28b10
feat: adding grpc
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 21:47:52 +02:00
7c83d04f48
feat: adding grpc
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 21:44:40 +02:00
7e15006175
feat: add proto
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-29 21:22:09 +02:00
abac0169d8
chore(test): test commit
Some checks failed
continuous-integration/drone/push Build is failing
2024-05-29 19:47:26 +02:00
ef737418c3
feat: remove nesting
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-27 22:50:51 +02:00
22319ce56d
feat: update deps
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 23:31:45 +02:00
bd6b19fde6
feat: add crdb to config mpa instead
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 23:26:21 +02:00
9f499a4be7
feat: add namespace to cluster
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 23:23:05 +02:00
4308016351
feat: add crdb
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 23:15:06 +02:00
7fc0d8c204
feat: add service
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 21:31:39 +02:00
c93ee9823c
feat: add webroots
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-26 20:47:03 +02:00
c1d71df0e5
feat: upload of data
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-25 23:43:19 +02:00
90928d08ff
feat: add old
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-25 14:10:39 +02:00
03d293bdc8
feat: produce new templates
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-25 14:08:54 +02:00
f112bcf1a9
chore: remove deps
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-05-25 13:47:23 +02:00
98f5bd5c09 chore(deps): update rust crate anyhow to 1.0.86
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-05-18 12:34:07 +00:00
5e6905d3b1 chore(deps): update rust crate anyhow to 1.0.85
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-05-17 22:49:23 +00:00
70650902d0 chore(deps): update rust crate anyhow to 1.0.84
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2024-05-17 18:26:09 +00:00
5836f63ce2 chore(deps): update rust crate anyhow to 1.0.83
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2024-05-06 18:27:51 +00:00
d260e48bba fix(deps): update rust crate async-trait to 0.1.80
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-04-11 19:08:40 +00:00
4b97c91b8b chore(deps): update rust crate anyhow to 1.0.82
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2024-04-10 04:37:43 +00:00
00daeaf166
feat: with cuddle file setup
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-04-05 23:09:58 +02:00
310df8f127
feat: with cuddle file
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-04-05 22:47:44 +02:00
e1d19c8fc1
feat: without extra types
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 23:48:57 +01:00
2c25e6e75b
feat: add workspace crates
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 22:47:42 +01:00
ecdf3e98bf
feat: update dagger
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 21:40:54 +01:00
c61abf50ec
feat: with docker
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 20:39:50 +01:00
5caf30ec9d
feat: try with prs as well
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 16:27:27 +01:00
09f0f0152b
feat: rename plan
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 16:23:26 +01:00
1582b6b754
feat: add service plan template
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-03-30 16:21:00 +01:00
5e49d71f0f chore(deps): update rust crate clap to 4.5.4
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-03-25 21:46:43 +00:00
cca765e1b0 fix(deps): update rust crate async-trait to 0.1.79
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-03-24 03:48:39 +00:00
b1930d6fa2 fix(deps): update rust crate async-trait to 0.1.78
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-03-17 00:16:55 +00:00
dbb418ebe2 chore(deps): update rust crate clap to 4.5.3
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2024-03-15 13:32:17 +00:00
237a1d094c chore(deps): update rust crate anyhow to 1.0.81
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2024-03-12 03:16:11 +00:00
16 changed files with 3512 additions and 414 deletions

View File

@ -47,8 +47,6 @@ steps:
volumes:
- name: ssh
path: /root/.ssh/
- name: dockersock
path: /var/run
- name: ci
path: /mnt/ci
commands:
@ -56,13 +54,21 @@ steps:
- ssh-add
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username="$DOCKER_USERNAME" docker.io
- apk add git
- cuddle --version
- $CI_PREFIX pr
environment:
DAGGER_CLOUD_TOKEN:
from_secret: dagger_cloud_token
DRONE_HOST: "https://ci.i.kjuulh.io"
DRONE_USER: "kjuulh"
DRONE_TOKEN:
from_secret: drone_token
DOCKER_BUILDKIT: 1
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_HOST: "tcp://192.168.1.155:2376"
CUDDLE_SECRETS_PROVIDER: 1password
CUDDLE_ONE_PASSWORD_DOT_ENV: ".env.ci"
CUDDLE_SSH_AGENT: "true"
@ -87,8 +93,6 @@ steps:
volumes:
- name: ssh
path: /root/.ssh/
# - name: dockersock
# path: /var/run
- name: ci
path: /mnt/ci
commands:
@ -96,8 +100,15 @@ steps:
- ssh-add
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username="$DOCKER_USERNAME" docker.io
- apk add git
- cuddle --version
- $CI_PREFIX main
environment:
DAGGER_CLOUD_TOKEN:
from_secret: dagger_cloud_token
DRONE_HOST: "https://ci.i.kjuulh.io"
DRONE_USER: "kjuulh"
DRONE_TOKEN:
from_secret: drone_token
REGISTRY_CACHE_USERNAME:
from_secret: registry_cache_username
REGISTRY_CACHE_PASSWORD:
@ -117,7 +128,7 @@ steps:
GIT_PASSWORD:
from_secret: git_password
CI_PREFIX: "/mnt/ci/ci"
DOCKER_HOST: "tcp://192.168.1.233:2376"
DOCKER_HOST: "tcp://192.168.1.155:2376"
CUDDLE_PLEASE_TOKEN:
from_secret: cuddle_please_token
OP_SERVICE_ACCOUNT_TOKEN:
@ -140,8 +151,6 @@ steps:
volumes:
- name: ssh
path: /root/.ssh/
- name: dockersock
path: /var/run
- name: ci
path: /mnt/ci
commands:
@ -175,18 +184,8 @@ steps:
- "load_secret"
- "build ci"
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: ssh
temp: {}
- name: dockersock
temp: {}
- name: ci
temp: {}

3371
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,11 @@ resolver = "2"
[workspace.dependencies]
anyhow = { version = "1.0.80" }
anyhow = { version = "1.0.86" }
tokio = { version = "1", features = ["full"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3.18" }
clap = { version = "4.5.2", features = ["derive", "env"] }
clap = { version = "4.5.4", features = ["derive", "env"] }
dotenv = { version = "0.15.0" }
cuddle-clusters = { git = "https://git.front.kjuulh.io/kjuulh/cuddle-clusters", branch = "main" } #tag = "v0.1.1" }

View File

@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
tokio.workspace = true
dagger-sdk = {git = "https://github.com/kjuulh/dagger.git", branch = "feat/with-send-sync"}
dagger-sdk = "0.11.10"
eyre = { version = "0.6.12" }
dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }

View File

@ -1,15 +1,17 @@
use std::sync::Arc;
use cuddle_ci::drone_templater::DroneTemplater;
use cuddle_ci::rust_service::architecture::{Architecture, Os};
use cuddle_ci::rust_service::{extensions::*, RustService};
use cuddle_ci::CuddleCI;
use tokio::sync::Mutex;
const BIN_NAME: &str = "cuddle-rust-service-plan";
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let service = RustService::from(client)
dagger_sdk::connect(|client| async move {
let service = &RustService::from(client.clone())
.with_arch(Architecture::Amd64)
.with_os(Os::Linux)
.with_apt(&[
@ -19,25 +21,33 @@ async fn main() -> eyre::Result<()> {
"libgit2-dev",
"git",
"openssh-client",
"protobuf-compiler",
])
.with_apt_release(&["git", "openssh-client"])
.with_apt_release(&["git", "openssh-client", "protobuf-compiler"])
.with_docker_cli()
.with_cuddle_cli()
.with_kubectl()
.with_apt_ca_certificates()
.with_crates(["ci", "crates/*"])
.with_mold("2.3.3")
.with_bin_name("cuddle-rust-service-plan")
.with_bin_name(BIN_NAME)
.with_deployment(false)
.to_owned();
let service = Arc::new(Mutex::new(service));
let drone_templater =
&DroneTemplater::new(client, "templates/cuddle-rust-service-plan.yaml")
.with_variable("bin_name", BIN_NAME)
.to_owned();
CuddleCI::default()
.with_pull_request(service.clone())
.with_main(service.clone())
.with_pull_request(service)
.with_main(service)
.with_main(drone_templater)
.execute(std::env::args())
.await?;
Ok(())
})
.await?;
Ok(())
}

View File

@ -6,10 +6,14 @@ edition = "2021"
[dependencies]
tokio.workspace = true
dagger-sdk = {git = "https://github.com/kjuulh/dagger.git", branch = "feat/with-send-sync"}
dagger-sdk = "0.11.10"
eyre = { version = "0.6.12" }
tracing.workspace = true
tracing-subscriber.workspace = true
dagger-components = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
dagger-rust = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
cuddle-ci = { git = "https://git.front.kjuulh.io/kjuulh/dagger-components", branch = "main" }
async-trait = "0.1.77"
cuddle-clusters.workspace = true
async-trait = "0.1.80"

View File

@ -1,51 +1,121 @@
use std::sync::Arc;
use std::collections::HashMap;
use std::path::PathBuf;
use async_trait::async_trait;
use cuddle_ci::cuddle_file::CuddleFile;
use cuddle_ci::cuddle_please::CuddlePlease;
use cuddle_ci::cuddle_releaser::CuddleReleaser;
use cuddle_ci::rust_service::architecture::{Architecture, Os};
use cuddle_ci::rust_service::RustService;
use cuddle_ci::rust_service::{extensions::*, RustServiceContext};
use cuddle_ci::{Context, CuddleCI, MainAction, PullRequestAction};
use tokio::sync::Mutex;
use cuddle_clusters::catalog::cluster_vars::ClusterVars;
use cuddle_clusters::catalog::crdb_database::CockroachDB;
use cuddle_clusters::catalog::cuddle_vars::CuddleVars;
use cuddle_clusters::catalog::ingress::Ingress;
use cuddle_clusters::catalog::vault_secret::VaultSecret;
use cuddle_clusters::releaser::Releaser;
use cuddle_clusters::IntoComponent;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
tracing_subscriber::fmt::init();
dagger_sdk::connect(|client| async move {
let cuddle_file = CuddleFile::from_cuddle_file().await?;
let service = RustService::from(client.clone())
let service = &RustService::from(client.clone())
.with_cuddle_file(&cuddle_file)
.with_arch(Architecture::Amd64)
.with_os(Os::Linux)
.with_apt(&["libssl-dev", "libz-dev", "libpq-dev", "protobuf-compiler"])
.with_apt_release(&["libssl-dev", "libz-dev", "libpq-dev"])
.with_apt_ca_certificates()
.with_crates(["crates/*"])
.with_workspace_crates()
.await
.with_mold("2.3.3")
.with_bin_name(cuddle_file.vars.service)
.with_deployment(false)
.to_owned();
let service = Arc::new(Mutex::new(service));
let render = &RustServiceRender {
service: cuddle_file.vars.service,
//registry: "http://127.0.0.1:7900".into(),
//registry: "http://10.0.11.19:7900".into(),
registry: "https://releaser.i.kjuulh.io:443".into(),
};
let deployment = &CuddleReleaser::new(client.clone()).await?;
let render = Arc::new(Mutex::new(RustServiceRender::default()));
let mut ci = CuddleCI::default();
let deployment = Arc::new(Mutex::new(CuddleReleaser::new(client).await?));
CuddleCI::default()
.with_pull_request(service.clone())
//.with_pull_request(render.clone())
ci.with_pull_request(service)
.with_pull_request(render)
//.with_pull_request(deployment.clone())
.with_main(service.clone())
.with_main(render.clone())
.with_main(deployment.clone())
.execute(std::env::args())
.with_main(service)
.with_main(render)
.with_main(deployment);
if cuddle_file.please.is_some() {
ci.with_main(&CuddlePlease::new(client.clone()));
}
ci.execute(std::env::args()).await?;
Ok(())
})
.await?;
Ok(())
}
#[derive(Default)]
struct RustServiceRender {}
#[derive(Default, Clone)]
struct RustServiceRender {
service: String,
registry: String,
}
impl RustServiceRender {
async fn render_templates(&self, image_tag: &str) -> eyre::Result<()> {
let mut releaser = Releaser::default();
releaser
.with_service(&self.service)
.with_registry(&self.registry);
match cuddle_clusters::process_opts(
vec![
CuddleVars::new(&std::env::current_dir()?)
.await
.map_err(|e| eyre::anyhow!("failed to get cuddle vars: {}", e.to_string()))?
.into_component(),
ClusterVars::default().into_component(),
VaultSecret::default().into_component(),
CockroachDB::new(&std::env::current_dir()?)
.await
.map_err(|e| eyre::anyhow!("failed to get cuddle vars: {}", e.to_string()))?
.into_component(),
Ingress::new(&std::env::current_dir()?)
.await
.map_err(|e| eyre::anyhow!("failed to get cuddle vars: {}", e.to_string()))?
.into_component(),
],
cuddle_clusters::process::ProcessOpts {
path: std::env::current_dir()?,
output: PathBuf::from(".cuddle/tmp/cuddle-clusters"),
variables: HashMap::from([("image_tag".into(), image_tag.into())]),
},
Some(releaser),
)
.await
.map_err(|e| eyre::anyhow!("failed to process templates: {}", e.to_string()))
{
Ok(_) => {}
Err(e) => {
tracing::error!("failed to process templates: {}", e);
}
}
Ok(())
}
}
#[async_trait]
impl MainAction for RustServiceRender {
@ -54,13 +124,15 @@ impl MainAction for RustServiceRender {
.get_image_tag()?
.ok_or(eyre::anyhow!("failed to find image_tag"))?;
cuddle_ci::cuddle_x::well_known::render(vec![
"--cluster",
"clank-prod",
"--image_tag",
&image_tag,
])
.await?;
self.render_templates(&image_tag).await?;
// cuddle_ci::cuddle_x::well_known::render(vec![
// "--cluster",
// "clank-prod",
// "--image_tag",
// &image_tag,
// ])
// .await?;
Ok(())
}
@ -73,13 +145,7 @@ impl PullRequestAction for RustServiceRender {
.get_image_tag()?
.ok_or(eyre::anyhow!("failed to find image_tag"))?;
cuddle_ci::cuddle_x::well_known::render(vec![
"--cluster",
"clank-dev",
"--image_tag",
&image_tag,
])
.await?;
self.render_templates(&image_tag).await?;
Ok(())
}

View File

View File

@ -10,6 +10,13 @@ vars:
clank-prod:
replicas: "3"
namespace: prod
config:
something: something
secrets:
something.else: something
cuddle/clusters:
dev:
scripts:
render:

View File

@ -0,0 +1,13 @@
{%- set cluster_namespace = vars.cluster_vars.namespace -%}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ vars.cuddle_vars.service }}-config
namespace: {{ cluster_namespace }}
data:
{%- if (vars.cluster_vars.env | items | length) > 0 %}
{%- for (name, value) in vars.cluster_vars.env | dictsort %}
{{name | upper | replace(".", "_") | replace("-", "_") }}: {{value}}
{%- endfor %}
{%- endif %}

View File

@ -0,0 +1,68 @@
{%- set service_name = vars.cuddle_vars.service -%}
{%- set cluster_name = vars.cluster_vars.name -%}
{%- set cluster_namespace = vars.cluster_vars.namespace -%}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: {{ service_name }}
cluster: {{ cluster_name }}
name: {{ service_name }}
namespace: {{ cluster_namespace }}
spec:
replicas: 3
selector:
matchLabels:
app: {{ service_name }}
cluster: {{ cluster_name }}
template:
metadata:
labels:
app: {{ service_name }}
cluster: {{ cluster_name }}
spec:
containers:
- args:
- serve
command:
- {{ service_name }}
image: kasperhermansen/{{ service_name }}:{{ vars.user_vars.image_tag }}
name: {{ service_name }}
envFrom:
- configMapRef:
name: {{service_name}}-config
{%- if vars.cuddle_crdb.has_values %}
- configMapRef:
name: {{ vars.cuddle_crdb.file_name(service_name) }}
{%- endif %}
{%- if vars.vault_secret.has_values or vars.cuddle_crdb.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_crdb.has_values %}
- name: {{vars.cuddle_crdb.env }}
valueFrom:
secretKeyRef:
name: {{ vars.cuddle_crdb.file_name(service_name) }}
key: {{ vars.cuddle_crdb.env }}
{%- endif %}
#}
{%- endif %}
ports:
- containerPort: 3000
name: external-http
- containerPort: 3001
name: internal-http
- containerPort: 4000
name: external-grpc
- containerPort: 4001
name: internal-grpc

View File

@ -0,0 +1,42 @@
{%- set service_name = vars.cuddle_vars.service -%}
{%- set cluster_name = vars.cluster_vars.name -%}
{%- set cluster_namespace = vars.cluster_vars.namespace -%}
apiVersion: v1
kind: Service
metadata:
name: "{{ service_name }}"
namespace: {{ cluster_namespace }}
spec:
selector:
app: {{ service_name }}
cluster: {{ cluster_name }}
type: LoadBalancer
ports:
- name: external-http
port: 3000
targetPort: 3000
- name: internal-http
port: 3001
targetPort: 3001
---
apiVersion: v1
kind: Service
metadata:
name: "{{ service_name }}-grpc"
namespace: {{ cluster_namespace }}
annotations:
traefik.ingress.kubernetes.io/service.serversscheme: h2c
spec:
selector:
app: {{ service_name }}
cluster: {{ cluster_name }}
type: LoadBalancer
ports:
- name: external-grpc
port: 4000
targetPort: 4000
- name: internal-grpc
port: 4001
targetPort: 4001

View File

@ -0,0 +1,134 @@
kind: pipeline
name: cuddle-rust-service-plan
type: docker
steps:
- name: load_secret
image: debian:buster-slim
volumes:
- name: ssh
path: /root/.ssh/
environment:
SSH_KEY:
from_secret: gitea_id_ed25519
commands:
- mkdir -p $HOME/.ssh/
- echo "$SSH_KEY" | base64 -d > $HOME/.ssh/id_ed25519
- chmod -R 600 ~/.ssh
- |
cat >$HOME/.ssh/config <<EOL
Host git.front.kjuulh.io
IdentityFile $HOME/.ssh/id_ed25519
IdentitiesOnly yes
UserKnownHostsFile=/dev/null
StrictHostKeyChecking no
EOL
- chmod 700 ~/.ssh/config
- name: build pr
image: kasperhermansen/{{bin_name}}:{{image_tag}}
volumes:
- name: ssh
path: /root/.ssh/
commands:
- eval `ssh-agent`
- ssh-add
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username="$DOCKER_USERNAME" docker.io
- export CLUSTER=clank-dev
- cuddle --version
- {{ bin_name }} pr
environment:
DAGGER_CLOUD_TOKEN:
from_secret: dagger_cloud_token
DRONE_HOST: "https://ci.i.kjuulh.io"
DRONE_USER: "kjuulh"
DRONE_TOKEN:
from_secret: drone_token
REGISTRY_CACHE_USERNAME:
from_secret: registry_cache_username
REGISTRY_CACHE_PASSWORD:
from_secret: registry_cache_password
REGISTRY_CACHE_TOKEN:
from_secret: registry_cache_token
REGISTRY_CACHE_url:
from_secret: registry_cache_url
DOCKER_BUILDKIT: 1
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
CUDDLE_SECRETS_PROVIDER: 1password
CUDDLE_ONE_PASSWORD_DOT_ENV: ".env.ci"
CUDDLE_SSH_AGENT: "true"
GIT_PASSWORD:
from_secret: git_password
CI_PREFIX: "/mnt/ci/ci"
DOCKER_HOST: "tcp://192.168.1.155:2376"
CUDDLE_PLEASE_TOKEN:
from_secret: cuddle_please_token
OP_SERVICE_ACCOUNT_TOKEN:
from_secret: op_service_account_token
when:
event:
- pull_request
depends_on:
- "load_secret"
- name: build main
image: kasperhermansen/{{bin_name}}:{{image_tag}}
volumes:
- name: ssh
path: /root/.ssh/
commands:
- eval `ssh-agent`
- ssh-add
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username="$DOCKER_USERNAME" docker.io
- export CLUSTER=clank-prod
- cuddle --version
- {{ bin_name }} main
environment:
DAGGER_CLOUD_TOKEN:
from_secret: dagger_cloud_token
DRONE_HOST: "https://ci.i.kjuulh.io"
DRONE_USER: "kjuulh"
DRONE_TOKEN:
from_secret: drone_token
REGISTRY_CACHE_USERNAME:
from_secret: registry_cache_username
REGISTRY_CACHE_PASSWORD:
from_secret: registry_cache_password
REGISTRY_CACHE_TOKEN:
from_secret: registry_cache_token
REGISTRY_CACHE_url:
from_secret: registry_cache_url
DOCKER_BUILDKIT: 1
DOCKER_PASSWORD:
from_secret: docker_password
DOCKER_USERNAME:
from_secret: docker_username
CUDDLE_SECRETS_PROVIDER: 1password
CUDDLE_ONE_PASSWORD_DOT_ENV: ".env.ci"
CUDDLE_SSH_AGENT: "true"
GIT_PASSWORD:
from_secret: git_password
CI_PREFIX: "/mnt/ci/ci"
DOCKER_HOST: "tcp://192.168.1.155:2376"
CUDDLE_PLEASE_TOKEN:
from_secret: cuddle_please_token
OP_SERVICE_ACCOUNT_TOKEN:
from_secret: op_service_account_token
when:
event:
- push
branch:
- main
- master
exclude:
- pull_request
depends_on:
- "load_secret"
volumes:
- name: ssh
temp: {}

View File

@ -16,5 +16,7 @@ spec:
name: external_http
- containerPort: 3001
name: internal_http
- containerPort: 3002
- containerPort: 4000
name: external_grpc
- containerPort: 4001
name: internal_grpc

View File

@ -1,3 +1,5 @@
{% set_global cluster_vars = filter_by_prefix(prefix=["clusters", cluster]) %}
apiVersion: apps/v1
kind: Deployment
metadata:
@ -20,3 +22,18 @@ spec:
name: internal-http
- containerPort: 3002
name: internal-grpc
{% if cluster_vars.config or cluster_vars.secrets %}
env:
{% for secret in cluster_vars.secrets %}
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: my-secret
key: username
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: my-secret
key: password
{% endfor %}
{% endif %}

View File

@ -1,4 +1,3 @@
{% set_global cluster_vars = filter_by_prefix(prefix=["clusters", cluster]) %}
apiVersion: kustomize.config.k8s.io/v1beta1