Skip to content

Commit

Permalink
feat: setup of temporary dataapps URL redirector for CSAS migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kauf303 committed Sep 20, 2024
1 parent 6d6c127 commit fada878
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
14 changes: 14 additions & 0 deletions provisioning/apps-proxy/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ fi
# Constants
export NAMESPACE="apps-proxy"

# CSAS migration
export CSAS_MIGRATION_APPS_PROXY_REDIRECT_REPLICAS="${CSAS_MIGRATION_APPS_PROXY_REDIRECT_REPLICAS:=0}"
if [ "$CSAS_MIGRATION_APPS_PROXY_REDIRECT_REPLICAS" -gt 0 ]; then
export APP="nginx"
else
export APP="apps-proxy"
fi

# Common part of the deployment. Same for AWS/Azure/Local
./kubernetes/build.sh

Expand All @@ -45,3 +53,9 @@ kubectl apply -f ./kubernetes/deploy/proxy/config-map.yaml
kubectl apply -f ./kubernetes/deploy/proxy/pdb.yaml
kubectl apply -f ./kubernetes/deploy/proxy/network-policy.yaml
kubectl apply -f ./kubernetes/deploy/proxy/deployment.yaml

# CSAS migration Nginx-redir
if [ "$CSAS_MIGRATION_APPS_PROXY_REDIRECT_REPLICAS" -gt 0 ]; then
kubectl apply -f ./kubernetes/deploy/nginx-redir/cm.yaml
kubectl apply -f ./kubernetes/deploy/nginx-redir/deployment.yaml
fi
4 changes: 4 additions & 0 deletions provisioning/apps-proxy/kubernetes/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ envsubst < templates/proxy/pdb.yaml > deploy/proxy/pdb.yaml
envsubst < templates/proxy/network-policy.yaml > deploy/proxy/network-policy.yaml
envsubst < templates/proxy/deployment.yaml > deploy/proxy/deployment.yaml

# CSAS migration, without condition because it's trashed after build
envsubst < templates/nginx-redir/cm.yaml > deploy/nginx-redir/cm.yaml
envsubst < templates/nginx-redir/deployment.yaml > deploy/nginx-redir/deployment.yaml

# Remove resources requests/limits to fit all pods to the CI environment
REMOVE_RESOURCES_LIMITS="${REMOVE_RESOURCES_LIMITS:=false}"
if [[ "$REMOVE_RESOURCES_LIMITS" == "true" ]]; then
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ metadata:
name: apps-proxy
namespace: $NAMESPACE
labels:
app: apps-proxy
app: $APP
annotations:
service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
type: LoadBalancer
selector:
app: apps-proxy
app: $APP
ports:
- port: 80
targetPort: 8000
Expand Down
15 changes: 15 additions & 0 deletions provisioning/apps-proxy/kubernetes/templates/nginx-redir/cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
namespace: $NAMESPACE
data:
nginx.conf: |
server {
listen 8000;
server_name ~^(?<subdomain>.+)\.hub\.csas\.keboola\.cloud$;
location / {
return 302 https://$subdomain.hub.cs.keboola.cloud$request_uri;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: $NAMESPACE
labels:
app: nginx
spec:
replicas: $CSAS_MIGRATION_APPS_PROXY_REDIRECT_REPLICAS
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
volumeMounts:
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
ports:
- containerPort: 8000
volumes:
- name: nginx-config-volume
configMap:
name: nginx-config

0 comments on commit fada878

Please sign in to comment.