feat(k3s): add GoProxy egress check POC (#17)

## Summary

- add a Kubernetes GoProxy egress-check POC using `snail007/goproxy`
- keep the existing Squid egress-check workload
- check `http://example.com/` and `http://example.com/robots.txt` separately
- route the client HTTP traffic through the GoProxy sidecar

## Verification

- PyYAML manifest parsing and structural assertions: PASS
- local upstream integration through GoProxy: `/` returned `200`, `/robots.txt` returned `404`
- `git diff --check`: PASS

The Kubernetes cluster was not changed; rollout remains Flux-controlled after merge.

Reviewed-on: org1/swarm_connectivity_tester#17
Reviewed-by: admin <rudolfss13@gmail.com>
Co-authored-by: hermes <rudolfss13+hermes@gmail.com>
This commit is contained in:
2026-11-18 23:58:48 +01:00
committed by admin
parent 1389a3b84c
commit 1cdfe25d32
3 changed files with 178 additions and 1 deletions
+20 -1
View File
@@ -37,4 +37,23 @@ if HTTPS endpoints are required.
The client prints each URL and returned status to the container log, then repeats
both requests every 30 seconds. Change the two URL environment variables in the
Deployment before applying it.
Deployment before applying it.
## GoProxy egress check
`goproxy-egress-check.yaml` adds a second client/proxy POC in the
`egress-check-goproxy` namespace. The client checks the same two URLs every 30
seconds and uses the GoProxy sidecar at `127.0.0.1:3128` through the HTTP proxy
environment variables. The sidecar uses the multi-architecture `alpine:3.22`
image and an init container downloads the matching pinned GoProxy v15.3 binary
for `amd64` or `arm64` with SHA-256 verification.
The init container selects the release asset from the runtime architecture, so
this workload is not tied to a single Kubernetes node platform. GoProxy runs as
`proxy http -t tcp -p :3128`.
This variant uses explicit HTTP proxying rather than iptables interception. The
client has no proxy bypass list, and the proxy and client run in the same pod so
each request is sent to GoProxy before leaving the pod. GoProxy logs are
available with `kubectl logs -n egress-check-goproxy deploy/egress-check-goproxy
-c goproxy`; client results are available from the `client` container.
+157
View File
@@ -0,0 +1,157 @@
apiVersion: v1
kind: Namespace
metadata:
name: egress-check-goproxy
---
apiVersion: v1
kind: ConfigMap
metadata:
name: egress-check-goproxy-client
namespace: egress-check-goproxy
data:
client.py: |
import os
import time
from urllib.request import urlopen
urls = [os.environ["CHECK_URL_1"], os.environ["CHECK_URL_2"]]
timeout = float(os.environ.get("CHECK_TIMEOUT_SECONDS", "5"))
interval = float(os.environ.get("CHECK_INTERVAL_SECONDS", "30"))
while True:
for url in urls:
try:
with urlopen(url, timeout=timeout) as response:
print(url, response.status, flush=True)
except Exception as error:
print(url, error, flush=True)
time.sleep(interval)
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: egress-check-goproxy
namespace: egress-check-goproxy
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: egress-check-goproxy
template:
metadata:
labels:
app.kubernetes.io/name: egress-check-goproxy
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
initContainers:
- name: goproxy-download
image: alpine:3.22@sha256:49340b346798875b5592e5d420241f2f9cfba5f47e62ebb1446a1b34734e898f
command:
- /bin/sh
- -ec
- |
case "$(uname -m)" in
x86_64)
asset=proxy-linux-amd64.tar.gz
checksum=00be86a17b16c4444fe86766e715c86a95d9e8e7bdf1b0b902ecd8bcf9cd8a54
;;
aarch64)
asset=proxy-linux-arm64-v8.tar.gz
checksum=dd230006c13caee98d66233a2b5764ad8d3d58e6ea081cec61344ada8f55d015
;;
*)
echo "unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
wget -qO /tmp/proxy.tar.gz "https://github.com/snail007/goproxy/releases/download/v15.3/$asset"
echo "$checksum /tmp/proxy.tar.gz" | sha256sum -c -
tar -xzf /tmp/proxy.tar.gz -C /proxy
chmod 0555 /proxy/proxy
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- name: goproxy
mountPath: /proxy
- name: tmp
mountPath: /tmp
containers:
- name: client
image: python:3.12-alpine
command:
- python
- /app/client.py
env:
- name: CHECK_URL_1
value: http://example.com/
- name: CHECK_URL_2
value: http://example.com/robots.txt
- name: CHECK_INTERVAL_SECONDS
value: "30"
- name: CHECK_TIMEOUT_SECONDS
value: "5"
- name: http_proxy
value: http://127.0.0.1:3128
- name: https_proxy
value: http://127.0.0.1:3128
- name: HTTP_PROXY
value: http://127.0.0.1:3128
- name: HTTPS_PROXY
value: http://127.0.0.1:3128
- name: no_proxy
value: ""
- name: NO_PROXY
value: ""
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- name: client
mountPath: /app
readOnly: true
- name: goproxy
image: alpine:3.22@sha256:49340b346798875b5592e5d420241f2f9cfba5f47e62ebb1446a1b34734e898f
command:
- /proxy/proxy
- http
- -t
- tcp
- -p
- :3128
ports:
- name: proxy
containerPort: 3128
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
volumeMounts:
- name: goproxy
mountPath: /proxy
readOnly: true
- name: tmp
mountPath: /tmp
volumes:
- name: goproxy
emptyDir: {}
- name: client
configMap:
name: egress-check-goproxy-client
- name: tmp
emptyDir: {}
+1
View File
@@ -3,3 +3,4 @@ kind: Kustomization
resources:
- kubernetes.yaml
- egress-check.yaml
- goproxy-egress-check.yaml