personal: ferretdb
Change-Id: I0a460e558f2ed068d8bd899b549b230a4f27f0ca
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1573
diff --git a/personal/noisersup/ferretdb.jsonnet b/personal/noisersup/ferretdb.jsonnet
new file mode 100644
index 0000000..8e3788f
--- /dev/null
+++ b/personal/noisersup/ferretdb.jsonnet
@@ -0,0 +1,63 @@
+// The simple deployment of FerretDB proxy to be a bit more fluent with hscloud.
+// - kubectl -n personal-noisersup create secret generic ferretdb --from-literal=pg_password=password --from-literal=secret_key=pg_password
+// - kubecfg update personal/noisersup/ferretdb.jsonnet
+// - nix run nixpkgs#mongosh "mongodb://username:password@185.236.240.50/ferretdb?authMechanism=PLAIN"
+local kube = import '../../kube/kube.libsonnet';
+local postgres = import '../../kube/postgres.libsonnet';
+
+{
+ local top = self,
+ local cfg = self.cfg,
+
+ cfg:: {
+ name: 'ferretdb',
+ image: 'ghcr.io/ferretdb/ferretdb:latest',
+ namespace: 'personal-noisersup',
+ },
+
+ ns: kube.Namespace(cfg.namespace),
+
+ deployment: top.ns.Contain(kube.Deployment(cfg.name)) {
+ spec+: {
+ replicas: 1,
+ template+: {
+ spec+: {
+ containers_: {
+ default: kube.Container(cfg.name) {
+ image: cfg.image,
+ ports_: {
+ http: { containerPort: 27017 },
+ },
+ env: [
+ { name: 'FERRETDB_POSTGRESQL_URL', value: 'postgres://postgres:5432/ferretdb' },
+ ],
+ },
+ },
+ },
+ },
+ },
+ },
+
+ postgres: postgres {
+ cfg+: {
+ namespace: cfg.namespace,
+ appName: 'ferretdb-postgres',
+ database: 'ferretdb',
+ username: 'username',
+ password: { secretKeyRef: { name: top.cfg.name, key: 'pg_password' } },
+
+ storageClassName: 'waw-hdd-redundant-3',
+ },
+ },
+
+ service: top.ns.Contain(kube.Service(cfg.name)) {
+ target_pod:: top.deployment.spec.template,
+ spec+: {
+ ports: [
+ { name: 'http', port: 27017, targetPort: 27017, protocol: 'TCP' },
+ ],
+ type: 'LoadBalancer',
+ externalTrafficPolicy: 'Local',
+ },
+ },
+}
\ No newline at end of file