Skip to content

Commit b7fdcd4

Browse files
authored
Streamline the MultiKueue ClusterProfile API documentation (#8390)
* Streamline the MultiKueue ClusterProfile API documentation * Add plugin example links to MultiKueue ClusterProfile docs * Add image volumes as an option for mounting plugins
1 parent 04f02e3 commit b7fdcd4

1 file changed

Lines changed: 157 additions & 51 deletions

File tree

site/content/en/docs/tasks/manage/setup_multikueue.md

Lines changed: 157 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ To create the sample queue setup in the `default` namespace, you can apply the f
3434

3535
### MultiKueue Specific Kubeconfig
3636

37-
3837
In order to delegate the jobs in a worker cluster, the manager cluster needs to be able to create, delete, and watch workloads and their parent Jobs.
3938

4039
While `kubectl` is set up to use the worker cluster, download:
@@ -131,27 +130,79 @@ It provides a robust, modular, and extensible framework that helps other open so
131130
The integration with OCM is an optional solution that enables Kueue users to streamline the MultiKueue setup process, automate the generation of MultiKueue specific Kubeconfig, and enhance multicluster scheduling capabilities.
132131
For more details about this solution, please refer to this [link](https://github.com/open-cluster-management-io/ocm/tree/main/solutions/kueue-admission-check).
133132

134-
## Setup MultiKueue with ClusterProfile API
133+
## Configure federated credential discovery via the ClusterProfile API
135134

136135
{{< feature-state state="alpha" for_version="v0.15" >}}
137136

138-
The [ClusterProfile API](https://multicluster.sigs.k8s.io/concepts/cluster-profile-api/) provides a standardized, vendor-neutral interface for presenting cluster information. It allows defining cluster access information in a standardized `ClusterProfile` object and using credential plugins for authentication.
137+
The [Cluster Inventory API](https://multicluster.sigs.k8s.io/) provides a standardized, vendor-neutral interface for representing a cluster's properties and status.
138+
It defines a `ClusterProfile` resource that encapsulates the identity, metadata, and status of a specific cluster within a multi-cluster environment.
139+
140+
Kueue can leverage the configuration contained within a `ClusterProfile` object to obtain credentials and connect to the cluster it represents.
141+
In practice, this means that instead of using Kubeconfig files to specify the connection to its workers, the manager cluster uses the state and
142+
access providers contained in the existing `ClusterProfile`s. This eliminates a large portion of management required from the administrator and
143+
allows to delegate credentialing to the entity managing the clusters (like a cloud provider).
144+
145+
{{% alert title="Note" color="primary" %}}
146+
147+
Kueue itself does not manage the `ClusterProfile` resources, which is the responsibility of the cluster manager, for example a cloud provider or a dedicated controller.
148+
149+
{{% /alert %}}
150+
151+
### Enable the `MultiKueueClusterProfile` feature gate
152+
153+
The `MultiKueueClusterProfile` feature gate has to be enabled for Kueue to consider `ClusterProfile` objects when connecting to clusters.
154+
Refer to the [Installation guide](/docs/installation/#change-the-feature-gates-configuration) for instructions on configuring feature gates.
155+
156+
### Provision the `ClusterProfile` objects for your clusters
157+
158+
#### Cloud provider managed cluster inventory
159+
160+
When using a cloud provider that supports the automatic generation and synchronization of a cluster inventory, the `ClusterProfile` objects are
161+
managed directly by their platform and do not require that the user sets them up manually or uses a dedicated controller.
162+
163+
To enable the generation of an inventory, refer to your cloud provider's documentation:
164+
* Google Cloud Platform:
165+
* [Full walkthrough of MultiKueue setup with ClusterProfile](https://github.com/GoogleCloudPlatform/gke-fleet-management/blob/b9fe08386c48f84617cb8ab7b042f2790741e893/multikueue-clusterprofile/README.md).
166+
* [Inventory generation documentation](https://docs.cloud.google.com/kubernetes-engine/fleet-management/docs/generate-inventory-for-integrations).
167+
168+
When using cloud provider managed cluster inventory, you should expect a `ClusterProfile` object to be created in your MultiKueue manager cluster,
169+
one per cluster (including the manager itself).
170+
171+
For example:
172+
```yaml
173+
apiVersion: multicluster.x-k8s.io/v1alpha1
174+
kind: ClusterProfile
175+
metadata:
176+
labels:
177+
x-k8s.io/cluster-manager: <cloud-provider-service-name>
178+
name: multikueue-worker-1
179+
namespace: kueue-system
180+
spec:
181+
clusterManager:
182+
name: <cloud-provider-service-name>
183+
displayName: multikueue-worker-1
184+
status:
185+
accessProviders:
186+
- cluster:
187+
server: <cluster-url>
188+
name: <access-provider-name>
189+
```
139190
140-
### Enable MultiKueueClusterProfile feature gate
141-
Enable the `MultiKueueClusterProfile` feature gate. Refer to the
142-
[Installation guide](/docs/installation/#change-the-feature-gates-configuration)
143-
for instructions on configuring feature gates.
191+
Where:
192+
* `cloud-provider-service-name` is the name of the service within the cloud provider that manages the cluster. For example `gke-fleet`.
193+
* `cluster-url` is the URL of the cluster's control plane.
194+
* `access-provider-name` is the name of the provider of the cluster's credentials. For example `google`.
144195

145-
### Create ClusterProfile objects
196+
#### Manually created cluster inventory
146197

147-
If you are using a cloud provider, refer to the documentation on how to generate ClusterProfile objects (e.g. [GKE](https://docs.cloud.google.com/kubernetes-engine/fleet-management/docs/generate-inventory-for-integrations)). Alternatively, you can manually install the `ClusterProfile` CRD and objects for your clusters.
198+
In principle, the `ClusterProfile` objects can be provisioned without the use of a cloud provider.
148199

149-
To install the `ClusterProfile` CRD, run:
200+
Firstly, the `ClusterProfile` CRDs have to be manually installed within the cluster:
150201
```bash
151202
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/cluster-inventory-api/refs/heads/main/config/crd/bases/multicluster.x-k8s.io_clusterprofiles.yaml
152203
```
153204

154-
To create a `ClusterProfile` object for `worker1-cluster`, run:
205+
Next, the `ClusterProfile` objects can be created:
155206
```yaml
156207
apiVersion: multicluster.x-k8s.io/v1alpha1
157208
kind: ClusterProfile
@@ -162,46 +213,33 @@ spec:
162213
...
163214
status:
164215
accessProviders:
165-
- name: ${PROVIDER_NAME}
216+
- name: <access-provider-name>
166217
cluster:
167-
server: https://${SERVER_ENDPOINT}
168-
certificate-authority-data: ${CERTIFICATE_AUTHORITY_DATA}
218+
...
169219
```
170220

171-
### Configure Kueue Manager
221+
{{% alert title="Note" color="primary" %}}
172222

173-
Next, configure the controller manager config map with the credentials providers.
223+
The `ClusterProfile` access providers are within the object's `status` subresource and, in principle, should be managed by the cluster manager
224+
(i.e. the entity provisioning the clusters, like a cloud provider) and not created manually.
174225

175-
```yaml
176-
apiVersion: v1
177-
data:
178-
controller_manager_config.yaml: |
179-
...
180-
multiKueue:
181-
clusterProfile:
182-
credentialsProviders:
183-
- name: ${PROVIDER_NAME}
184-
execConfig:
185-
apiVersion: client.authentication.k8s.io/v1beta1
186-
command: /plugins/${PLUGIN_COMMAND}
187-
kind: ConfigMap
188-
metadata:
189-
labels:
190-
app.kubernetes.io/name: kueue
191-
control-plane: controller-manager
192-
name: kueue-manager-config
193-
namespace: kueue-system
194-
```
226+
{{% /alert %}}
227+
228+
### Install the access provider plugin
195229

196-
### Install Required Plugins
230+
The access provider defined in `ClusterProfile` depends upon an executable plugin being available to the
231+
Kueue controller manager pods running within the MultiKueue manager cluster.
232+
It's the responsibility of the Kueue administrator to make sure that the required command is available.
197233

198-
If your credentials provider requires an executable plugin, you must make it available to the Kueue manager.
234+
An example plugin can be found [here](https://github.com/kubernetes-sigs/cluster-inventory-api/tree/445319b6307a88778b930e154ed3e2f38d85a689/cmd/secretreader-plugin) (secret reader) or [here](https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke) (Google Cloud Platform).
199235

200-
#### Add plugins via volume mounts
236+
#### Mount the executable with `initContainers`
201237

202-
You can use an `initContainer` to add the plugin to a shared `emptyDir` volume before the Kueue manager starts. The `kueue-controller-manager` container can then mount this volume to access the plugin.
238+
The [`initContainers`](https://kubernetes.io/docs/concepts/workloads/pods/init-containers/) field within the pods specification
239+
can be used to populate a volume with the required plugin. The image used by the init container has to be built beforehand.
203240

204-
Here is an example patch for the `kueue-controller-manager` deployment that adds a custom authentication plugin:
241+
The `kueue-controller-manager` container within the Kueue manager deployment can then mount this volume in its filesystem to access the executable.
242+
For example:
205243

206244
```yaml
207245
apiVersion: apps/v1
@@ -214,8 +252,8 @@ spec:
214252
spec:
215253
initContainers:
216254
- name: add-auth-plugin
217-
image: ${PLUGIN_IMAGE}
218-
command: ["cp", "${PLUGIN_COMMAND}", "/plugins/${PLUGIN_COMMAND}"]
255+
image: <plugin-image>
256+
command: ["cp", "<plugin-command>", "/plugins/<plugin-command>"]
219257
volumeMounts:
220258
- name: clusterprofile-plugins
221259
mountPath: "/plugins"
@@ -229,18 +267,86 @@ spec:
229267
emptyDir: {}
230268
```
231269

232-
This patch does the following:
233-
1. Adds an `initContainer` that copies the `${PLUGIN_COMMAND}` from its container image to the `/plugins` directory in the shared volume.
234-
2. Adds an `emptyDir` volume named `clusterprofile-plugins` to the pod.
235-
3. Mounts the `clusterprofile-plugins` volume to the `manager` container, making the plugin available at `/plugins/${PLUGIN_COMMAND}`.
270+
Where:
271+
* `plugin-image` is the image reference of an image that contains the plugin executable.
272+
* `plugin-command` is the name of the executable. For example `gcp-auth-plugin`.
273+
274+
#### (Kubernetes 1.35+) Mount the executable using an image volume
275+
276+
The ability to [mount content from OCI registries into containers](https://kubernetes.io/docs/tasks/configure-pod-container/image-volumes/) reached beta in Kubernetes 1.35. This feature streamlines some aspects of the `initContainers` approach.
277+
278+
For example:
279+
280+
```yaml
281+
apiVersion: apps/v1
282+
kind: Deployment
283+
metadata:
284+
name: kueue-controller-manager
285+
namespace: kueue-system
286+
spec:
287+
template:
288+
spec:
289+
containers:
290+
- name: manager
291+
volumeMounts:
292+
- name: clusterprofile-plugins
293+
mountPath: "/plugins"
294+
volumes:
295+
- name: clusterprofile-plugins
296+
image:
297+
reference: <plugin-image>
298+
pullPolicy: IfNotPresent
299+
```
300+
301+
Where:
302+
* `plugin-image` is the image reference of an image that contains the plugin executable.
303+
304+
The files inside the `plugin-image` will be accessible under the `mountPath` (in this case `/plugins`)
305+
and can be called analogously to the `initContainers` approach (`/plugins/<plugin-command>`).
306+
307+
#### Build a custom Kueue manager image
308+
309+
Alternatively, a custom Kueue manager image can be built to include the plugin executable.
310+
The image reference in the Kueue manager deployment should then point to the user-managed custom image.
311+
312+
### Define the credentials provider in the Kueue manager config
313+
314+
To connect the access providers specified in the `ClusterProfile`s with the mounted plugin,
315+
an entry within the Kueue configuration has to be created:
316+
317+
```yaml
318+
apiVersion: v1
319+
data:
320+
controller_manager_config.yaml: |
321+
...
322+
multiKueue:
323+
clusterProfile:
324+
credentialsProviders:
325+
- name: <access-provider-name>
326+
execConfig:
327+
apiVersion: client.authentication.k8s.io/v1beta1
328+
command: /plugins/<plugin-command>
329+
kind: ConfigMap
330+
metadata:
331+
labels:
332+
app.kubernetes.io/name: kueue
333+
control-plane: controller-manager
334+
name: kueue-manager-config
335+
namespace: kueue-system
336+
```
236337

237-
#### Build a custom image
338+
Where:
339+
* `access-provider-name` is the name of the provider of the cluster's credentials.
340+
It has to match the `accessProviders` name in the relevant `ClusterProfile`s.
341+
* `plugin-command` is the name of the executable within the manager container.
238342

239-
Alternatively, you can build a custom Kueue manager image that includes your plugin. You would then update your Kueue deployment to use this new image.
343+
This definition will configure the `ClusterProfile`s using the `access-provider-name` to retrieve
344+
cluster credentials via the `plugin-command` executable.
240345

241-
### Configure MultiKueueCluster objects
346+
### Link `MultiKueueCluster` objects to their corresponding `ClusterProfile`
242347

243-
When using the `ClusterProfile` API for authentication, configure your `MultiKueueCluster` objects to reference a `ClusterProfile` via the `clusterProfileRef` field, instead of providing `kubeconfig` directly.
348+
When using the `ClusterProfile` API for authentication, the `MultiKueueCluster` objects have to reference a `ClusterProfile` via the `clusterProfileRef` field,
349+
instead of providing `kubeconfig` directly.
244350

245351
Here's an example `MultiKueueCluster` object using a `clusterProfileRef`:
246352

0 commit comments

Comments
 (0)