58b04fe47e
Add TLS configuration for staging-shiny and staging-shiny-api hosts in the ingress resources. Create a new namespace for ingress-nginx to better organize resources. Update kustomization files to include new certificates and secrets. Streamline setup process with improved wait commands for pod readiness.
54 lines
2.4 KiB
Bash
Executable File
54 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
kind create cluster --config kind/kind.yaml --wait 10m
|
|
|
|
kubectl create secret docker-registry gitlab \
|
|
--docker-server=registry.gitlab.com \
|
|
--docker-username=gitlab \
|
|
--docker-password="${GITLAB_TOKEN}" \
|
|
--docker-email=gitlab@unbound.se
|
|
|
|
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gitlab"}]}'
|
|
|
|
kustomized="$(mktemp -t unboundnginx.yaml.XXXXXX)"
|
|
|
|
kubectl kustomize --enable-helm "k8s/nginx" >> "${kustomized}"
|
|
kubectl apply -f "${kustomized}" --server-side || true
|
|
|
|
printf "\nWait for pod app.kubernetes.io/component=controller to be created."
|
|
while :; do
|
|
sleep 2
|
|
[ -n "$(kubectl -n ingress-nginx get pod --selector=app.kubernetes.io/component=controller 2>/dev/null)" ] && printf "\n\n" && break
|
|
printf "."
|
|
done
|
|
|
|
echo "Wait for nginx to be available."
|
|
until [[ $(kubectl -n ingress-nginx get endpointslices -l 'kubernetes.io/service-name=ingress-nginx-controller' -o=jsonpath='{.items[*].endpoints[*].addresses[*]}') ]]; do sleep 5; done
|
|
|
|
kustomized="$(mktemp -t unboundinfra.yaml.XXXXXX)"
|
|
|
|
kubectl kustomize --enable-helm "k8s/infra" >> "${kustomized}"
|
|
kubectl apply -f "${kustomized}" --server-side || true
|
|
|
|
printf "\nWait for pod app.kubernetes.io/instance=cert-manager to be created."
|
|
while :; do
|
|
sleep 2
|
|
[ -n "$(kubectl -n cert-manager get pod --selector=app.kubernetes.io/instance=cert-manager 2>/dev/null)" ] && printf "\n\n" && break
|
|
printf "."
|
|
done
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=cert-manager --timeout 4m
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=cainjector --timeout 4m
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=webhook --timeout 4m
|
|
kubectl wait --for=condition=Ready pods --all -n external-secrets --timeout=5m
|
|
# Apply again to get any CRD's that wasn't applied earlier since the definitions wasn't available
|
|
kubectl apply -f "${kustomized}" --server-side || true
|
|
kubectl apply -k k8s/app --server-side
|
|
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=cert-manager --timeout 4m
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=cainjector --timeout 4m
|
|
kubectl wait --for=condition=Ready pods -n cert-manager -l app=webhook --timeout 4m
|
|
kubectl wait --for=condition=Ready pods --all -n external-secrets --timeout=5m
|
|
kubectl wait --for=condition=Ready pods --all -n default --timeout 3m
|