32 lines
730 B
YAML
32 lines
730 B
YAML
apiVersion: policy.jspolicy.com/v1beta1
|
|
kind: JsPolicy
|
|
metadata:
|
|
name: inject-tailscale-proxy.tbrnt.ch
|
|
spec:
|
|
type: Mutating
|
|
operations: ["CREATE"]
|
|
resources: ["pods"]
|
|
scope: Namespaced
|
|
objectSelector:
|
|
matchLabels:
|
|
k8upjob: "true"
|
|
javascript: |
|
|
const httpProxy = {
|
|
name: "http_proxy",
|
|
value: "127.0.0.1:1055"
|
|
}
|
|
const httpsProxy = {
|
|
name: "https_proxy",
|
|
value: "127.0.0.1:1055"
|
|
}
|
|
|
|
request.object.spec.containers?.forEach(container => {
|
|
if (container.name.match(/^backup$/)) {
|
|
print("Found backup container, injecting env vars")
|
|
container.env.push(httpProxy)
|
|
container.env.push(httpsProxy)
|
|
}
|
|
});
|
|
|
|
mutate(request.object);
|