Skip to content

Add custom resource definition for Cellar and bump dependencies #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
810 changes: 157 additions & 653 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ readme = "README.md"
keywords = ["kubernetes", "operator", "clevercloud", "openshift"]

[dependencies]
async-trait = "^0.1.87"
axum = { version = "^0.8.1", default-features = false, features = [
"http1",
"tokio",
Expand All @@ -25,8 +24,8 @@ axum = { version = "^0.8.1", default-features = false, features = [
] }
base64 = "^0.22.1"
chrono = { version = "^0.4.40", default-features = false }
clap = { version = "^4.5.32", features = ["derive"] }
clevercloud-sdk = { version = "^0.14.0", features = ["jsonschemas"] }
clap = { version = "^4.5.34", features = ["derive"] }
clevercloud-sdk = { version = "0.15.0", features = ["jsonschemas"] }
config = "^0.15.9"
futures = "^0.3.31"
hostname = "^0.4.0"
Expand All @@ -44,16 +43,16 @@ k8s-openapi = { version = "^0.24.0", default-features = false, features = [
"v1_30",
] }
mime = { version = "^0.3.17" }
paw = "^1.0.0"
prometheus = { version = "^0.13.4", optional = true }
paw = { version = "^1.0.0" }
prometheus = { version = "^0.14.0", optional = true }
schemars = { version = "^0.8.21", features = [
"chrono",
"indexmap1",
"uuid1",
"bytes",
"url",
] }
serde = { version = "1.0.219", features = ["derive"] }
serde = { version = "^1.0.219", features = ["derive"] }
serde_json = { version = "^1.0.140", features = [
"preserve_order",
"float_roundtrip",
Expand All @@ -63,7 +62,7 @@ tempfile = "^3.18.0"
toml = "^0.8.20"
thiserror = "^2.0.12"
tokio = { version = "^1.44.0", features = ["full"] }
tracing = "^0.1.41"
tracing = { version = "^0.1.41" }
tracing-subscriber = { version = "^0.3.19", default-features = false, features = [
"std",
"ansi",
Expand All @@ -73,7 +72,7 @@ tracing-subscriber = { version = "^0.3.19", default-features = false, features =
default = ["logging", "metrics", "tracing"]
logging = ["clevercloud-sdk/logging"]
metrics = ["clevercloud-sdk/metrics", "prometheus"]
tracing = ["clevercloud-sdk/tracing", "clevercloud-sdk/tokio"]
tracing = ["clevercloud-sdk/tracing"]

[profile.release]
lto = true
Expand Down
81 changes: 81 additions & 0 deletions deployments/kubernetes/v1.30.0/10-custom-resource-definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1079,3 +1079,84 @@ spec:
storage: true
subresources:
status: {}

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cellars.api.clever-cloud.com
spec:
group: api.clever-cloud.com
names:
categories: []
kind: Cellar
plural: cellars
shortNames: []
singular: cellar
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Organisation
jsonPath: .spec.organisation
name: organisation
type: string
- description: Addon
jsonPath: .status.addon
name: addon
type: string
- description: Region
jsonPath: .spec.instance.region
name: region
type: string
- description: Instance
jsonPath: .spec.instance.plan
name: instance
type: string
- description: Url
jsonPath: .status.url
name: url
type: string
name: v1
schema:
openAPIV3Schema:
description: Auto-generated derived type for Spec via `CustomResource`
properties:
spec:
properties:
instance:
properties:
plan:
type: string
region:
type: string
required:
- plan
- region
type: object
options:
default: {}
type: object
organisation:
type: string
required:
- instance
- organisation
type: object
status:
nullable: true
properties:
addon:
nullable: true
type: string
url:
nullable: true
type: string
type: object
required:
- spec
title: Cellar
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 2 additions & 0 deletions deployments/kubernetes/v1.30.0/20-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ rules:
- otoroshis/status
- azimutts
- azimutts/status
- cellars
- cellars/status
verbs:
- get
- list
Expand Down
97 changes: 97 additions & 0 deletions examples/kubernetes/23-cellar-addon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
apiVersion: api.clever-cloud.com/v1
kind: Cellar
metadata:
namespace: default
name: cellar
spec:
organisation: orga_<uuid v4>
instance:
region: par
plan: s
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: debian-cellar
name: debian-cellar
namespace: default
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: debian-cellar
namespace: default
spec:
minAvailable: 0
selector:
matchLabels:
app: debian-cellar
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: debian-cellar
namespace: default
spec:
podSelector:
matchLabels:
app: debian-cellar
policyTypes:
- Ingress
- Egress
ingress:
- {}
egress:
- {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: default
name: debian-cellar
labels:
app: debian-cellar
spec:
replicas: 1
selector:
matchLabels:
app: debian-cellar
template:
metadata:
labels:
app: debian-cellar
spec:
serviceAccountName: debian-cellar
automountServiceAccountToken: true
containers:
- image: debian:bullseye-slim
imagePullPolicy: Always
name: debian-cellar
command:
- "sleep"
- "3600"
env:
- name: CELLAR_ADDON_HOST
valueFrom:
secretKeyRef:
name: cellar-secrets
key: CELLAR_ADDON_HOST
- name: CELLAR_ADDON_KEY_ID
valueFrom:
secretKeyRef:
name: cellar-secrets
key: CELLAR_ADDON_KEY_ID
- name: CELLAR_ADDON_KEY_SECRET
valueFrom:
secretKeyRef:
name: cellar-secrets
key: CELLAR_ADDON_KEY_SECRET
resources:
requests:
memory: 64M
cpu: 100m
limits:
memory: 64M
cpu: 100m
2 changes: 0 additions & 2 deletions src/cmd/configmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use std::{collections::BTreeMap, sync::Arc};

use async_trait::async_trait;
use clap::Subcommand;
use k8s_openapi::api::core::v1;

Expand Down Expand Up @@ -36,7 +35,6 @@ pub enum ConfigMap {
},
}

#[async_trait]
impl Executor for ConfigMap {
type Error = ConfigMapError;

Expand Down
17 changes: 11 additions & 6 deletions src/cmd/crd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use std::{error::Error, str::FromStr, sync::Arc};

use async_trait::async_trait;
use clap::Subcommand;
use kube::CustomResourceExt;

Expand All @@ -14,9 +13,10 @@ use crate::{
svc::{
cfg::Configuration,
crd::{
azimutt::Azimutt, config_provider::ConfigProvider, elasticsearch::ElasticSearch,
keycloak::Keycloak, kv::KV, matomo::Matomo, metabase::Metabase, mongodb::MongoDb,
mysql::MySql, otoroshi::Otoroshi, postgresql::PostgreSql, pulsar::Pulsar, redis::Redis,
azimutt::Azimutt, cellar::Cellar, config_provider::ConfigProvider,
elasticsearch::ElasticSearch, keycloak::Keycloak, kv::KV, matomo::Matomo,
metabase::Metabase, mongodb::MongoDb, mysql::MySql, otoroshi::Otoroshi,
postgresql::PostgreSql, pulsar::Pulsar, redis::Redis,
},
},
};
Expand All @@ -39,6 +39,7 @@ pub enum CustomResource {
Matomo,
Otoroshi,
Azimutt,
Cellar,
}

impl FromStr for CustomResource {
Expand All @@ -60,10 +61,11 @@ impl FromStr for CustomResource {
"matomo" => Ok(Self::Matomo),
"otoroshi" => Ok(Self::Otoroshi),
"azimutt" => Ok(Self::Azimutt),
"cellar" => Ok(Self::Cellar),
_ => Err(format!(
"failed to parse '{s}', available options are: 'postgresql', 'redis', \
'mysql', 'mongodb, 'pulsar', 'config-server', 'elasticsearch', 'kv', \
'metabase', 'keycloak', 'matomo', 'otoroshi' and 'azimutt'"
'metabase', 'keycloak', 'matomo', 'otoroshi', 'azimutt' and 'cellar'"
)
.into()),
}
Expand Down Expand Up @@ -91,7 +93,6 @@ pub enum CustomResourceDefinition {
},
}

#[async_trait]
impl Executor for CustomResourceDefinition {
type Error = CustomResourceDefinitionError;

Expand Down Expand Up @@ -139,6 +140,8 @@ pub async fn view(
.map_err(CustomResourceDefinitionError::Serialize)?,
CustomResource::Azimutt => serde_yaml::to_string(&Azimutt::crd())
.map_err(CustomResourceDefinitionError::Serialize)?,
CustomResource::Cellar => serde_yaml::to_string(&Cellar::crd())
.map_err(CustomResourceDefinitionError::Serialize)?,
}]
} else {
vec![
Expand Down Expand Up @@ -167,6 +170,8 @@ pub async fn view(
.map_err(CustomResourceDefinitionError::Serialize)?,
serde_yaml::to_string(&Azimutt::crd())
.map_err(CustomResourceDefinitionError::Serialize)?,
serde_yaml::to_string(&Cellar::crd())
.map_err(CustomResourceDefinitionError::Serialize)?,
]
};

Expand Down
Loading
Loading