-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Package Kubenix script * Update changelog * Fix hardcoded kubeconfig * Expose generated manifest with Kubenix CLI derivation passthru
- Loading branch information
Showing
3 changed files
with
94 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -uo pipefail | ||
|
||
function _help() { | ||
echo " | ||
kubenix - Kubernetes management with Nix | ||
commands: | ||
"" - run diff, prompt for confirmation, then apply | ||
apply - create resources in target cluster | ||
diff - show a diff between configured and live resources | ||
render - print resource manifests to stdout | ||
options: | ||
-h --help - show this menu | ||
" | ||
} | ||
|
||
function _kubectl() { | ||
vals eval -fail-on-missing-key-in-map <$MANIFEST | kubectl $@ | ||
} | ||
|
||
# if no args given, add empty string | ||
[ $# -eq 0 ] && set -- "" | ||
|
||
# parse arguments | ||
while test $# -gt 0; do | ||
case "$1" in | ||
|
||
-h | --help) | ||
_help | ||
exit 0 | ||
;; | ||
|
||
"") | ||
_kubectl diff -f - --prune | ||
if [[ $? -eq 1 ]]; then | ||
read -p 'apply? [y/N]: ' response | ||
[[ $response == "y" ]] && _kubectl apply -f - --prune --all | ||
fi | ||
shift | ||
;; | ||
|
||
render) | ||
vals eval <$MANIFEST | ||
shift | ||
;; | ||
|
||
apply | diff) | ||
_kubectl $@ -f - --prune | ||
shift | ||
;; | ||
|
||
*) | ||
_kubectl $@ | ||
shift | ||
;; | ||
|
||
esac | ||
done |