devzone 0.48.2 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/agent-pod-egress.sh +36 -0
- package/.devcontainer/agent-pod-manifest.sh +5 -2
- package/.devcontainer/devzone +1 -1
- package/README.md +10 -0
- package/charts/devzone-workspace/templates/egress-networkpolicy.yaml +37 -0
- package/charts/devzone-workspace/templates/egress-proxy.yaml +102 -0
- package/charts/devzone-workspace/values.yaml +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Egress proxy helpers for the ephemeral session pod (#220).
|
|
3
|
+
# Sourced by agent-pod-manifest.sh. bash 3.2 compatible ; shellcheck -x clean.
|
|
4
|
+
|
|
5
|
+
agent_pod_egress_mode() {
|
|
6
|
+
kubectl get service -l app.kubernetes.io/component=egress-proxy \
|
|
7
|
+
-o jsonpath='{.items[0].metadata.labels.devzone\.io/egress-mode}' 2>/dev/null || true
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
agent_pod_egress_manifest_lines() {
|
|
11
|
+
local mode="$1"
|
|
12
|
+
[ -n "$mode" ] || return 0
|
|
13
|
+
printf '%s\n' " - name: HTTP_PROXY"
|
|
14
|
+
printf '%s\n' " value: \"http://egress-proxy:3128\""
|
|
15
|
+
printf '%s\n' " - name: HTTPS_PROXY"
|
|
16
|
+
printf '%s\n' " value: \"http://egress-proxy:3128\""
|
|
17
|
+
printf '%s\n' " - name: NO_PROXY"
|
|
18
|
+
printf '%s\n' " value: \"localhost,127.0.0.1,.svc,.cluster.local\""
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
agent_pod_egress_init_lines() {
|
|
22
|
+
local mode="$1" ws_image="$2"
|
|
23
|
+
[ "$mode" = "strict" ] || return 0
|
|
24
|
+
printf '%s\n' " initContainers:"
|
|
25
|
+
printf '%s\n' " - name: wait-egress-restriction"
|
|
26
|
+
printf '%s\n' " image: ${ws_image}"
|
|
27
|
+
printf '%s\n' " command: [\"/bin/bash\", \"-lc\"]"
|
|
28
|
+
printf '%s\n' " args:"
|
|
29
|
+
printf '%s\n' " - 'i=0; while [ \$i -lt 20 ]; do if ! curl --noproxy \"*\" -m 3 -sS https://opencode.ai >/dev/null 2>&1; then exit 0; fi; i=\$((i+1)); sleep 1; done; echo \"egress restriction never became effective: session refused\" >&2; exit 1'"
|
|
30
|
+
printf '%s\n' " securityContext:"
|
|
31
|
+
printf '%s\n' " runAsUser: 1000"
|
|
32
|
+
printf '%s\n' " runAsGroup: 1000"
|
|
33
|
+
printf '%s\n' " allowPrivilegeEscalation: false"
|
|
34
|
+
printf '%s\n' " capabilities:"
|
|
35
|
+
printf '%s\n' " drop: [\"ALL\"]"
|
|
36
|
+
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
# Manifest and validation helpers for the ephemeral session pod (#222).
|
|
3
3
|
# Sourced by agent-pod.sh.
|
|
4
4
|
# bash 3.2 compatible ; shellcheck -x clean.
|
|
5
|
+
# shellcheck disable=SC1091
|
|
6
|
+
. "$(dirname "${BASH_SOURCE[0]}")/agent-pod-egress.sh"
|
|
5
7
|
|
|
6
8
|
# --- Defaults ---
|
|
7
9
|
|
|
@@ -147,7 +149,7 @@ agent_pod_build_manifest() {
|
|
|
147
149
|
ticket_block=" devzone.io/agent-ticket: \"${AGENT_POD_TICKET}\""
|
|
148
150
|
fi
|
|
149
151
|
|
|
150
|
-
manifest_file="$(mktemp "${TMPDIR:-/tmp}/devzone-agent-pod-manifest.XXXXXX.yaml")"
|
|
152
|
+
manifest_file="$(mktemp "${TMPDIR:-/tmp}/devzone-agent-pod-manifest.XXXXXX.yaml")"; egress_mode="$(agent_pod_egress_mode)"
|
|
151
153
|
|
|
152
154
|
{
|
|
153
155
|
printf '%s\n' "apiVersion: v1"
|
|
@@ -160,6 +162,7 @@ agent_pod_build_manifest() {
|
|
|
160
162
|
printf '%s\n' "$ticket_block"
|
|
161
163
|
fi
|
|
162
164
|
printf '%s\n' "spec:"
|
|
165
|
+
agent_pod_egress_init_lines "$egress_mode" "$ws_image"
|
|
163
166
|
printf '%s\n' " restartPolicy: Never"
|
|
164
167
|
printf '%s\n' " activeDeadlineSeconds: ${DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS}"
|
|
165
168
|
printf '%s\n' " automountServiceAccountToken: false"
|
|
@@ -191,7 +194,7 @@ agent_pod_build_manifest() {
|
|
|
191
194
|
printf '%s\n' " - name: DEVZONE_WORKSPACE"
|
|
192
195
|
printf '%s\n' " value: \"kubernetes\""
|
|
193
196
|
printf '%s\n' " - name: DEVZONE_RACINE"
|
|
194
|
-
printf '%s\n' " value: \"/workspaces/projets\""
|
|
197
|
+
printf '%s\n' " value: \"/workspaces/projets\""; agent_pod_egress_manifest_lines "$egress_mode"
|
|
195
198
|
printf '%s\n' " resources:"
|
|
196
199
|
printf '%s\n' " limits:"
|
|
197
200
|
printf '%s\n' " cpu: ${DEVZONE_AGENT_POD_CPU_LIMIT}"
|
package/.devcontainer/devzone
CHANGED
package/README.md
CHANGED
|
@@ -444,3 +444,13 @@ Cette commande retire seulement la commande `devzone` de ta machine ; elle ne su
|
|
|
444
444
|
|
|
445
445
|
devzone est un logiciel libre, distribué sous la [GNU General Public License version 3](https://github.com/SimBienvenueHoulBoumi/devzone/blob/main/LICENSE).
|
|
446
446
|
|
|
447
|
+
|
|
448
|
+
### Mandataire de sortie des sessions d’agent (désactivé par défaut)
|
|
449
|
+
|
|
450
|
+
Limite le réseau sortant des sessions lancées avec `devzone agent --pod` via un mandataire HTTP(S) (Squid) dans le namespace du workspace. Tout est désactivé par défaut : sans activation, le rendu du chart et le manifeste des pods de session restent identiques.
|
|
451
|
+
|
|
452
|
+
- **Modes** : `observation` (le mandataire accepte tout et journalise, aucune coupure, pour construire la liste) ; `strict` (seule la liste de domaines est autorisée, et une NetworkPolicy limite la sortie des pods de session au mandataire et au DNS).
|
|
453
|
+
- **Activer** (Helm) : `egressProxy.enabled=true` et `egressProxy.mode=observation` ou `strict` (liste : `egressProxy.allowedDomains`, par défaut `.opencode.ai`, `.npmjs.org`, `.github.com`).
|
|
454
|
+
- **Lire les contacts** : `kubectl logs deploy/devzone-workspace-egress-proxy -c access-log -n <namespace>`.
|
|
455
|
+
- **Garde (strict)** : une fenêtre de 1 à 2 s existe au démarrage avant que la restriction soit programmée ; un conteneur d’initialisation attend que l’accès direct soit fermé (20 essais, 1 s) et refuse la session si la restriction ne devient jamais effective.
|
|
456
|
+
- **Limites** : le workspace lui-même reste ouvert ; seules les sessions `devzone agent --pod` sont filtrées ; les outils qui ignorent `HTTPS_PROXY` sont bloqués en mode strict.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{{- if and .Values.egressProxy.enabled (eq .Values.egressProxy.mode "strict") -}}
|
|
2
|
+
apiVersion: networking.k8s.io/v1
|
|
3
|
+
kind: NetworkPolicy
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ include "devzone-workspace.fullname" . }}-egress-strict
|
|
6
|
+
namespace: {{ .Release.Namespace }}
|
|
7
|
+
labels:
|
|
8
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
9
|
+
app.kubernetes.io/part-of: devzone
|
|
10
|
+
app.kubernetes.io/managed-by: devzone
|
|
11
|
+
app.kubernetes.io/component: egress-proxy
|
|
12
|
+
spec:
|
|
13
|
+
podSelector:
|
|
14
|
+
matchExpressions:
|
|
15
|
+
- key: devzone.io/agent-session
|
|
16
|
+
operator: Exists
|
|
17
|
+
policyTypes:
|
|
18
|
+
- Egress
|
|
19
|
+
egress:
|
|
20
|
+
- to:
|
|
21
|
+
- podSelector:
|
|
22
|
+
matchLabels:
|
|
23
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
24
|
+
app.kubernetes.io/component: egress-proxy
|
|
25
|
+
ports:
|
|
26
|
+
- protocol: TCP
|
|
27
|
+
port: 3128
|
|
28
|
+
- to:
|
|
29
|
+
- namespaceSelector:
|
|
30
|
+
matchLabels:
|
|
31
|
+
kubernetes.io/metadata.name: kube-system
|
|
32
|
+
ports:
|
|
33
|
+
- protocol: UDP
|
|
34
|
+
port: 53
|
|
35
|
+
- protocol: TCP
|
|
36
|
+
port: 53
|
|
37
|
+
{{- end -}}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{{- if .Values.egressProxy.enabled -}}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: ConfigMap
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
|
|
6
|
+
namespace: {{ .Release.Namespace }}
|
|
7
|
+
labels:
|
|
8
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
9
|
+
app.kubernetes.io/part-of: devzone
|
|
10
|
+
app.kubernetes.io/managed-by: devzone
|
|
11
|
+
app.kubernetes.io/component: egress-proxy
|
|
12
|
+
data:
|
|
13
|
+
squid.conf: |
|
|
14
|
+
http_port 3128
|
|
15
|
+
max_filedescriptors 1024
|
|
16
|
+
cache deny all
|
|
17
|
+
access_log daemon:/var/log/squid/access.log
|
|
18
|
+
pid_filename /tmp/squid.pid
|
|
19
|
+
{{- if eq .Values.egressProxy.mode "strict" }}
|
|
20
|
+
{{- range .Values.egressProxy.allowedDomains }}
|
|
21
|
+
acl allowed dstdomain {{ . }}
|
|
22
|
+
{{- end }}
|
|
23
|
+
acl SSL_ports port 443
|
|
24
|
+
acl CONNECT method CONNECT
|
|
25
|
+
http_access allow CONNECT SSL_ports allowed
|
|
26
|
+
http_access allow allowed
|
|
27
|
+
http_access deny all
|
|
28
|
+
{{- else }}
|
|
29
|
+
http_access allow all
|
|
30
|
+
{{- end }}
|
|
31
|
+
---
|
|
32
|
+
apiVersion: apps/v1
|
|
33
|
+
kind: Deployment
|
|
34
|
+
metadata:
|
|
35
|
+
name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
|
|
36
|
+
namespace: {{ .Release.Namespace }}
|
|
37
|
+
labels:
|
|
38
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
39
|
+
app.kubernetes.io/part-of: devzone
|
|
40
|
+
app.kubernetes.io/managed-by: devzone
|
|
41
|
+
app.kubernetes.io/component: egress-proxy
|
|
42
|
+
spec:
|
|
43
|
+
replicas: 1
|
|
44
|
+
selector:
|
|
45
|
+
matchLabels:
|
|
46
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
47
|
+
app.kubernetes.io/component: egress-proxy
|
|
48
|
+
template:
|
|
49
|
+
metadata:
|
|
50
|
+
labels:
|
|
51
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
52
|
+
app.kubernetes.io/part-of: devzone
|
|
53
|
+
app.kubernetes.io/managed-by: devzone
|
|
54
|
+
app.kubernetes.io/component: egress-proxy
|
|
55
|
+
spec:
|
|
56
|
+
volumes:
|
|
57
|
+
- name: config
|
|
58
|
+
configMap:
|
|
59
|
+
name: {{ include "devzone-workspace.fullname" . }}-egress-proxy
|
|
60
|
+
- name: logs
|
|
61
|
+
emptyDir: {}
|
|
62
|
+
containers:
|
|
63
|
+
- name: squid
|
|
64
|
+
image: {{ .Values.egressProxy.image }}
|
|
65
|
+
ports:
|
|
66
|
+
- name: proxy
|
|
67
|
+
containerPort: 3128
|
|
68
|
+
volumeMounts:
|
|
69
|
+
- name: config
|
|
70
|
+
mountPath: /etc/squid/squid.conf
|
|
71
|
+
subPath: squid.conf
|
|
72
|
+
- name: logs
|
|
73
|
+
mountPath: /var/log/squid
|
|
74
|
+
resources:
|
|
75
|
+
{{- toYaml .Values.egressProxy.resources | nindent 12 }}
|
|
76
|
+
- name: access-log
|
|
77
|
+
image: busybox:1.36
|
|
78
|
+
command: ["sh", "-c", "tail -F /var/log/squid/access.log 2>/dev/null"]
|
|
79
|
+
volumeMounts:
|
|
80
|
+
- name: logs
|
|
81
|
+
mountPath: /var/log/squid
|
|
82
|
+
---
|
|
83
|
+
apiVersion: v1
|
|
84
|
+
kind: Service
|
|
85
|
+
metadata:
|
|
86
|
+
name: egress-proxy
|
|
87
|
+
namespace: {{ .Release.Namespace }}
|
|
88
|
+
labels:
|
|
89
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
90
|
+
app.kubernetes.io/part-of: devzone
|
|
91
|
+
app.kubernetes.io/managed-by: devzone
|
|
92
|
+
app.kubernetes.io/component: egress-proxy
|
|
93
|
+
devzone.io/egress-mode: {{ .Values.egressProxy.mode | quote }}
|
|
94
|
+
spec:
|
|
95
|
+
selector:
|
|
96
|
+
app.kubernetes.io/name: {{ include "devzone-workspace.name" . }}-egress-proxy
|
|
97
|
+
app.kubernetes.io/component: egress-proxy
|
|
98
|
+
ports:
|
|
99
|
+
- name: proxy
|
|
100
|
+
port: 3128
|
|
101
|
+
targetPort: 3128
|
|
102
|
+
{{- end -}}
|
|
@@ -97,3 +97,19 @@ networkPolicy:
|
|
|
97
97
|
# workstation needs the Internet (Maven, npm, Docker images). true limits the
|
|
98
98
|
# egress to the namespace and to DNS (kube-system). The egress allow list is #220.
|
|
99
99
|
restrictEgress: false
|
|
100
|
+
|
|
101
|
+
egressProxy:
|
|
102
|
+
enabled: false
|
|
103
|
+
mode: observation
|
|
104
|
+
allowedDomains:
|
|
105
|
+
- .opencode.ai
|
|
106
|
+
- .npmjs.org
|
|
107
|
+
- .github.com
|
|
108
|
+
image: ubuntu/squid@sha256:6a097f68bae708cedbabd6188d68c7e2e7a38cedd05a176e1cc0ba29e3bbe029
|
|
109
|
+
resources:
|
|
110
|
+
requests:
|
|
111
|
+
memory: 64Mi
|
|
112
|
+
cpu: 50m
|
|
113
|
+
limits:
|
|
114
|
+
memory: 256Mi
|
|
115
|
+
cpu: "1"
|