Skip to content

Commit a9878d2

Browse files
committed
Modified handling of remote compute resources
The access to the remote cluster is pushed from a specific "remote" HostClaim to the metal3 machine controller. Risks of using a kubeconfig for automation are exposed. Signed-off-by: Pierre Crégut <[email protected]>
1 parent a5b0869 commit a9878d2

File tree

1 file changed

+135
-62
lines changed

1 file changed

+135
-62
lines changed

design/hostclaim-multitenancy-and-hybrid-clusters.md

+135-62
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ implementation details of the compute resource.
9393
an arbitrary workload described by an OS image and an initial configuration.
9494
The user does not need to know exactly which resource is used and may not
9595
have full control over this resource (typically no BMC access).
96+
* Using BareMetalHosts defined in other clusters. Support as described here
97+
will be limited to the use with cluster-api.
9698

9799
### Non-Goals
98100

@@ -107,9 +109,6 @@ implementation details of the compute resource.
107109
of such a framework will be addressed in another design document.
108110
* Pivoting client clusters resources (managed clusters that are not the
109111
initial cluster).
110-
* Using BareMetalHosts defined in other clusters. The HostClaim concept
111-
supports this use case with some extensions. The design is outlined in the
112-
alternative approach section but is beyond the scope of this document.
113112

114113
## Proposal
115114

@@ -260,20 +259,22 @@ kind: Metal3MachineTemplate
260259
metadata:
261260
name: md-i
262261
spec:
263-
dataTemplate:
264-
name: dt-i
265-
kind: CT_i
266-
args:
267-
arg_i1: v1
268-
...
269-
arg_ik: vk
270-
hostSelector:
271-
matchLabels:
272-
...
273-
image:
274-
checksum: https://image_url.qcow2.md5
275-
format: qcow2
276-
url: https://image_url.qcow2.md5
262+
template:
263+
spec:
264+
dataTemplate:
265+
name: dt-i
266+
kind: CT_i
267+
args:
268+
arg_i1: v1
269+
...
270+
arg_ik: vk
271+
hostSelector:
272+
matchLabels:
273+
...
274+
image:
275+
checksum: https://image_url.qcow2.md5
276+
format: qcow2
277+
url: https://image_url.qcow2.md5
277278
```
278279
279280
The Metal3Machine controllers will create HostClaims with different kinds
@@ -287,9 +288,91 @@ Controllers for disposable resources such as virtual machine typically do not
287288
use hostSelectors. Controllers for a "bare-metal as a service" service
288289
may use selectors.
289290
291+
#### Compute Resources in Another Cluster
292+
293+
As a user I would like to describe my cluster within a specific management
294+
cluster. However the resources I intend to use (such as BareMetalHosts or
295+
KubeVirt virtual machines) will be defined in a separate cluster.
296+
297+
The Metal3Machine is augmented with a field ``credentials`` that points to a
298+
secret containing a kubeconfig object. This kubeconfig will be utilized instead
299+
of the HostClaim controller service account to create and manage HostClaim
300+
resources in the default namespace of the remote cluster as defined by the
301+
kubeconfig object. This kubeconfig should be associated with a Role that
302+
authorizes only HostClaim manipulation in a specific namespace.
303+
304+
The following machine resource with the associated kubeconfig secret:
305+
306+
```yaml
307+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
308+
kind: Metal3Machine
309+
metadata:
310+
name: m3m-xxxx
311+
spec:
312+
kind: baremetalhost
313+
credentials: bmh-cluster-credentials
314+
dataTemplate:
315+
...
316+
hostSelector:
317+
...
318+
image:
319+
checksum: https://image_url.qcow2.md5
320+
format: qcow2
321+
url: https://image_url.qcow2.md5
322+
---
323+
apiVersion: v1
324+
kind: Secret
325+
metadata:
326+
name: bmh-cluster-credentials
327+
stringdata:
328+
kubeconfig: |
329+
apiVersion: v1
330+
clusters:
331+
- cluster:
332+
server: https://bmh-cluster:6443
333+
...
334+
name: bmh-cluster
335+
contexts:
336+
- context:
337+
cluster: bmh-cluster
338+
user: user1
339+
name: user1@bmh-cluster
340+
namespace: user1-ns
341+
current-context: user1@bmh-cluster
342+
kind: Config
343+
preferences: {}
344+
users:
345+
- name: user1
346+
...
347+
```
348+
349+
will result in the creation of a HostClaim resource on ``bmh-cluster`` within
350+
the ``user1-ns`` namespace with the following content:
351+
352+
``yaml
353+
apiVersion: metal3.io/v1alpha1
354+
kind: HostClaim
355+
metadata:
356+
name: host-claim-yyyy
357+
namespace: user1-ns
358+
spec:
359+
kind: baremetalhost
360+
credentials: bmh-cluster-credentials
361+
dataTemplate:
362+
...
363+
hostSelector:
364+
...
365+
image:
366+
checksum: https://image_url.qcow2.md5
367+
format: qcow2
368+
url: https://image_url.qcow2.md5
369+
online: true
370+
``
371+
290372
#### Manager Cluster Bootstrap
291373
292-
As a cluster administrator I would like to install a new baremetal cluster from a transient cluster.
374+
As a cluster administrator I would like to install a new baremetal cluster from
375+
a transient cluster.
293376
294377
The bootstrap process can be performed as usual from an ephemeral cluster
295378
(e.g., a KinD cluster). The constraint that all resources must be in the same
@@ -325,10 +408,21 @@ from the owner of BareMetalHost resources, especially when we upgrade the
325408
metal3 cluster api provider to a version supporting HostClaim.
326409
327410
The solution is to enforce that BareMetalHost that can be bound to a
328-
HostClaim have a label (proposed name: ``hosts.metal3.io/namespaces``)
411+
HostClaim have a label (proposed name: ``hostclaims.metal3.io/namespaces``)
329412
restricting authorized HostClaims to specific namespaces. The value could be
330413
either ``*`` for no constraint, or a comma separated list of namespace names.
331414
415+
#### Security Impact of using Kubeconfig for Access to Remote Cluster Hosting Compute Resources
416+
417+
There is no new real security risk associated with the using credentials stored
418+
in a secret for a restricted user that can only manipulate HostClaim in a
419+
specific namespace.
420+
421+
However, when a new user needs to access the remote compute resource, it becomes
422+
challenging to automate the creation of a new account bound with a specific role
423+
restricted to a single newly created namespace and to HostClaim resources
424+
without granting full admin rights to this process.
425+
332426
#### Tenants Trying to Bypass the Selection Mechanism
333427
334428
The fact that a HostClaim is bound to a specific BareMetalHost will appear
@@ -467,49 +561,28 @@ The disadvantages of the BareMetalPool approach are:
467561
* The current implementation of the proxy is limited to the Redfish protocol
468562
and would require significant work for IPMI.
469563
470-
#### HostClaims as a right to consume BareMetalHosts
471-
472-
The approach combines the concept of remote endpoint of BareMetalPools with
473-
the API-oriented approach of HostClaims, as described above.
474-
475-
In this variation, the HostClaim will be an object in the BareMetalHost
476-
namespace defined with an API endpoint to drive the associated BareMetalHost.
477-
The associated credentials are known from the Metal3Machine controller
478-
because they are associated with the cluster. The Metal3 machine controller
479-
will use this endpoint and the credentials to create the HostClaim. The
480-
HostClaim controller will associate the HostClaim with a BareMetalHost.
481-
Control actions and information about the status of the BareMetalHost will
482-
be exchanged with the Metal3 machine controller through the endpoint.
483-
484-
The main advantage of the approach is that BareMetalHosts do not need to be on
485-
the same cluster.
486-
487-
The main drawbacks are:
488-
489-
* It only addresses the multi-tenancy scenario. The hybrid scenario is not
490-
solved but the usage of HostClaim outside Cluster-API is not addressed
491-
either. The main reason is that there is no counter-part of the
492-
BareMetalHost in the namespace of the tenant.
493-
* The end user will have very limited direct view on the compute resources
494-
it is using even when the BareMetalHosts are on the same cluster.
495-
496-
Extending HostClaims with a remote variant fulfills the same requirements
497-
but keeps an explicit object in the namespace of the cluster definition
498-
representing the API offered by this approach.
499-
500-
A remote HostClaim is a a HostClaim with kind set to ``remote`` and at
501-
least two arguments:
502-
503-
* One points to a URL and a set of credentials to access the endpoint on a
504-
remote cluster,
505-
* The second is the kind of the copied HostClaim created on the remote
506-
cluster.
507-
508-
The two HostClaims are synchronized: the specification of the source HostClaim
509-
is copied to the remote one (except the kind part). The status of the target
510-
HostClaim is copied back to the source.. For meta-data, most of them are copied
511-
from the target to the source. The exact implementation of this extension is
512-
beyond the scope of this proposal.
564+
#### Explicit Remote HostClaim
565+
566+
Instead of relying on the Metal3Machine controller to handle access to a remote
567+
cluster, this solution introduces a HostClaim with the kind field set to
568+
``remote``.
569+
570+
This resource, referred to as the source, is synchronized with another
571+
HostClaim, referred to as the target, on a remote cluster.
572+
The specification of the source HostClaim is copied in the target resource
573+
excluding the kind field. The status of the target HostClaim is copied
574+
back to the source. For metadata, most of the fields are copied from the target
575+
to the source.
576+
577+
The source HostClaim must include at least two arguments:
578+
579+
* A ``real-kind`` field that define the kind of the remote HostClaim.
580+
* Credentials and location to access the remote cluster, typically in the form
581+
of a kubeconfig.
582+
583+
This solution is more complex as two HostClaims resources are required
584+
for each Metal3Machine. But, it can also be used to address the *simple
585+
workload* scenario with remote compute resources.
513586
514587
### Hybrid Clusters Without HostClaim
515588

0 commit comments

Comments
 (0)