searxng/manifests/bin/deploy.sh

49 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2024-05-01 08:36:34 +00:00
#!/bin/bash -e
set -o pipefail
function kapply() {
for f in "$@"; do
kubectl apply -f <(envsubst < "manifests/$f")
2024-05-01 08:36:34 +00:00
done
}; export -f kapply
2024-05-01 08:36:34 +00:00
function kcreatesec() {
kubectl create secret generic --dry-run=client -oyaml "$@" | kubectl replace -f-
}; export -f kcreatesec
2024-05-01 08:36:34 +00:00
function kcreatecm() {
kubectl create configmap --dry-run=client -oyaml "$@" | kubectl replace -f-
}; export -f kcreatecm
2024-05-01 08:36:34 +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 08:36:34 +00:00
function kgcmkey() {
local cm="$1"; shift
2024-05-01 08:36:34 +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 08:36:34 +00:00
2024-05-15 23:33:29 +00:00
kcreatesec searxng \
--from-literal=SEARXNG_SECRET="$(kgseckey searxng SEARXNG_SECRET || openssl rand -hex 32)"
2024-05-01 08:36:34 +00:00
opts=()
for f in config/*; do
opts+=(--from-file="$f")
done
kcreatecm searxng "${opts[@]}"
2024-05-01 08:36:34 +00:00
kapply common/valkey.yaml common/app.yaml
2024-05-01 08:36:34 +00:00
kubectl rollout restart deployment app