mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
99 lines
3.4 KiB
Nix
99 lines
3.4 KiB
Nix
{ config, lib, pkgs, kubenix, helm, k8sVersion, ... }:
|
|
|
|
with lib;
|
|
with kubenix.lib;
|
|
with pkgs.dockerTools;
|
|
|
|
let
|
|
corev1 = config.kubernetes.api.resources.core.v1;
|
|
appsv1 = config.kubernetes.api.resources.apps.v1;
|
|
|
|
postgresql = pullImage {
|
|
imageName = "docker.io/bitnami/postgresql";
|
|
imageDigest = "sha256:ec16eb9ff2e7bf0669cfc52e595f17d9c52efd864c3f943f404d525dafaaaf96";
|
|
sha256 = "12jr8pzvj1qglrp7sh857a5mv4nda67hw9si6ah2bl6y1ff19l65";
|
|
finalImageName = "docker.io/bitnami/postgresql";
|
|
finalImageTag = "11.7.0-debian-10-r55";
|
|
};
|
|
|
|
postgresqlExporter = pullImage {
|
|
imageName = "docker.io/bitnami/postgres-exporter";
|
|
imageDigest = "sha256:373ba8ac1892291b4121591d1d933b7f9501ae45b9b8d570d7deb4900f91cfe9";
|
|
sha256 = "0icrqmlj8127jhmiy3vh419cv7hwnw19xdn89hxxyj2l6a1chryh";
|
|
finalImageName = "docker.io/bitnami/postgres-exporter";
|
|
finalImageTag = "0.9.0-debian-10-r43";
|
|
};
|
|
|
|
bitnamiShell = pullImage {
|
|
imageName = "docker.io/bitnami/bitnami-shell";
|
|
imageDigest = "sha256:58ba68e1f1d9a55c1234ae5b439bdcf0de1931e4aa1bac7bd0851b66de14fd97";
|
|
sha256 = "00lmphm3ds17apbmh2m2r7cz05jhp4dc3ynswrj0pbpq0azif4zn";
|
|
finalImageName = "docker.io/bitnami/bitnami-shell";
|
|
finalImageTag = "10";
|
|
};
|
|
in {
|
|
imports = [ kubenix.modules.test kubenix.modules.helm kubenix.modules.k8s ];
|
|
|
|
test = {
|
|
name = "helm-simple";
|
|
description = "Simple k8s testing wheter name, apiVersion and kind are preset";
|
|
assertions = [{
|
|
message = "should have generated resources";
|
|
assertion =
|
|
appsv1.StatefulSet ? "app-psql-postgresql-primary" &&
|
|
appsv1.StatefulSet ? "app-psql-postgresql-read" &&
|
|
corev1.Secret ? "app-psql-postgresql" &&
|
|
corev1.Service ? "app-psql-postgresql-headless" ;
|
|
} {
|
|
message = "should have values passed";
|
|
assertion = appsv1.StatefulSet.app-psql-postgresql-read.spec.replicas == 2;
|
|
} {
|
|
message = "should have namespace defined";
|
|
assertion =
|
|
appsv1.StatefulSet.app-psql-postgresql-primary.metadata.namespace == "test";
|
|
}];
|
|
testScript = ''
|
|
kube.wait_until_succeeds("docker load < ${postgresql}")
|
|
kube.wait_until_succeeds("docker load < ${postgresqlExporter}")
|
|
kube.wait_until_succeeds("docker load < ${bitnamiShell}")
|
|
kube.wait_until_succeeds("kubectl apply -f ${config.kubernetes.result}")
|
|
kube.wait_until_succeeds("PGPASSWORD=postgres ${pkgs.postgresql}/bin/psql -h app-psql-postgresql.test.svc.cluster.local -U postgres -l")
|
|
'';
|
|
};
|
|
|
|
kubernetes.version = k8sVersion;
|
|
|
|
kubernetes.resources.namespaces.test = {};
|
|
|
|
kubernetes.helm.instances.app-psql = {
|
|
namespace = "test";
|
|
chart = helm.fetch {
|
|
repo = "https://charts.bitnami.com/bitnami";
|
|
chart = "postgresql";
|
|
version = "10.3.8";
|
|
sha256 = "sha256-0hJ5pNIivpXeRal1DwJ2VSD3Yxtw2omOoIYGZKGtu9I=";
|
|
};
|
|
|
|
values = {
|
|
image = {
|
|
repository = "bitnami/postgresql";
|
|
tag = "11.11.0-debian-10-r71";
|
|
pullPolicy = "IfNotPresent";
|
|
};
|
|
volumePermissions.image = {
|
|
repository = "bitnami/bitnami-shell";
|
|
tag = "10";
|
|
pullPolicy = "IfNotPresent";
|
|
};
|
|
metrics.image = {
|
|
repository = "bitnami/postgres-exporter";
|
|
tag = "0.9.0-debian-10-r43";
|
|
pullPolicy = "IfNotPresent";
|
|
};
|
|
replication.enabled = true;
|
|
replication.slaveReplicas = 2;
|
|
postgresqlPassword = "postgres";
|
|
persistence.enabled = false;
|
|
};
|
|
};
|
|
}
|