Skip to content

Commit 660976e

Browse files
committed
docs: add badges and update examples section
- Add CI, Go Report Card, GoDoc, and codecov badges - Update examples section with table listing both examples
1 parent bcfff6f commit 660976e

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# auto-cert-webhook
22

3+
[![Go](https://github.com/jimyag/auto-cert-admission/actions/workflows/check.yaml/badge.svg)](https://github.com/jimyag/auto-cert-admission/actions/workflows/check.yaml)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/jimyag/auto-cert-webhook)](https://goreportcard.com/report/github.com/jimyag/auto-cert-webhook)
5+
[![GoDoc](https://pkg.go.dev/badge/github.com/jimyag/auto-cert-webhook)](https://pkg.go.dev/github.com/jimyag/auto-cert-webhook)
6+
[![codecov](https://codecov.io/gh/jimyag/auto-cert-admission/branch/main/graph/badge.svg)](https://codecov.io/gh/jimyag/auto-cert-admission)
7+
38
A lightweight framework for building Kubernetes admission webhooks with automatic TLS certificate management.
49

510
## Features
@@ -148,7 +153,7 @@ webhooks:
148153
name: my-webhook
149154
namespace: default
150155
path: /mutate-pods
151-
port: 8443
156+
port: 443
152157
caBundle: "" # auto-populated by the framework
153158
rules:
154159
- operations: ["CREATE"]
@@ -179,12 +184,35 @@ rules:
179184
180185
## Environment Variables
181186
187+
All configuration options can be set via environment variables with the `ACW_` prefix. Configuration priority: **code > environment variables > defaults**.
188+
182189
| Variable | Description | Default |
183190
|----------|-------------|---------|
184-
| `POD_NAMESPACE` | Namespace for certificate secrets | Auto-detected from ServiceAccount |
191+
| `ACW_NAME` | Webhook name (required if not set in code) | - |
192+
| `ACW_NAMESPACE` | Namespace for webhook resources | Auto-detected |
193+
| `ACW_SERVICE_NAME` | Kubernetes service name | `<Name>` |
194+
| `ACW_PORT` | Webhook server port | `8443` |
195+
| `ACW_METRICS_ENABLED` | Enable metrics server | `true` |
196+
| `ACW_METRICS_PORT` | Metrics server port | `8080` |
197+
| `ACW_METRICS_PATH` | Metrics endpoint path | `/metrics` |
198+
| `ACW_HEALTHZ_PATH` | Health check endpoint path | `/healthz` |
199+
| `ACW_READYZ_PATH` | Readiness endpoint path | `/readyz` |
200+
| `ACW_CA_SECRET_NAME` | CA certificate secret name | `<Name>-ca` |
201+
| `ACW_CERT_SECRET_NAME` | Server certificate secret name | `<Name>-cert` |
202+
| `ACW_CA_BUNDLE_CONFIGMAP_NAME` | CA bundle configmap name | `<Name>-ca-bundle` |
203+
| `ACW_CA_VALIDITY` | CA certificate validity (e.g., `48h`) | `48h` |
204+
| `ACW_CA_REFRESH` | CA certificate refresh interval | `24h` |
205+
| `ACW_CERT_VALIDITY` | Server certificate validity | `24h` |
206+
| `ACW_CERT_REFRESH` | Server certificate refresh interval | `12h` |
207+
| `ACW_LEADER_ELECTION` | Enable leader election | `true` |
208+
| `ACW_LEADER_ELECTION_ID` | Leader election lease name | `<Name>-leader` |
209+
| `ACW_LEASE_DURATION` | Leader election lease duration | `30s` |
210+
| `ACW_RENEW_DEADLINE` | Leader election renew deadline | `10s` |
211+
| `ACW_RETRY_PERIOD` | Leader election retry period | `5s` |
212+
| `POD_NAMESPACE` | Namespace (backward compatibility) | Auto-detected |
185213
| `POD_NAME` | Pod identity for leader election | hostname |
186214

187-
The namespace is automatically detected from `/var/run/secrets/kubernetes.io/serviceaccount/namespace` (mounted by Kubernetes). You only need to set `POD_NAMESPACE` if running outside a Kubernetes cluster or without a ServiceAccount.
215+
The namespace is automatically detected from `/var/run/secrets/kubernetes.io/serviceaccount/namespace` (mounted by Kubernetes). You only need to set `ACW_NAMESPACE` or `POD_NAMESPACE` if running outside a Kubernetes cluster or without a ServiceAccount.
188216

189217
## Metrics
190218

@@ -211,6 +239,22 @@ groups:
211239
summary: "Webhook certificate expiring in less than 7 days"
212240
```
213241

242+
## Examples
243+
244+
Complete working examples with deployment manifests and test scripts:
245+
246+
| Example | Type | Description |
247+
|---------|------|-------------|
248+
| [pod-mutating](./examples/pod-mutating) | Mutating Webhook | Injects labels into pods automatically |
249+
| [pod-validating](./examples/pod-validating) | Validating Webhook | Enforces pod policies (labels, image tags, resource limits) |
250+
251+
Each example includes:
252+
- Complete Go implementation
253+
- Dockerfile for container builds
254+
- Makefile with `docker-build-push`, `deploy`, `undeploy`, and `test` targets
255+
- Kubernetes manifests (namespace, RBAC, deployment, service, webhook configuration)
256+
- Test script for validation
257+
214258
## License
215259

216260
Apache-2.0

0 commit comments

Comments
 (0)