-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevspace.yaml
More file actions
136 lines (131 loc) · 4.32 KB
/
devspace.yaml
File metadata and controls
136 lines (131 loc) · 4.32 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
version: v2beta1
vars:
GATEWAY_NAMESPACE: platform
pipelines:
dev:
flags:
- name: watch
short: w
description: "Keep DevSpace running and stream logs"
run: |-
if kubectl get application gateway -n argocd >/dev/null 2>&1; then
echo "Disabling ArgoCD auto-sync for gateway..."
kubectl patch application gateway -n argocd \
--type merge \
-p '{"spec":{"syncPolicy":{"automated":null}}}'
echo "ArgoCD auto-sync disabled."
else
echo "WARNING: ArgoCD Application 'gateway' not found in argocd namespace."
fi
echo "Patching gateway deployment for DevSpace..."
kubectl patch deployment gateway-gateway -n ${GATEWAY_NAMESPACE} --type strategic --patch "$(cat <<'EOF'
spec:
template:
spec:
securityContext:
runAsUser: 1000
fsGroup: 1000
initContainers: []
volumes:
- name: data
emptyDir: {}
containers:
- name: gateway
image: ghcr.io/agynio/devcontainer-go:1.1.0
workingDir: /opt/app/data
command:
- sh
- -c
- |
set -eu
start=$(date +%s)
while [ ! -f /opt/app/data/go.mod ] \
|| [ ! -f /opt/app/data/go.sum ] \
|| [ ! -f /opt/app/data/.air.toml ] \
|| [ ! -f /opt/app/data/cmd/gateway/main.go ] \
|| [ ! -f /opt/app/data/internal/platform/config.go ]; do
sleep 1
elapsed=$(( $(date +%s) - start ))
[ "$elapsed" -ge 300 ] && { echo "ERROR: sync timeout waiting for source files" >&2; exit 1; }
done
exec /opt/app/data/scripts/devspace-startup.sh
volumeMounts:
- name: data
mountPath: /opt/app/data
livenessProbe: null
startupProbe: null
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: "2"
memory: 4Gi
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
EOF
)"
if [ "$(get_flag "watch")" == "true" ]; then
trap './scripts/argocd-restore.sh' EXIT
start_dev --disable-pod-replace gateway
else
start_dev --disable-pod-replace gateway
echo "Waiting for gateway to be healthy on :8080..."
healthy=false
for i in $(seq 1 300); do
if kubectl exec deployment/gateway-gateway -n ${GATEWAY_NAMESPACE} -c gateway -- bash -c 'nc -z localhost 8080 >/dev/null 2>&1 || (echo > /dev/tcp/localhost/8080) >/dev/null 2>&1' 2>/dev/null; then
echo "Gateway is healthy on :8080."
healthy=true
break
fi
sleep 2
done
if [ "$healthy" != "true" ]; then
echo "ERROR: Gateway did not become healthy within 600s" >&2
exit 1
fi
echo "Dev environment ready. Stopping dev session."
stop_dev gateway
fi
restore-argocd:
run: |-
./scripts/argocd-restore.sh
dev:
gateway:
namespace: ${GATEWAY_NAMESPACE}
labelSelector:
app.kubernetes.io/name: gateway
app.kubernetes.io/instance: gateway
containers:
gateway:
container: gateway
sync:
- path: ./:/opt/app/data
excludePaths:
- .git/
- /gen/
- dist/
- .devspace/
- gateway.log
- gateway.pid
uploadExcludePaths:
- .git/
- /gen/
- dist/
downloadExcludePaths:
- .git/
- /gen/
- dist/
logs:
enabled: true
lastLines: 200
ports:
- port: "8080"