-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevspace.yaml
More file actions
95 lines (91 loc) · 3.77 KB
/
devspace.yaml
File metadata and controls
95 lines (91 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
version: v2beta1
vars:
APP_NAMESPACE: platform
functions:
disable_argocd_sync: |-
for app in console-app gateway; do
if kubectl get application "$app" -n argocd >/dev/null 2>&1; then
echo "Disabling ArgoCD auto-sync for $app..."
kubectl patch application "$app" -n argocd \
--type merge \
-p '{"spec":{"syncPolicy":{"automated":null}}}'
echo "ArgoCD auto-sync disabled for $app."
else
echo "WARNING: ArgoCD Application '$app' not found in argocd namespace."
fi
done
restore_argocd_sync: &restore_argocd_sync |-
for app in console-app gateway; do
if kubectl get application "$app" -n argocd >/dev/null 2>&1; then
echo "Re-enabling ArgoCD auto-sync for $app..."
kubectl patch application "$app" -n argocd \
--type merge \
-p '{"spec":{"syncPolicy":{"automated":{"prune":true,"selfHeal":true}}}}'
echo "ArgoCD auto-sync restored for $app."
else
echo "WARNING: ArgoCD Application '$app' not found."
fi
done
ensure_console_app_html_writable: |-
deploy=$(kubectl get deployment -n ${APP_NAMESPACE} -l app.kubernetes.io/name=console-app -o jsonpath='{.items[0].metadata.name}')
if [ -z "$deploy" ]; then
echo "WARNING: console-app deployment not found in ${APP_NAMESPACE} namespace."
return 0
fi
container=$(kubectl get deployment "$deploy" -n ${APP_NAMESPACE} -o jsonpath='{.spec.template.spec.containers[0].name}')
if [ -z "$container" ]; then
echo "WARNING: console-app container not found in ${APP_NAMESPACE} namespace."
return 0
fi
image=$(kubectl get deployment "$deploy" -n ${APP_NAMESPACE} -o jsonpath='{.spec.template.spec.containers[0].image}')
if [ -z "$image" ]; then
echo "WARNING: console-app container image not found in ${APP_NAMESPACE} namespace."
return 0
fi
kubectl patch deployment "$deploy" -n ${APP_NAMESPACE} \
--type strategic \
-p "{\"spec\":{\"template\":{\"spec\":{\"securityContext\":{\"fsGroup\":101},\"volumes\":[{\"name\":\"console-app-html\",\"emptyDir\":{}}],\"initContainers\":[{\"name\":\"console-app-html-init\",\"image\":\"${image}\",\"command\":[\"sh\",\"-c\",\"cp -R /usr/share/nginx/html/. /workdir/\"],\"securityContext\":{\"runAsUser\":101,\"runAsGroup\":101,\"runAsNonRoot\":true},\"volumeMounts\":[{\"name\":\"console-app-html\",\"mountPath\":\"/workdir\"}]}],\"containers\":[{\"name\":\"${container}\",\"securityContext\":{\"readOnlyRootFilesystem\":true,\"runAsUser\":101,\"runAsGroup\":101,\"runAsNonRoot\":true},\"volumeMounts\":[{\"name\":\"console-app-html\",\"mountPath\":\"/usr/share/nginx/html\"}]}]}}}}"
kubectl rollout status deployment "$deploy" -n ${APP_NAMESPACE} --timeout=600s
pipelines:
dev:
flags:
- name: watch
short: w
description: "Keep DevSpace running and stream logs"
run: |-
disable_argocd_sync
ensure_console_app_html_writable
if [ "$(get_flag "watch")" == "true" ]; then
start_dev --disable-pod-replace console-app
else
start_dev --disable-pod-replace console-app
echo "Dev environment ready. Stopping dev session."
stop_dev console-app
fi
hooks:
- name: restore-argocd-auto-sync
events:
- after:dev:console-app
command: bash
args:
- -c
- *restore_argocd_sync
dev:
console-app:
namespace: ${APP_NAMESPACE}
labelSelector:
app.kubernetes.io/name: console-app
app.kubernetes.io/instance: console-app
containers:
console-app:
sync:
- path: ./dist:/usr/share/nginx/html
excludePaths:
- .git/
- .devspace/
- node_modules/
logs:
enabled: true
lastLines: 200
ports:
- port: "3000"