-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevspace.yaml
More file actions
223 lines (214 loc) · 6.69 KB
/
devspace.yaml
File metadata and controls
223 lines (214 loc) · 6.69 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
version: v2beta1
vars:
CHAT_NAMESPACE: platform
functions:
disable_argocd_sync: |-
if kubectl get application chat -n argocd >/dev/null 2>&1; then
echo "Disabling ArgoCD auto-sync for chat..."
kubectl patch application chat -n argocd \
--type merge \
-p '{"spec":{"syncPolicy":{"automated":null}}}'
echo "ArgoCD auto-sync disabled."
else
echo "WARNING: ArgoCD Application 'chat' not found in argocd namespace."
fi
restore_argocd_sync: &restore_argocd_sync |-
if kubectl get application chat -n argocd >/dev/null 2>&1; then
echo "Re-enabling ArgoCD auto-sync for chat..."
kubectl patch application chat -n argocd \
--type merge \
-p '{"spec":{"syncPolicy":{"automated":{"prune":true,"selfHeal":true}}}}'
echo "ArgoCD auto-sync restored."
fi
patch_deployment: |-
echo "Patching chat deployment for DevSpace..."
kubectl patch deployment chat -n ${CHAT_NAMESPACE} --type strategic --patch "$(cat <<'EOF'
spec:
template:
spec:
securityContext:
runAsUser: 1000
fsGroup: 1000
initContainers: []
volumes:
- name: data
emptyDir: {}
containers:
- name: chat
image: ghcr.io/agynio/devcontainer-go:1
workingDir: /opt/app/data
command:
- sh
- -c
- |
set -eu
elapsed=0
while [ ! -f /opt/app/data/go.mod ]; do
sleep 1; elapsed=$((elapsed + 1))
[ "$elapsed" -ge 120 ] && { echo "ERROR: sync timeout" >&2; exit 1; }
done
exec /opt/app/data/scripts/devspace-startup.sh
volumeMounts:
- name: data
mountPath: /opt/app/data
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
)"
wait_healthy: |-
echo "Waiting for chat to be healthy on :50051..."
healthy=false
attempts=0
while [ "$attempts" -lt 60 ]; do
if exec_container --label-selector=app.kubernetes.io/name=chat -n ${CHAT_NAMESPACE} -- bash -c 'nc -z localhost 50051 >/dev/null 2>&1 || (echo > /dev/tcp/localhost/50051) >/dev/null 2>&1'; then
healthy=true
break
fi
attempts=$((attempts + 1))
sleep 2
done
if [ "$healthy" = true ]; then
echo "Chat is healthy on :50051."
else
echo "WARNING: Chat did not become healthy on :50051 within 120s."
fi
deployments:
chat-e2e:
namespace: ${CHAT_NAMESPACE}
helm:
chart:
name: component-chart
repo: https://charts.devspace.sh
values:
containers:
- image: ghcr.io/agynio/devcontainer-go:1
command: ["sleep", "infinity"]
env:
- name: CHAT_ADDRESS
value: "chat.${CHAT_NAMESPACE}:50051"
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: "1"
memory: 2Gi
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
readOnlyRootFilesystem: false
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefault
securityContext:
runAsUser: 1000
fsGroup: 1000
pipelines:
dev:
flags:
- name: no-logs
short: n
description: "Disable container log streaming"
run: |-
disable_argocd_sync
patch_deployment
if [ "$(get_flag "no-logs")" == "true" ]; then
start_dev --disable-pod-replace chat --set containers.chat.logs.enabled=false
else
start_dev --disable-pod-replace chat
fi
setup:
run: |-
disable_argocd_sync
trap 'restore_argocd_sync' EXIT
patch_deployment
wait_healthy
restore_argocd_sync
trap - EXIT
e2e:
run: |-
create_deployments chat-e2e
trap 'stop_dev chat-e2e; purge_deployments chat-e2e' EXIT
start_dev chat-e2e --disable-pod-replace
echo "Waiting for source files to sync..."
sleep 5
echo "Generating protobuf types..."
exec_container --label-selector=app.kubernetes.io/name=devspace-app,app.kubernetes.io/component=chat-e2e -n ${CHAT_NAMESPACE} -- \
bash -c 'cd /opt/app/data && buf generate buf.build/agynio/api --path agynio/api/chat/v1 --path agynio/api/threads/v1 --path agynio/api/runners/v1 --path agynio/api/runner/v1 --path agynio/api/identity/v1'
echo "Running e2e tests..."
exec_container --label-selector=app.kubernetes.io/name=devspace-app,app.kubernetes.io/component=chat-e2e -n ${CHAT_NAMESPACE} -- \
bash -c 'cd /opt/app/data && go test -v -count=1 ./test/e2e/...'
echo "Cleaning up test runner pod..."
stop_dev chat-e2e
purge_deployments chat-e2e
trap - EXIT
hooks:
- name: restore-argocd-auto-sync
events:
- after:dev:chat
command: sh
args:
- -c
- *restore_argocd_sync
dev:
chat:
namespace: ${CHAT_NAMESPACE}
labelSelector:
app.kubernetes.io/name: chat
app.kubernetes.io/instance: chat
containers:
chat:
container: chat
sync:
- path: ./:/opt/app/data
excludePaths:
- .git/
- /gen/
- .devspace/
uploadExcludePaths:
- .git/
- /gen/
downloadExcludePaths:
- .git/
- /gen/
logs:
enabled: true
lastLines: 200
ports:
- port: "50051"
chat-e2e:
namespace: ${CHAT_NAMESPACE}
labelSelector:
app.kubernetes.io/name: devspace-app
app.kubernetes.io/component: chat-e2e
sync:
- path: ./:/opt/app/data
noWatch: true
excludePaths:
- .git/
- /gen/
- .devspace/
uploadExcludePaths:
- .git/
- /gen/
downloadExcludePaths:
- .git/
- /gen/