mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-06 12:24:44 +00:00
ARTEX_RUNNER_BACKEND=kubernetes runs each task in a worker pod behind its own egress-proxy pod, created through the Kubernetes API (kube_client.go) with no container runtime socket. Per-task NetworkPolicies are applied before the pods and removed after them; the runner proves they are in effect before the first command, runs commands through pods/exec under env -i and artex-exec-wrap, and re-adopts task pods after a restart. Unit tests run against a fake API server; this commit keeps the tests for the review items, and the other unit tests and the live cluster test follow in a separate PR. Changes since the first review (502e42d): NetworkPolicies and scope: - Delete and failed setups delete the task's pods and wait until they are gone before removing the service and, last, the policies. If a pod cannot be deleted, the policies stay and the task stays tracked. Pods get a 1s grace, not 0: a zero grace removes the API object before the kubelet has stopped the containers. - applyPolicy replaces an existing policy only when it carries the runner's labels for the same task, and sends its resourceVersion. - ARTEX_KUBE_PROXY_DENIED_CIDRS adds to DefaultProxyDeniedCIDRs instead of replacing it. An empty DNSPodLabels map falls back to k8s-app=kube-dns. - No scope opens the cluster: ARTEX_KUBE_CLUSTER_CIDRS (pod, service and node CIDRs) plus metadata, loopback, link-local and the API server address form a never-reachable list. Each scope ipBlock gets them as except (a block inside one is dropped), the public rule excepts them, and the proxy refuses them through ARTEX_NEVER_CIDRS (new EgressPolicy.Never; Docker does not set it). Without ARTEX_KUBE_CLUSTER_CIDRS, scope CIDRs overlapping private, loopback or link-local ranges are dropped (logged), so the scope fails closed. - Isolation does not rely on an outside default-deny policy: every task pod has its own Ingress+Egress policy, adopted tasks get theirs applied again, and before the first command the runner checks that the worker reaches neither the API server nor a public address directly and that the proxy cannot reach the API server; setup fails otherwise. A scope change replaces the worker too, so the checks run in a worker no command has used. - The proxy pod uses ndots 1, so scope names are not first looked up as cluster names. Exec: - The worker base env comes after the request env in the env(1) argv. Refusing PATH, proxy and loader variables (LD_*, BASH_ENV, ...) in a request is a separate change to the shared ValidateEnv, which also covers the Docker backend. - Any exec error after the stream started (cancel, broken stream, read limit) kills the worker's processes, and so does a wrapper timeout (exit 124 after at least timeout_ms, the Docker rule). - Exec, Kill and Delete validate the task ID; Exec validates the request. Concurrency and cleanup: - Kill takes the task lock; stored tasks are copied, never changed in place. A Kill caused by an exec acts only on the worker pod UID that ran it; pod deletes carry a UID precondition. - An exec queued behind a Delete returns ErrNotFound instead of creating the task again. Per-task locks are reference counted and removed. - A failed setup removes what it created, found by label (a foreign object with the same name stays). Delete returns ErrNotFound only when no object of the task exists. - Recover adopts only pods named artex-w-/artex-p-<hash> and services with a real ClusterIP; adopted tasks are re-checked on first use. - Scope hash: full SHA-256; task object names use 128 bits. Config: http:// API servers are refused, the tasks and audit sub paths must not be ".", equal or nested, and NewKubernetesBackend documents what the deployment must provide (PID limits, restricted namespace, quotas, shared volume, shared Kill).
84 lines
3.8 KiB
AMPL
84 lines
3.8 KiB
AMPL
module github.com/Autumn-27/artex
|
|
|
|
go 1.26.11
|
|
|
|
require (
|
|
github.com/Autumn-27/norma v0.4.11
|
|
github.com/andybalholm/brotli v1.2.7
|
|
github.com/aws/aws-sdk-go-v2 v1.47.5
|
|
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.25
|
|
github.com/aws/aws-sdk-go-v2/config v1.33.13
|
|
github.com/aws/aws-sdk-go-v2/credentials v1.20.13
|
|
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.23.19
|
|
github.com/aws/aws-sdk-go-v2/service/s3 v1.114.6
|
|
github.com/golang-jwt/jwt/v5 v5.3.1
|
|
github.com/google/uuid v1.6.0
|
|
github.com/gorilla/websocket v1.5.4-0.20240701034025-d67f41855da4
|
|
github.com/jackc/pgx/v5 v5.10.0
|
|
github.com/klauspost/compress v1.20.2
|
|
github.com/lqqyt2423/go-mitmproxy v1.9.2
|
|
github.com/miekg/dns v1.1.72
|
|
github.com/projectdiscovery/dnsx v1.2.3
|
|
golang.org/x/crypto v0.59.0
|
|
golang.org/x/net v0.62.0
|
|
golang.org/x/text v0.44.0
|
|
modernc.org/sqlite v1.52.0
|
|
mvdan.cc/sh/v3 v3.14.1
|
|
)
|
|
|
|
require (
|
|
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
|
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.5 // indirect
|
|
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.8 // indirect
|
|
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.8 // indirect
|
|
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.8 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.23 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.9 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.8 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.8 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/signin v1.12.1 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/sso v1.39.1 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.1 // indirect
|
|
github.com/aws/aws-sdk-go-v2/service/sts v1.51.6 // indirect
|
|
github.com/aws/smithy-go v1.28.7 // indirect
|
|
github.com/aymerick/douceur v0.2.0 // indirect
|
|
github.com/creack/pty v1.1.24 // indirect
|
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
|
github.com/gaissmai/bart v0.26.0 // indirect
|
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
|
github.com/gorilla/css v1.0.1 // indirect
|
|
github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 // indirect
|
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
|
|
github.com/ncruces/go-strftime v1.0.0 // indirect
|
|
github.com/pkg/errors v0.9.1 // indirect
|
|
github.com/projectdiscovery/blackrock v0.0.1 // indirect
|
|
github.com/projectdiscovery/cdncheck v1.2.13 // indirect
|
|
github.com/projectdiscovery/retryabledns v1.0.111 // indirect
|
|
github.com/projectdiscovery/utils v0.7.3 // indirect
|
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
|
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
|
|
github.com/satori/go.uuid v1.2.0 // indirect
|
|
github.com/sirupsen/logrus v1.9.4 // indirect
|
|
github.com/tidwall/gjson v1.18.0 // indirect
|
|
github.com/tidwall/match v1.2.0 // indirect
|
|
github.com/tidwall/pretty v1.2.1 // indirect
|
|
github.com/weppos/publicsuffix-go v0.40.3-0.20250408071509-6074bbe7fd39 // indirect
|
|
go.uber.org/atomic v1.11.0 // indirect
|
|
go.uber.org/multierr v1.11.0 // indirect
|
|
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
|
|
golang.org/x/mod v0.42.0 // indirect
|
|
golang.org/x/sync v0.25.0 // indirect
|
|
golang.org/x/sys v0.50.0
|
|
golang.org/x/tools v0.52.0 // indirect
|
|
gopkg.in/yaml.v3 v3.0.1
|
|
modernc.org/libc v1.72.3 // indirect
|
|
modernc.org/mathutil v1.7.1 // indirect
|
|
modernc.org/memory v1.11.0 // indirect
|
|
)
|
|
|
|
replace github.com/Autumn-27/norma => github.com/BaaRai/Norma v0.4.13
|