Skip to content

Commit 76c99ab

Browse files
Refactor InfraCluster contract
1 parent fef53c1 commit 76c99ab

23 files changed

+685
-367
lines changed

docs/book/src/SUMMARY.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
- [Diagnostics](./tasks/diagnostics.md)
4848
- [Security Guidelines](./security/index.md)
4949
- [Pod Security Standards](./security/pod-security-standards.md)
50-
- [Infrastructure Provider Security Guidance](./security/infrastructure-provider-security-guidance.md)
5150
- [clusterctl CLI](./clusterctl/overview.md)
5251
- [clusterctl Commands](clusterctl/commands/commands.md)
5352
- [init](clusterctl/commands/init.md)
@@ -64,7 +63,6 @@
6463
- [alpha topology plan](clusterctl/commands/alpha-topology-plan.md)
6564
- [additional commands](clusterctl/commands/additional-commands.md)
6665
- [clusterctl Configuration](clusterctl/configuration.md)
67-
- [clusterctl Provider Contract](clusterctl/provider-contract.md)
6866
- [clusterctl for Developers](clusterctl/developers.md)
6967
- [clusterctl Extensions with Plugins](clusterctl/plugins.md)
7068
- [Developer Guide](./developer/getting-started.md)
@@ -87,7 +85,6 @@
8785
- [Developing E2E tests](developer/core/e2e.md)
8886
- [Tuning controllers](./developer/core/tuning.md)
8987
- [Support multiple instances](./developer/core/support-multiple-instances.md)
90-
- [Multi-tenancy](./developer/core/multi-tenancy.md)
9188
- [Developing providers](./developer/providers/overview.md)
9289
- [Getting started](developer/providers/getting-started/overview.md)
9390
- [Naming](developer/providers/getting-started/naming.md)
@@ -97,12 +94,15 @@
9794
- [Controllers and Reconciliation](developer/providers/getting-started/controllers-and-reconciliation.md)
9895
- [Configure the provider manifest](developer/providers/getting-started/configure-the-deployment.md)
9996
- [Building, Running, Testing](developer/providers/getting-started/building-running-and-testing.md)
100-
- [Provider contracts](./developer/providers/contracts.md)
101-
- [Cluster Infrastructure](./developer/providers/cluster-infrastructure.md)
102-
- [Control Plane](./developer/providers/control-plane.md)
103-
- [Machine Infrastructure](./developer/providers/machine-infrastructure.md)
104-
- [Bootstrap](./developer/providers/bootstrap.md)
105-
- [Version migration](./developer/providers/version-migration.md)
97+
- [Provider contracts](developer/providers/contracts/overview.md)
98+
- [InfraCluster](./developer/providers/contracts/infra-cluster.md)
99+
- [InfraMachine](developer/providers/contracts/infra-machine.md)
100+
- [BootstrapConfig](developer/providers/contracts/bootstrap-config.md)
101+
- [ControlPlane](developer/providers/contracts/control-plane.md)
102+
- [clusterctl](developer/providers/contracts/clusterctl.md)
103+
- [Best practices](./developer/providers/best-practices.md)
104+
- [Security guidelines](./developer/providers/security-guidelines.md)
105+
- [Version migration](developer/providers/migrations/overview.md)
106106
- [v1.6 to v1.7](./developer/providers/migrations/v1.6-to-v1.7.md)
107107
- [v1.7 to v1.8](./developer/providers/migrations/v1.7-to-v1.8.md)
108108
- [v1.8 to v1.9](./developer/providers/migrations/v1.8-to-v1.9.md)

docs/book/src/clusterctl/commands/move.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clusterctl move --to-kubeconfig="path-to-target-kubeconfig.yaml"
2424
To move the Cluster API objects existing in the current namespace of the source management cluster; in case if you want
2525
to move the Cluster API objects defined in another namespace, you can use the `--namespace` flag.
2626

27-
The discovery mechanism for determining the objects to be moved is in the [provider contract](../provider-contract.md#move)
27+
The discovery mechanism for determining the objects to be moved is in the [provider contract](../../developer/providers/contracts/clusterctl.md#move)
2828

2929
<aside class="note">
3030

docs/book/src/clusterctl/configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It can be used to:
99

1010
## Provider repositories
1111

12-
The `clusterctl` CLI is designed to work with providers implementing the [clusterctl Provider Contract](provider-contract.md).
12+
The `clusterctl` CLI is designed to work with providers implementing the [clusterctl Provider Contract](../developer/providers/contracts/clusterctl.md).
1313

1414
Each provider is expected to define a provider repository, a well-known place where release assets are published.
1515

@@ -39,7 +39,7 @@ providers:
3939
type: "BootstrapProvider"
4040
```
4141
42-
See [provider contract](provider-contract.md) for instructions about how to set up a provider repository.
42+
See [provider contract](../developer/providers/contracts/clusterctl.md) for instructions about how to set up a provider repository.
4343
4444
**Note**: It is possible to use the `${HOME}` and `${CLUSTERCTL_REPOSITORY_PATH}` environment variables in `url`.
4545

Original file line numberDiff line numberDiff line change
@@ -1,89 +1,52 @@
11
# Cluster Controller
22

3-
![](../../../images/cluster-admission-cluster-controller.png)
4-
5-
The Cluster controller's main responsibilities are:
6-
7-
* Setting an OwnerReference on the infrastructure object referenced in `Cluster.spec.infrastructureRef`.
8-
* Setting an OwnerReference on the control plane object referenced in `Cluster.spec.controlPlaneRef`.
9-
* Cleanup of all owned objects so that nothing is dangling after deletion.
10-
* Keeping the Cluster's status in sync with the infrastructureCluster's status.
11-
* Creating a kubeconfig secret for [workload clusters](../../../reference/glossary.md#workload-cluster).
12-
13-
## Contracts
14-
15-
### Infrastructure Provider
16-
17-
The general expectation of an infrastructure provider is to provision the necessary infrastructure components needed to
18-
run a Kubernetes cluster. As an example, the AWS infrastructure provider, specifically the AWSCluster reconciler, will
19-
provision a VPC, some security groups, an ELB, a bastion instance and some other components all with AWS best practices
20-
baked in. Once that infrastructure is provisioned and ready to be used the AWSMachine reconciler takes over and
21-
provisions EC2 instances that will become a Kubernetes cluster through some bootstrap mechanism.
22-
23-
The cluster controller will set an OwnerReference on the infrastructureCluster. This controller should normally take no action during reconciliation until it sees the OwnerReference.
24-
25-
An infrastructureCluster controller is expected to either supply a controlPlaneEndpoint (via its own `spec.controlPlaneEndpoint` field),
26-
or rely on `spec.controlPlaneEndpoint` in its parent [Cluster](./cluster.md) object.
3+
The Cluster controller is responsible for reconciling the Cluster resource.
274

28-
If an endpoint is not provided, the implementer should exit reconciliation until it sees `cluster.spec.controlPlaneEndpoint` populated.
5+
In order to allow Cluster provisioning on different type of infrastructure, The Cluster resource references
6+
an InfraCluster object, e.g. AWSCluster, GCPCluster etc.
297

30-
The Cluster controller bubbles up `spec.controlPlaneEndpoint` and `status.ready` into `status.infrastructureReady` from the infrastructureCluster.
8+
The [InfraCluster resource contract](../../providers/contracts/infra-cluster.md) defines a set of rules a provider is expected to comply in order to allow
9+
the expected interactions with the Cluster controller.
3110

32-
#### Required `status` fields
11+
Among those rules:
12+
- InfraCluster SHOULD report a [controlplane endpoint](../../providers/contracts/infra-cluster.md#infracluster-control-plane-endpoint) for the Cluster
13+
- InfraCluster SHOULD report available [failure domains](../../providers/contracts/infra-cluster.md#infracluster-failure-domains) where machines should be placed in
14+
- InfraCluster MUST report when Cluster's infrastructure is [fully provisioned](../../providers/contracts/infra-cluster.md#infracluster-initialization-completed)
15+
- InfraCluster SHOULD report [conditions](../../providers/contracts/infra-cluster.md#infracluster-conditions)
16+
- InfraCluster SHOULD report [terminal failures](../../providers/contracts/infra-cluster.md#infracluster-terminal-failures)
3317

34-
The InfrastructureCluster object **must** have a `status` object.
18+
Similarly, in order to support different solutions for control plane management, The Cluster resource references
19+
an ControlPlane object, e.g. KubeadmControlPlane, EKSControlPlane etc.
3520

36-
The `spec` object **must** have the following fields defined:
21+
The [ControlPlane resource contract](../../providers/contracts/control-plane.md) defines a set of rules a provider is expected to comply in order to allow
22+
the expected interactions with the Cluster controller.
3723

38-
- `controlPlaneEndpoint` - identifies the endpoint used to connect to the target's cluster apiserver.
24+
Considering all the info above, the Cluster controller's main responsibilities are:
3925

40-
The `status` object **must** have the following fields defined:
41-
42-
- `ready` - a boolean field that is true when the infrastructure is ready to be used.
43-
44-
#### Optional `status` fields
45-
46-
The `status` object **may** define several fields that do not affect functionality if missing:
47-
48-
* `failureReason` - is a string that explains why a fatal error has occurred, if possible.
49-
* `failureMessage` - is a string that holds the message contained by the error.
50-
* `failureDomains` - is a `FailureDomains` type indicating the failure domains that machines should be placed in. `FailureDomains`
51-
is a map, defined as `map[string]FailureDomainSpec`. A unique key must be used for each `FailureDomainSpec`.
52-
`FailureDomainSpec` is defined as:
53-
- `controlPlane` (bool): indicates if failure domain is appropriate for running control plane instances.
54-
- `attributes` (`map[string]string`): arbitrary attributes for users to apply to a failure domain.
26+
* Setting an OwnerReference on the infrastructure object referenced in `Cluster.spec.infrastructureRef`.
27+
* Setting an OwnerReference on the control plane object referenced in `Cluster.spec.controlPlaneRef`.
28+
* Keeping the Cluster's status in sync with the InfraCluster and ControlPlane's status.
29+
* If no ControlPlane object is referenced, create a kubeconfig secret for [workload clusters](../../../reference/glossary.md#workload-cluster).
30+
* Cleanup of all owned objects so that nothing is dangling after deletion.
5531

56-
Note: once any of `failureReason` or `failureMessage` surface on the cluster who is referencing the infrastructureCluster object,
57-
they cannot be restored anymore (it is considered a terminal error; the only way to recover is to delete and recreate the cluster).
32+
![](../../../images/cluster-admission-cluster-controller.png)
5833

59-
Example:
60-
```yaml
61-
kind: MyProviderCluster
62-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
63-
spec:
64-
controlPlaneEndpoint:
65-
host: example.com
66-
port: 6443
67-
status:
68-
ready: true
69-
```
34+
### Kubeconfig Secrets
7035

71-
### Secrets
36+
In order to create a kubeconfig secret, it is required to have a certificate authority (CA) for the cluster.
7237

7338
If you are using the kubeadm bootstrap provider you do not have to provide any Cluster API secrets. It will generate
74-
all necessary CAs (certificate authorities) for you.
39+
all necessary CAs for you.
7540

76-
However, if you provide a CA for the cluster then Cluster API will be able to generate a kubeconfig secret.
77-
This is useful if you have a custom CA or do not want to use the bootstrap provider's generated self-signed CA.
41+
As alternative users can provide custom CA as described in [Using Custom Certificates](../../../tasks/certs/using-custom-certificates.md).
7842

79-
| Secret name | Field name | Content |
80-
|:---:|:---:|:---:|
81-
|`<cluster-name>-ca`|`tls.crt`|base64 encoded TLS certificate in PEM format|
82-
|`<cluster-name>-ca`|`tls.key`|base64 encoded TLS private key in PEM format|
83-
84-
Alternatively can entirely bypass Cluster API generating a kubeconfig entirely if you provide a kubeconfig secret
43+
Last option, is to entirely bypass Cluster API kubeconfig generation by providing a kubeconfig secret
8544
formatted as described below.
8645

87-
| Secret name | Field name | Content |
88-
|:---:|:---:|:---:|
89-
|`<cluster-name>-kubeconfig`|`value`|base64 encoded kubeconfig|
46+
| Secret name | Field name | Content |
47+
|:---------------------------:|:----------:|:-------------------------:|
48+
| `<cluster-name>-kubeconfig` | `value` | base64 encoded kubeconfig |
49+
50+
Notes:
51+
- Also renewal of the above certificate should be taken care out of band.
52+
- This option does not prevent from providing a cluster CA which is required also for other purposes.

docs/book/src/developer/core/multi-tenancy.md

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Support running multiple instances of the same provider
22

3-
Up until v1alpha3, the need of supporting [multiple credentials](../../../reference/glossary.md#multi-tenancy) was addressed by running multiple
3+
Up until v1alpha3, the need of supporting [multiple credentials](../../reference/glossary.md#multi-tenancy) was addressed by running multiple
44
instances of the same provider, each one with its own set of credentials while watching different namespaces.
55

66
However, running multiple instances of the same provider proved to be complicated for several reasons:
@@ -19,24 +19,22 @@ However, running multiple instances of the same provider proved to be complicate
1919
Nevertheless, we want to make it possible for users to choose to deploy multiple instances of the same providers,
2020
in case the above limitations/extra complexity are acceptable for them.
2121

22-
## Contract
23-
24-
In order to make it possible for users to deploy multiple instances of the same provider:
22+
In order to make it possible for users to deploy multiple instances of the Cluster API controller following
23+
flags are provided:
2524

2625
- Providers MUST support the `--namespace` flag in their controllers.
2726
- Providers MUST support the `--watch-filter` flag in their controllers.
2827

29-
⚠️ Users selecting this deployment model, please be aware:
28+
<aside class="note warning">
29+
30+
<h1>⚠️ Users selecting this deployment model, please be aware:</h1>
3031

31-
- Support should be considered best-effort.
32+
- Giving the increasingly complex task that is to manage multiple instances of the same controllers,
33+
the Cluster API community may only provide best effort support for users that choose this model.
3234
- Cluster API (incl. every provider managed under `kubernetes-sigs`) won't release a specialized components file
3335
supporting the scenario described above; however, users should be able to create such deployment model from
3436
the `/config` folder.
3537
- Cluster API (incl. every provider managed under `kubernetes-sigs`) testing infrastructure won't run test cases
3638
with multiple instances of the same provider.
3739

38-
In conclusion, giving the increasingly complex task that is to manage multiple instances of the same controllers,
39-
the Cluster API community may only provide best effort support for users that choose this model.
40-
41-
As always, if some members of the community would like to take on the responsibility of managing this model,
42-
please reach out through the usual communication channels, we'll make sure to guide you in the right path.
40+
</aside>

docs/book/src/developer/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ make envsubst
7676
The generated binary can be found at ./hack/tools/bin/envsubst
7777

7878
[envsubst]: https://github.com/drone/envsubst
79-
[provider-contract]: ./../clusterctl/provider-contract.md
79+
[provider-contract]: providers/contracts/clusterctl.md
8080

8181
### Cert-Manager
8282

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Implementation best practices
2+
3+
Cluster API doesn't define strict rules about how providers should implement controllers.
4+
5+
However, some best practice are worth to notice:
6+
7+
- Infrastructure objects (e.g. load balancers, VMs etc) generated by the Infra providers SHOULD adopt a naming
8+
convention that directly links to the Kubernetes resource that originated those objects.
9+
Please note that in most cases external constraints might impact this decision, like e.g.
10+
- Differences in naming conversions from Kubernetes CRDs and the target infrastructure
11+
- The fact that the InfraCluster Kubernetes CRD is namespace-scoped while target infrastructure might have different approaches
12+
to grouping resources
13+
14+
- Naming convention above should not be used and advertised as a contract to build on top. Instead more robust mechanism
15+
MUST always be provided and used for identifying objects, like tagging or labeling.
16+
Please note that this is necessary not only to prevent issues in case Cluster API changes default naming strategies
17+
for the Kubernetes objects generated by core controllers, but also to handle use cases where users intentionally influence Cluster API naming strategies.
18+
19+
- Cluster API offers a great development environment based on Tilt, which can be easily extended to work with any provider. Use it!
20+
See [Rapid iterative development with Tilt]
21+
22+
- Cluster API defines a set of best practices and standards that, if adopted, could speed up provider development and improve
23+
consistency with core Cluster API. See:
24+
- [Logging]
25+
- [Tuning controllers]
26+
27+
- Cluster API implements a test framework that, if adopted, could help in ensuring the quality of the provider. See:
28+
- [Testing]
29+
- [Developing E2E tests]
30+
31+
- While standard security practices for developing Kubernetes controllers apply, it is important to recognize that
32+
given that infrastructure provider deal with cloud credentials and cloud infrastructure, there are additional critical
33+
security concern that must be addressed to ensure secure operations. See:
34+
- [Infrastructure Provider Security Guidance]
35+
36+
[Rapid iterative development with Tilt]: ../core/tilt.md
37+
[Logging]: ../core/logging.md
38+
[Testing]: ../core/testing.md
39+
[Developing E2E tests]: ../core/e2e.md
40+
[Tuning controllers]: ../core/tuning.md
41+
[Infrastructure Provider Security Guidance]: security-guidelines.md

0 commit comments

Comments
 (0)