You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add documentation on securing cross-namespace access for CC
- Add ByClusterClassRef index
- Support cross-ns CC rebase
Signed-off-by: Danil-Grigorev <[email protected]>
### Defining a custom namespace for ClusterClass object
442
+
443
+
As a user, I may need to create a `Cluster` from a `ClusterClass` object that exists only in a different namespace. To uniquely identify the `ClusterClass`, a `NamespacedName` ref is constructed from combination of:
444
+
* `cluster.spec.topology.classNamespace` - namespace of the `ClusterClass` object.
445
+
* `cluster.spec.topology.class` - name of the `ClusterClass` object.
446
+
447
+
Example of the `Cluster` object with the `name/namespace` reference:
448
+
449
+
```yaml
450
+
apiVersion: cluster.x-k8s.io/v1beta1
451
+
kind: Cluster
452
+
metadata:
453
+
name: my-docker-cluster
454
+
namespace: default
455
+
spec:
456
+
topology:
457
+
class: docker-clusterclass-v0.1.0
458
+
classNamespace: default
459
+
version: v1.22.4
460
+
controlPlane:
461
+
replicas: 3
462
+
workers:
463
+
machineDeployments:
464
+
- class: default-worker
465
+
name: md-0
466
+
replicas: 4
467
+
failureDomain: region
468
+
```
469
+
470
+
471
+
#### Securing cross-namespace reference to the ClusterClass
472
+
473
+
It is often desirable to restrict free cross-namespace `ClusterClass` access for the `Cluster` object. This can be implemented by defining a [`ValidatingAdmissionPolicy`](https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/#what-is-validating-admission-policy) on the `Cluster` object.
474
+
475
+
An example of such policy may be:
476
+
477
+
```yaml
478
+
apiVersion: admissionregistration.k8s.io/v1
479
+
kind: ValidatingAdmissionPolicy
480
+
metadata:
481
+
name: "cluster-class-ref.cluster.x-k8s.io"
482
+
spec:
483
+
failurePolicy: Fail
484
+
paramKind:
485
+
apiVersion: v1
486
+
kind: Secret
487
+
matchConstraints:
488
+
resourceRules:
489
+
- apiGroups: ["cluster.x-k8s.io"]
490
+
apiVersions: ["v1beta1"]
491
+
operations: ["CREATE", "UPDATE"]
492
+
resources: ["clusters"]
493
+
validations:
494
+
- expression: "!has(object.spec.topology.classNamespace) || object.spec.topology.classNamespace in params.data"
0 commit comments