Skip to content

Commit c8cb469

Browse files
authored
fix: migration and dev-env setup (#75)
1 parent 11b57cd commit c8cb469

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

templates/.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ jobs:
241241
pushd kubernetes/migration
242242
kubectl -n $NAMESPACE delete configmap $MIGRATION_NAME || echo "no migration configmap existing for deletion"
243243
if [ `ls ${SQL_DIR}/*.sql 2>/dev/null | wc -l` -gt 0 ] ; then
244-
kubectl -n $NAMESPACE create configmap $MIGRATION_NAME --from-file ${SQL_DIR}/*.sql
244+
kubectl -n $NAMESPACE create configmap $MIGRATION_NAME $(ls ${SQL_DIR}/*.sql | xargs printf '--from-file %s ')
245245
else
246246
kubectl -n $NAMESPACE create configmap $MIGRATION_NAME
247247
fi

templates/.github/actions/db-migration/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
if [ `ls ${SQL_DIR}/*.sql 2>/dev/null | wc -l` -gt 0 ] ; then
2424
pushd kubernetes/migration
2525
kubectl -n $NAMESPACE delete configmap $MIGRATION_NAME || echo "no migration configmap existing for deletion"
26-
kubectl -n $NAMESPACE create configmap $MIGRATION_NAME --from-file ${SQL_DIR}/*.sql
26+
kubectl -n $NAMESPACE create configmap $MIGRATION_NAME $(ls ${SQL_DIR}/*.sql | xargs printf '--from-file %s ')
2727
2828
kubectl -n $NAMESPACE create -f job.yml
2929
if ! kubectl -n $NAMESPACE wait --for=condition=complete --timeout=180s job/$MIGRATION_NAME ; then
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Backend public endpoint
2+
# pattern: http://<proxy>/status/*
3+
# In example this is serves the infoPanel data, and the status endpoints that don't require user auth
4+
apiVersion: oathkeeper.ory.sh/v1alpha1
5+
kind: Rule
6+
metadata:
7+
name: public-backend-endpoints
8+
spec:
9+
match:
10+
url: http://<% index .Params `stagingBackendSubdomain` %><% index .Params `stagingHostRoot` %>/<(status|webhook)\/.*>
11+
---
12+
## Backend User-restricted endpoint
13+
# pattern: http://<proxy>/<not `status`/`.ory/kratos`>, everything else should be authenticated
14+
# In example this is serves the /userInfo endpoint returning the user-session's info (user_id / email)
15+
# Note the authenticators is `cookie_session`,
16+
# oathkeeper will verify the validity of session then pass along user-id/email in the Request Header
17+
# these can be configured via infra's `oathkeeper-values.yml`
18+
apiVersion: oathkeeper.ory.sh/v1alpha1
19+
kind: Rule
20+
metadata:
21+
name: authenticated-backend-endpoints
22+
spec:
23+
match:
24+
url: http://<% index .Params `stagingBackendSubdomain` %><% index .Params `stagingHostRoot` %>/<(?!(status|webhook|\.ory\/kratos)).*>

templates/kubernetes/overlays/dev/ingress.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ metadata:
1010
ingress.kubernetes.io/ssl-redirect: "true"
1111
cert-manager.io/cluster-issuer: clusterissuer-letsencrypt-production
1212
# CORS
13-
nginx.ingress.kubernetes.io/enable-cors: "true"
1413
## to support both frontend origin and 'localhost', need 'configuration-snippet' implementation here, because 'cors-allow-origin' field doesn't support multiple originss yet.
1514
nginx.ingress.kubernetes.io/configuration-snippet: |
1615
if ($http_origin ~* "^https?://((?:<% index .Params `stagingFrontendSubdomain` %><% index .Params `stagingHostRoot` %>)|(?:localhost))") {
@@ -22,13 +21,15 @@ metadata:
2221
2322
if ($cors = "true") {
2423
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
24+
add_header 'Access-Control-Allow-Credentials' 'true';
2525
add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, PATCH, OPTIONS' always;
2626
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always;
2727
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
2828
}
2929
3030
if ($cors = "trueoptions") {
3131
add_header 'Access-Control-Allow-Origin' "$http_origin";
32+
add_header 'Access-Control-Allow-Credentials' 'true';
3233
add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, PATCH, OPTIONS';
3334
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
3435
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';

templates/kubernetes/overlays/dev/kustomization.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ kind: Kustomization
33

44
patchesStrategicMerge:
55
- deployment.yml
6+
<%if eq (index .Params `userAuth`) "yes" %>- auth.yml
7+
<% end %>
68

79
resources:
810
- ../../base

templates/start-dev-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ MIGRATION_NAME=${PROJECT_NAME}-migration
105105
SQL_DIR="${PWD}/database/migration"
106106
## launch migration job
107107
(cd kubernetes/migration && \
108-
kubectl --context ${CLUSTER_CONTEXT} -n ${DEV_NAMESPACE} create configmap ${MIGRATION_NAME} --from-file ${SQL_DIR}/*.sql || error_exit "Failed to apply kubernetes migration configmap" && \
108+
kubectl --context ${CLUSTER_CONTEXT} -n ${DEV_NAMESPACE} create configmap ${MIGRATION_NAME} $(ls ${SQL_DIR}/*.sql | xargs printf '\-\-from\-file %s ') || error_exit "Failed to apply kubernetes migration configmap" && \
109109
cat job.yml | \
110110
sed "s|/${DATABASE_NAME}|/${DEV_DATABASE_NAME}|g" | \
111111
kubectl --context ${CLUSTER_CONTEXT} -n ${DEV_NAMESPACE} create -f - ) || error_exit "Failed to apply kubernetes migration"

0 commit comments

Comments
 (0)