Package org.mockserver.webhook
Class SidecarPatchBuilder
java.lang.Object
org.mockserver.webhook.SidecarPatchBuilder
Builds a RFC 6902 JSON Patch that injects the MockServer sidecar container
and iptables-REDIRECT init container into a Kubernetes Pod spec.
The patch is designed for use in a MutatingAdmissionWebhook response. It adds:
- An init container that sets up iptables REDIRECT rules with UID-based loop-avoidance (the same pattern used in the Helm chart's sidecar.iptables)
- A MockServer sidecar container with transparent proxy enabled
- An idempotency marker annotation to prevent double-injection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.node.ArrayNodebuildPatch(com.fasterxml.jackson.databind.JsonNode podSpec) Builds a JSON Patch (RFC 6902) array to inject the MockServer sidecar and iptables init container into the given pod.booleanshouldInject(com.fasterxml.jackson.databind.JsonNode podSpec) Determines whether the given pod should be injected with the MockServer sidecar.
-
Constructor Details
-
SidecarPatchBuilder
-
-
Method Details
-
shouldInject
public boolean shouldInject(com.fasterxml.jackson.databind.JsonNode podSpec) Determines whether the given pod should be injected with the MockServer sidecar.- Parameters:
podSpec- the pod object from the admission review (the full pod, not just spec)- Returns:
- true if the pod opts in via annotation and has not already been injected
-
buildPatch
public com.fasterxml.jackson.databind.node.ArrayNode buildPatch(com.fasterxml.jackson.databind.JsonNode podSpec) Builds a JSON Patch (RFC 6902) array to inject the MockServer sidecar and iptables init container into the given pod.- Parameters:
podSpec- the pod object from the admission review- Returns:
- a JSON Patch array node
-