diff --git a/homelab-services/nimh-static/flake.nix b/homelab-services/nimh-static/flake.nix index 6780473..095048a 100644 --- a/homelab-services/nimh-static/flake.nix +++ b/homelab-services/nimh-static/flake.nix @@ -20,11 +20,6 @@ options.services.nimh-static = { enable = lib.mkEnableOption "serve nimh via k3s pod."; - credentialsFile = lib.mkOption { - type = lib.types.path; - description = "File containing service (k3s) secrets."; - }; - rootDir = lib.mkOption { type = lib.types.path; description = "Root of the static site"; @@ -58,15 +53,15 @@ serviceConfig = { Type = "oneshot"; ExecStart = '' + kubernetes_config=$(mktemp) + gomplate=${pkgs.gomplate}/bin/gomplate + gomplate --input-dir=./k3s --output-dir=$kubernetes_config kubectl=${pkgs.kubectl}/bin/kubectl - kubectl apply -k ./k3s - - + kubectl apply -k $out ''; User = "nimh"; Group = "nimh"; - EnvironmentFile = "${opts.credentialsFile}"; }; }; diff --git a/homelab-services/nimh-static/k3s/configmap.yaml b/homelab-services/nimh-static/k3s/configmap.yaml new file mode 100644 index 0000000..746d47f --- /dev/null +++ b/homelab-services/nimh-static/k3s/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nimh-static-files + namespace: nimh + +data: + index.html: | + {{ file.Read "../site/index.html" | strings.Indent 4}} diff --git a/homelab-services/nimh-static/k3s/deployment.yaml b/homelab-services/nimh-static/k3s/deployment.yaml new file mode 100644 index 0000000..a013017 --- /dev/null +++ b/homelab-services/nimh-static/k3s/deployment.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nimh-static + +spec: + replicas: 1 + + selector: + matchLabels: + app: nimh-static + template: + metadata: + labels: + app: nimh-static + spec: + containers: + - name: nginx + image: nginx:stable + + ports: + - containerPort: 80 + + volumeMounts: + - name: static-files + mountPath: /var/nimh-static/site + readOnly: true + volumes: + - name: static-files + configMap: + name: nimh-static-files diff --git a/homelab-services/nimh-static/k3s/kustomization.yaml b/homelab-services/nimh-static/k3s/kustomization.yaml new file mode 100644 index 0000000..7b387b5 --- /dev/null +++ b/homelab-services/nimh-static/k3s/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - configmap.yaml + - deployment.yaml + - service.yaml diff --git a/homelab-services/nimh-static/k3s/service.yaml b/homelab-services/nimh-static/k3s/service.yaml index 3a3ef37..cf75f39 100644 --- a/homelab-services/nimh-static/k3s/service.yaml +++ b/homelab-services/nimh-static/k3s/service.yaml @@ -4,4 +4,11 @@ metadata: name: nimh-static spec: selector: - app.hubernetes.io/name: proxy + app: nimh-static + + ports: + - port: 80 + targetPort: 80 + nodePort: 30080 + + type: NodePort diff --git a/homelab-services/nimh-static/index.html b/homelab-services/nimh-static/site/index.html similarity index 100% rename from homelab-services/nimh-static/index.html rename to homelab-services/nimh-static/site/index.html