Skip to content

Commit

Permalink
refactor: cleanup old certificates for ingress that have tls-acme false
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Sep 14, 2023
1 parent a7a6ad3 commit b4744ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions legacy/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,15 @@ fi
# Get list of autogenerated routes
AUTOGENERATED_ROUTES=$(kubectl -n ${NAMESPACE} get ingress --sort-by='{.metadata.name}' -l "lagoon.sh/autogenerated=true" -o=go-template --template='{{range $indexItems, $ingress := .items}}{{if $indexItems}},{{end}}{{$tls := .spec.tls}}{{range $indexRule, $rule := .spec.rules}}{{if $indexRule}},{{end}}{{if $tls}}https://{{else}}http://{{end}}{{.host}}{{end}}{{end}}')

# remove any certificates for tls-acme false ingress to prevent reissuing attempts
TLS_FALSE_INGRESSES=$(kubectl -n ${NAMESPACE} get ingress -o json | jq -r '.items[] | select(.metadata.annotations["kubernetes.io/tls-acme"] == "false") | .metadata.name')
for TLS_FALSE_INGRESS in $TLS_FALSE_INGRESSES; do
if kubectl -n ${NAMESPACE} get certificate ${TLS_FALSE_INGRESS}-tls &> /dev/null; then
echo ">> Cleaning up certificate for ${TLS_FALSE_INGRESS} as tls-acme is set to false"
kubectl -n ${NAMESPACE} delete certificate ${TLS_FALSE_INGRESS}-tls
fi
done

yq3 write -i -- /kubectl-build-deploy/values.yaml 'route' "$ROUTE"
yq3 write -i -- /kubectl-build-deploy/values.yaml 'routes' "$ROUTES"
yq3 write -i -- /kubectl-build-deploy/values.yaml 'autogeneratedRoutes' "$AUTOGENERATED_ROUTES"
Expand Down

0 comments on commit b4744ce

Please sign in to comment.