Skip to content

Commit b519527

Browse files
committed
Refactor webhook docs locations
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
1 parent 5793b69 commit b519527

12 files changed

Lines changed: 312 additions & 261 deletions

File tree

docs/content/en/docs/4_tutorials_and_how-tos/working_with_crd_based_packagerevisions/creating-packages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ All operations in this guide can also be performed using the `porchctl` CLI with
170170

171171
## Summary
172172

173-
{{% alert title="Note" color="warning" %}}
174-
Validating admission webhooks for PackageRevision are not yet implemented. The operations below represent the intended usage patterns. The controller handles common mistakes defensively (e.g. blocking deletion of published packages via a finalizer), but some invalid states are not rejected at admission time.
173+
{{% alert title="Note" color="info" %}}
174+
PackageRevision and Repository resources are validated by admission webhooks running in the porch-controllers pod. These webhooks enforce lifecycle transitions, prevent invalid operations, and detect configuration conflicts at creation or update time. See [Webhook Validation Rules]({{% relref "/docs/6_configuration_and_deployments/configurations/components/porch-webhooks/validation-rules" %}}) for details.
175175
{{% /alert %}}
176176

177177
| Operation | How |

docs/content/en/docs/6_configuration_and_deployments/configurations/components/_index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ Configure each Porch component individually for optimal performance and security
1212
### [Porch Server]({{% relref "porch-server-config" %}})
1313
The main API server that handles package operations and Git repository interactions:
1414
- [Git Authentication]({{% relref "porch-server-config/git-authentication" %}}) - Repository authentication methods
15-
- [Cert Manager Webhooks]({{% relref "porch-server-config/cert-manager-webhooks" %}}) - Webhook certificate management
1615

1716
### [Porch Controllers]({{% relref "porch-controllers-config" %}})
18-
Manage the lifecycle of Repositories, PackageRevisions, PackageVariants, and PackageVariantSets.
17+
Manage the lifecycle of Repositories, PackageRevisions, PackageVariants, and PackageVariantSets:
18+
- [Webhooks]({{% relref "porch-webhooks" %}}) - Validation webhooks for PackageRevision and Repository resources
19+
- [Certificate Management]({{% relref "porch-webhooks/cert-manager-webhooks" %}}) - TLS certificate setup
20+
- [Validation Rules]({{% relref "porch-webhooks/validation-rules" %}}) - Detailed validation rules
1921

2022
### [Function Runner]({{% relref "function-runner-config" %}})
2123
Executes KRM functions in isolated containers:

docs/content/en/docs/6_configuration_and_deployments/configurations/components/porch-controllers-config.md renamed to docs/content/en/docs/6_configuration_and_deployments/configurations/components/porch-controllers-config/_index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 2
55
description: "Configure the Porch controllers component"
66
---
77

8-
The Porch controllers manage Repository synchronization, PackageVariants, and PackageVariantSets.
8+
The Porch controllers manage Repository synchronization, PackageVariants, PackageVariantSets, and PackageRevision validation via webhooks.
99

1010
## Enabling Controllers
1111

@@ -117,4 +117,12 @@ The PR Controller requires:
117117

118118
- **Reconcile concurrency**: Controls total parallel work. Source execution and lifecycle transitions are lightweight, so the bottleneck is usually rendering. A ratio of 2-3x reconciles to renders (e.g. 50 reconciles, 20 renders) works well for most clusters.
119119

120-
- **gRPC message size**: Increase this if packages contain large resource files (over 6MB total). This is uncommon for typical KRM packages.
120+
- **gRPC message size**: Increase this if packages contain large resource files (over 6MB total). This is uncommon for typical KRM packages.
121+
122+
## Webhook Configuration
123+
124+
Both the PackageRevision and Repository webhooks run in the porch-controllers pod and provide admission-time validation. Unlike controllers which reconcile state continuously, webhooks validate operations at creation or update time and deny invalid requests immediately. This fail-closed approach prevents invalid configurations from being stored in Kubernetes etcd.
125+
126+
For webhook TLS certificate setup and management, see [Webhook Certificate Management](../porch-webhooks/cert-manager-webhooks.md).
127+
128+
For details on webhook validation rules, see [Webhook Validation Rules](../porch-webhooks/validation-rules.md).

docs/content/en/docs/6_configuration_and_deployments/configurations/components/porch-server-config/_index.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ env:
7070

7171
For detailed Git repository authentication configuration, see [Git Authentication]({{% relref "git-authentication" %}}) subsection.
7272

73-
## Webhook Certificate Management
74-
75-
For cert-manager integration with Porch admission webhooks (which validate PackageRevision and Repository resources), see [Webhook Certificate Management]({{% relref "cert-manager-webhooks" %}}) subsection.
76-
77-
{{% alert title="Note" color="primary" %}}
78-
Webhooks run in the porch-controllers pod, not the API server. They provide real-time validation at admission time.
79-
{{% /alert %}}
80-
8173
## Distributed Tracing
8274

8375
For tracing and metrics configuration, see [OpenTelemetry Configuration]({{% relref "/docs/6_configuration_and_deployments/configurations/opentelemetry" %}}).

docs/content/en/docs/6_configuration_and_deployments/configurations/components/porch-server-config/cert-manager-webhooks.md

Lines changed: 0 additions & 247 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Porch Webhooks"
3+
type: docs
4+
weight: 3
5+
description: "Overview of Porch validating webhooks"
6+
---
7+
8+
Porch uses Kubernetes [validating webhooks](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook) to enforce validation at admission time. These webhooks run as part of the porch-controllers pod and intercept Create, Update, and Delete operations before they reach etcd. They provide fail-closed guarantees—if webhooks become unavailable, operations on those resources are rejected.
9+
10+
## Overview
11+
12+
Porch runs two webhooks on port 9443:
13+
14+
**PackageRevision Webhook** (`porch.kpt.dev/v1alpha2`) validates CREATE, UPDATE, DELETE on PackageRevision resources. It enforces lifecycle transitions, immutable fields, render race prevention, and upstream reference protection. The endpoint is `/validate-porch-kpt-dev-v1alpha2-packagerevision`.
15+
16+
**Repository Webhook** (`config.porch.kpt.dev/v1alpha1`) validates CREATE, UPDATE on Repository resources. It enforces git repository conflict detection, prevents duplicate git locations, and blocks directory nesting. The endpoint is `/validate-repository`.
17+
18+
See [Validation Rules](./validation-rules.md) for details on each check.
19+
20+
## How It Works
21+
22+
When you apply or modify a resource, Kubernetes routes the request to the ValidatingWebhookConfiguration, which calls the webhook in the porch-controllers pod. The webhook runs validation and either admits the request (continues to etcd write) or denies it (returns error to user immediately).
23+
24+
Both webhooks use `failurePolicy: Fail`, meaning if the webhook is unavailable, times out, or returns an error, the operation is rejected. This fail-closed approach prevents invalid resources from being created. If webhooks become unavailable, operations on those resources cannot proceed until webhooks are restored.
25+
26+
## Certificate Setup
27+
28+
Webhooks require TLS certificates for secure communication. By default, Porch generates self-signed certificates at deployment time. For production, use cert-manager for automatic provisioning and rotation.
29+
30+
See [Webhook Certificate Management](./cert-manager-webhooks.md) for configuration options.
31+
32+
## Troubleshooting
33+
34+
See [Webhook Certificate Management - Troubleshooting](./cert-manager-webhooks.md#troubleshooting) for common issues and solutions. For validation-specific errors, see [Validation Rules](./validation-rules.md).

0 commit comments

Comments
 (0)