element/manifests/bin/deploy.sh

42 lines
955 B
Bash
Raw Normal View History

2024-05-01 09:24:20 +00:00
#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply -f <(envsubst < "manifests/$f")
2024-05-01 09:24:20 +00:00
done
}; export -f kapply
2024-05-01 09:24:20 +00:00
function kcreatesec() {
kubectl create secret generic --dry-run=client -oyaml "$@" | kubectl replace -f-
}; export -f kcreatesec
2024-05-01 09:24:20 +00:00
function kcreatecm() {
kubectl create configmap --dry-run=client -oyaml "$@" | kubectl replace -f-
}; export -f kcreatecm
2024-05-01 09:24:20 +00:00
function kgseckey() {
local sec="$1"; shift
local key="$1"; shift
if ! kubectl get secret "$sec" -ojson | jq -re ".data.\"$key\" // empty" | base64 -d; then
return 1
fi
}; export -f kgseckey
2024-05-01 09:24:20 +00:00
function kgcmkey() {
local cm="$1"; shift
2024-05-01 09:24:20 +00:00
local key="$1"; shift
if ! kubectl get configmap "$cm" -ojson | jq -re ".data.\"$key\" // empty"; then
return 1
fi
}; export -f kgcmkey
2024-05-01 09:24:20 +00:00
kcreatecm element --from-file=config/config.json
2024-05-01 09:24:20 +00:00
kapply common/app.yaml
kubectl rollout restart deployment app