searxng/manifests/bin/deploy.sh
2024-05-15 23:37:43 +02:00

48 lines
1.1 KiB
Bash
Executable File

#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply -f \
<(envsubst "$(env | xargs printf '$%s ')" < "manifests/$f")
done
}
function kcreatesec() {
kubectl create secret generic --save-config --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kcreatecm() {
kubectl create configmap --dry-run=client -oyaml "$@" | kubectl apply -f-
}
function kgseckey() {
local sec="$1"; shift
local key="$1"; shift
kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d
}
function kgcmkey() {
local cm="$1"; shift
local key="$1"; shift
kubectl get configmap "$cm" -o jsonpath="{.data.$key}"
}
kcreatesec searxng-secrets \
--from-literal=SEARXNG_SECRET="$(kgseckey searxng-secrets SEARXNG_SECRET || openssl rand -hex 32)"
(cd config
cmd=(kcreatecm searxng)
for f in *; do
cmd+=("--from-file=$f=<(envsubst \"\$(env | xargs printf '$%s ')\" < $f)")
done
eval "${cmd[*]}"
)
kapply common/redis.yaml common/app.yaml
kubectl rollout restart deployment app