Skip to content

Commit 2056db8

Browse files
authored
Merge pull request #6166 from killianmuldoon/book/update-providers
📖 Fix outdated links in implementers guide
2 parents cb1d1e3 + 63ccc94 commit 2056db8

File tree

5 files changed

+94
-11
lines changed

5 files changed

+94
-11
lines changed

docs/book/src/SUMMARY.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@
5858
- [Multi-tenancy](./developer/architecture/controllers/multi-tenancy.md)
5959
- [Support multiple instances](./developer/architecture/controllers/support-multiple-instances.md)
6060
- [Provider Implementers](./developer/providers/implementers.md)
61-
- [v0.3 to v0.4](./developer/providers/v0.3-to-v0.4.md)
62-
- [v0.4 to v1.0](./developer/providers/v0.4-to-v1.0.md)
63-
- [v1.0 to v1.1](./developer/providers/v1.0-to-v1.1.md)
64-
- [v1.1 to v1.2](./developer/providers/v1.1-to-v1.2.md)
65-
- [Cluster Infrastructure](./developer/providers/cluster-infrastructure.md)
66-
- [Machine Infrastructure](./developer/providers/machine-infrastructure.md)
67-
- [Bootstrap](./developer/providers/bootstrap.md)
61+
- [Version migration](./developer/providers/version-migration.md)
62+
- [v0.3 to v0.4](./developer/providers/v0.3-to-v0.4.md)
63+
- [v0.4 to v1.0](./developer/providers/v0.4-to-v1.0.md)
64+
- [v1.0 to v1.1](./developer/providers/v1.0-to-v1.1.md)
65+
- [v1.1 to v1.2](./developer/providers/v1.1-to-v1.2.md)
66+
- [Provider contracts](./developer/providers/contracts.md)
67+
- [Cluster Infrastructure](./developer/providers/cluster-infrastructure.md)
68+
- [Machine Infrastructure](./developer/providers/machine-infrastructure.md)
69+
- [Bootstrap](./developer/providers/bootstrap.md)
6870
- [Implementer's Guide](./developer/providers/implementers-guide/overview.md)
6971
- [Naming](./developer/providers/implementers-guide/naming.md)
7072
- [Create Repo and Generate CRDs](./developer/providers/implementers-guide/generate_crds.md)
7173
- [Create API](./developer/providers/implementers-guide/create_api.md)
74+
- [Webhooks](./developer/providers/webhooks.md)
7275
- [Controllers and Reconciliation](./developer/providers/implementers-guide/controllers_and_reconciliation.md)
7376
- [Building, Running, Testing](./developer/providers/implementers-guide/building_running_and_testing.md)
7477
- [CustomResourceDefinitions relationships](./developer/crd-relationships.md)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Provider contract
2+
3+
Cluster API defines a contract which requires providers to implement certain fields and patterns in their CRDs and controllers. This contract is required for providers to work correctly with Cluster API.
4+
5+
Cluster API defines the following contracts:
6+
7+
- [Infrastructure provider contract](./cluster-infrastructure.md)
8+
- [Boostrap provider contract](./bootstrap.md)
9+
- [Control Plane provider contract](../../developer/architecture/controllers/control-plane.md#crd-contracts)
10+
- [Machine provider contract](./machine-infrastructure.md)
11+
- [clusterctl provider contract](../../clusterctl/provider-contract.md#clusterctl-provider-contract)
12+
- [Multi tenancy contract](../../developer/architecture/controllers/multi-tenancy.md#contract)
13+
14+
## API version labels
15+
Providers MUST set `cluster.x-k8s.io/<version>` label on all Custom Resource Definitions related to Cluster API starting with v1alpha3.
16+
The label is a map from an API Version of Cluster API (contract) to your Custom Resource Definition versions.
17+
The value is a underscore-delimited (_) list of versions.
18+
Each value MUST point to an available version in your CRD Spec.
19+
20+
The label allows Cluster API controllers to perform automatic conversions for object references, the controllers will pick the last available version in the list if multiple versions are found.
21+
To apply the label to CRDs it’s possible to use commonLabels in your kustomize.yaml file, usually in config/crd.
22+
23+
In this example we show how to map a particular Cluster API contract version to your own CRD using Kustomize’s commonLabels feature:
24+
25+
```yaml
26+
commonLabels:
27+
cluster.x-k8s.io/v1alpha2: v1alpha1
28+
cluster.x-k8s.io/v1alpha3: v1alpha2
29+
cluster.x-k8s.io/v1beta1: v1beta1
30+
```
31+
32+
An example of this is in the [Kubeadm Bootstrap provider](https://github.com/kubernetes-sigs/cluster-api/blob/release-1.1/controlplane/kubeadm/config/crd/kustomization.yaml).
33+
34+
## Improving and contributing to the contract
35+
36+
The definition of the contract between Cluster API and providers may be changed in future versions of Cluster API. The Cluster API maintainers welcome feedback and contributions to the contract in order to improve how it's defined, its clarity and visibility to provider implementers and its suitability across the different kinds of Cluster API providers. To provide feedback or open a discussion about the provider contract please [open an issue on the Cluster API](https://github.com/kubernetes-sigs/cluster-api/issues/new?assignees=&labels=&template=feature_request.md) repo or add an item to the agenda in the [Cluster API community meeting](http://git.k8s.io/community/sig-cluster-lifecycle/README.md#cluster-api).

docs/book/src/developer/providers/implementers-guide/generate_crds.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ make manifests
8383
8484
The cluster API CRDs should be further customized:
8585
86-
- [Apply the contract version label to support conversions](https://release-0-4.cluster-api.sigs.k8s.io/developer/providers/v1alpha2-to-v1alpha3.html#apply-the-contract-version-label-clusterx-k8sioversion-version1_version2_version3-to-your-crds)
87-
- [Upgrade to CRD v1](https://release-0-4.cluster-api.sigs.k8s.io/developer/providers/v1alpha2-to-v1alpha3.html#upgrade-to-crd-v1)
88-
- [Set “matchPolicy=Equivalent” kubebuilder marker for webhooks](https://release-0-4.cluster-api.sigs.k8s.io/developer/providers/v1alpha2-to-v1alpha3.html#add-matchpolicyequivalent-kubebuilder-marker-in-webhooks)
89-
- [Refactor the kustomize config folder to support multi-tenancy](https://release-0-4.cluster-api.sigs.k8s.io/developer/providers/v1alpha2-to-v1alpha3.html#refactor-kustomize-config-folder-to-support-multi-tenancy-when-using-webhooks)
86+
- [Apply the contract version label to support conversions](../contracts.md#api-version-labels)
9087
- [Ensure you are compliant with the clusterctl provider contract](../../../clusterctl/provider-contract.md#components-yaml)
9188
9289
### Commit your changes
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Version migration
2+
3+
The following pages provide an overview of relevant changes between versions of Cluster API and their direct successors. These guides are intended to assist
4+
maintainers of other providers and consumers of the Go API in upgrading from one version of Cluster API to a subsequent version.
5+
6+
- [v0.3 to v0.4](v0.3-to-v0.4.md)
7+
- [v0.4 to v1.0](v0.4-to-v1.0.md)
8+
- [v1.0 to v1.1](v1.0-to-v1.1.md)
9+
- [v1.1 to v1.2](v1.1-to-v1.2.md)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Webhooks
2+
3+
Cluster API provides support for three kinds of webhooks: validating webhooks, defaulting webhook and conversion webhooks.
4+
5+
## Validating webhooks
6+
Validating webhooks are an implementation of a [Kubernetes validating webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#validatingadmissionwebhook). A validating webhook allows developers to test whether values supplied by users are valid. e.g. [the Cluster webhook] ensures the Infrastructure reference supplied at the Cluster's `.spec.infrastructureRef` is in the same namespace as the Cluster itself and rejects the object creation or update if not.
7+
8+
## Defaulting webhooks
9+
Defaulting webhooks are an implementation of a [Kubernetes mutating webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook). A defaulting webhook allows developers to set default values for a type before they are placed in the Kubernetes data store. e.g. [the Cluster webhook] will set the Infrastructure reference namespace to equal the Cluster namespace if `.spec.infrastructureRef.namespace` is empty.
10+
11+
## Conversion webhooks
12+
Conversion webhooks are what allow Cluster API to work with multiple API types without requiring different versions. It does this by converting the incoming version to a `Hub` version which is used internally by the controllers. To read more about conversion see the [Kubebuilder documentation](https://book.kubebuilder.io/multiversion-tutorial/conversion.html)
13+
14+
For a walkthrough on implementing conversion webhooks see the video in the [Developer Guide](https://cluster-api.sigs.k8s.io/developer/guide.html?highlight=video#videos-explaining-capi-architecture-and-code-walkthroughs)
15+
16+
## Implementing webhooks with Controller Runtime and Kubebuilder
17+
The webhooks in Cluster API are offered through tools in Controller Runtime and Kubebuilder. The webhooks implement interfaces defined in Controller Runtime, while generation of manifests can be done using Kubebuilder.
18+
19+
For information on how to create webhooks [refer to the Kubebuilder book](https://book.kubebuilder.io/cronjob-tutorial/webhook-implementation.html).
20+
21+
22+
Webhook manifests are generated using Kubebuilder in Cluster API. This is done by adding tags to the webhook implementation in the codebase. Below, for example, are the tags on the [the Cluster webhook]:
23+
24+
```go
25+
26+
// +kubebuilder:webhook:verbs=create;update;delete,path=/validate-cluster-x-k8s-io-v1beta1-cluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=cluster.x-k8s.io,resources=clusters,versions=v1beta1,name=validation.cluster.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
27+
// +kubebuilder:webhook:verbs=create;update,path=/mutate-cluster-x-k8s-io-v1beta1-cluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=cluster.x-k8s.io,resources=clusters,versions=v1beta1,name=default.cluster.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
28+
29+
// Cluster implements a validating and defaulting webhook for Cluster.
30+
type Cluster struct {
31+
Client client.Reader
32+
}
33+
```
34+
35+
A detailed guide on the purpose of each of these tags is [here](https://book.kubebuilder.io/reference/markers/webhook.html).
36+
37+
<!-- links -->
38+
[the Cluster webhook]: https://github.com/kubernetes-sigs/cluster-api/blob/release-1.1/internal/webhooks/cluster.go

0 commit comments

Comments
 (0)