Package org.mockserver.webhook
Class WebhookServer
java.lang.Object
org.mockserver.webhook.WebhookServer
Kubernetes MutatingAdmissionWebhook HTTPS server.
Starts an HTTPS server that:
POST /inject— handles AdmissionReview requests (delegates toAdmissionReviewHandler)GET /healthz— returns 200 for readiness/liveness probes
TLS cert + key are loaded from file paths (env-configurable). Sidecar injection config is read from environment variables so Helm values flow through.
-
Constructor Summary
ConstructorsConstructorDescriptionWebhookServer(InetSocketAddress bindAddress, SSLContext sslContext, SidecarInjectionConfig config) Creates a WebhookServer that binds to the given address using the provided SSLContext. -
Method Summary
Modifier and TypeMethodDescriptionstatic SSLContextbuildSslContext(Path certPath, Path keyPath) Builds an SSLContext from PEM-encoded certificate and private key files.intgetPort()Returns the port the server is listening on.static voidvoidstart()Starts the HTTPS server.voidstop(int delaySeconds) Stops the HTTPS server gracefully.
-
Constructor Details
-
WebhookServer
public WebhookServer(InetSocketAddress bindAddress, SSLContext sslContext, SidecarInjectionConfig config) throws IOException Creates a WebhookServer that binds to the given address using the provided SSLContext.- Parameters:
bindAddress- the address/port to bind tosslContext- the SSL context for HTTPSconfig- the sidecar injection configuration- Throws:
IOException- if the server cannot bind
-
-
Method Details
-
start
public void start()Starts the HTTPS server. -
stop
public void stop(int delaySeconds) Stops the HTTPS server gracefully.- Parameters:
delaySeconds- seconds to wait for in-flight requests
-
getPort
public int getPort()Returns the port the server is listening on. Useful for tests with ephemeral ports. -
buildSslContext
Builds an SSLContext from PEM-encoded certificate and private key files.- Parameters:
certPath- path to the PEM certificate file (may contain a chain)keyPath- path to the PEM private key file (PKCS#8)- Returns:
- a configured SSLContext
- Throws:
Exception
-
main
- Throws:
Exception
-