From bd1ce97779cf1e90262aafc570c1a84594f617d6 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:55:20 +0100 Subject: [PATCH] just: use resourcegen for simple deployment Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- justfile | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 784010b8c6..622e9430da 100644 --- a/justfile +++ b/justfile @@ -25,7 +25,7 @@ default_deploy_target := "simple" workspace_dir := "workspace" # Generate policies, apply Kubernetes manifests. -deploy target=default_deploy_target cli=default_cli: (generate target cli) apply +deploy target=default_deploy_target cli=default_cli: (generate target cli) (apply target) # Generate policies, update manifest. generate target=default_deploy_target cli=default_cli: @@ -33,7 +33,14 @@ generate target=default_deploy_target cli=default_cli: set -euo pipefail mkdir -p ./{{ workspace_dir }} rm -rf ./{{ workspace_dir }}/* - cp -R ./deployments/{{ target }} ./{{ workspace_dir }}/deployment + case {{ target }} in + "simple") + nix shell .#nunki --command resourcegen {{ target }} ./{{ workspace_dir }}/deployment/deployment.yml + ;; + *) + cp -R ./deployments/{{ target }} ./{{ workspace_dir }}/deployment + ;; + esac echo "{{ target }}${namespace_suffix-}" > ./{{ workspace_dir }}/just.namespace nix run .#scripts.patch-nunki-image-hashes -- ./{{ workspace_dir }}/deployment nix run .#kypatch images -- ./{{ workspace_dir }}/deployment \ @@ -51,8 +58,16 @@ generate target=default_deploy_target cli=default_cli: echo "generate $duration" >> ./{{ workspace_dir }}/just.perf # Apply Kubernetes manifests from /deployment -apply: - kubectl apply -f ./{{ workspace_dir }}/deployment/ns.yml +apply target=default_deploy_target: + #!/usr/bin/env bash + case {{ target }} in + "simple") + : + ;; + *) + kubectl apply -f ./{{ workspace_dir }}/deployment/ns.yml + ;; + esac kubectl apply -f ./{{ workspace_dir }}/deployment # Delete Kubernetes manifests. @@ -63,6 +78,10 @@ undeploy: echo "No workspace directory found, nothing to undeploy." exit 0 fi + if [[ ! -f ./{{ workspace_dir }}/just.namespace ]]; then + echo "No namespace file found, nothing to undeploy." + exit 0 + fi ns=$(cat ./{{ workspace_dir }}/just.namespace) if kubectl get ns $ns 2> /dev/null; then kubectl delete -f ./{{ workspace_dir }}/deployment