Skip to content

Commit

Permalink
just: use resourcegen for simple deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Meyer <[email protected]>
  • Loading branch information
katexochen committed Mar 4, 2024
1 parent c87e688 commit bd1ce97
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,22 @@ 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:
#!/usr/bin/env bash
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 \
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit bd1ce97

Please sign in to comment.