Skip to content

Commit 1253277

Browse files
authored
Workload transf (#35)
1 parent d4fae06 commit 1253277

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

install-guide/package-transformations.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,21 +374,108 @@ triggered configsync to apply the `PackageVariant` configurations in the
374374
`mgmt/regional` package. Let's examine those `PackageVariant` configurations one
375375
by one.
376376

377+
In the text below, let's assume we are creating a workload cluster called `lambda`.
378+
377379
## pv-cluster.yaml: creates the Workload cluster
378380

381+
In the text below, let's assume we are creating a workload cluster called `lambda`.
382+
383+
This package variant transformation results in a package variant of the `cluster-capi-kind` package called `lambda-package`. The `lambda-package` contains the definition of a pair custom resources that are created when the package is applied. The custom resource pair are instances of the CRDs below
384+
385+
Custom Resource Definition | Controller | Function |
386+
--------------------------------- | ----------------------------------- | --------------------------------------------------------------------- |
387+
clusters.cluster.x-k8s.io | capi-system.capi-controller-manager | Trigger creation and start of the kind cluster |
388+
workloadclusters.infra.nephio.org | nephio-system.nephio-controller | Trigger addition of nephio-specific configuration to the kind cluster |
389+
390+
The `PackageVariant` specified in `pv-cluster.yaml` is executed and:
391+
1. Produces a package variant of the [cluster-capi-kind](https://github.com/nephio-project/nephio-example-packages/tree/main/cluster-capi-kind) package called `lambda-cluster` in the gitea `mgmt` repo on your management cluster.
392+
2. Applies the `lambda-cluster` kpt package to create the kind cluster for the workload cluster
393+
394+
### Package transformations
395+
396+
During creation of the package variant kpt package, the following transformations occur:
397+
398+
1. It creates a `drafts/lambda-cluster/v1` branch on the `mgmt` repo
399+
2. It does the equivalent of a [kpt pkg get](#kpt-pkg-get) on the `cluster-capi-kind` package into a directory called `lambda-cluster` on that branch, with the same transformations on package files carried out as the [kpt pkg get](#kpt-pkg-get) command above, this content is checked into the new branch in the initial commit
400+
3. The pipeline specified in the `Kptfile`of the `cluster-capi-kind` package specifies an `apply-replacements` specified in the `apply-replacements.yaml` file in the package and uses the value of the `workload-cluster.yaml:spec.clusterName` field set in 2. above (which is the workload cluster name). This has the value of `example` in the `workload-cluster.yaml` file. This means that in the `cluster.yaml` file the value of field `metadata.name` is changed from `workload` to `example`.
401+
4. The package variant `spec.injectors` changes specified in the `pv-cluster.yaml` file are applied.<br>
402+
a. The relevant `pv-cluster.yaml` fields are:
403+
```
404+
spec:
405+
injectors:
406+
- kind: WorkloadCluster
407+
name: example
408+
pipeline:
409+
mutators:
410+
- image: gcr.io/kpt-fn/set-annotations:v0.1.4
411+
configMap:
412+
nephio.org/cluster-name: example
413+
```
414+
415+
b. The following `PackageVariant` changes are made to the `lambda-cluster` package:
416+
1. The field `info.readinessGates.conditionType` is added to the `Kptfile` with the value `config.injection.WorkloadCluster.workload-cluster`.
417+
2. An extra `pipeline.mutators` entry is inserted in the `Kptfile`. This mutator is the mutator specified in the `pv-cluster.yaml` package variant specification, which specifies that the annotation `nephio.org/cluster-name: lambda` should be set on teh resources in the package:
418+
419+
```
420+
pipeline:
421+
mutators:
422+
- name: PackageVariant.lambda-cluster..0
423+
image: gcr.io/kpt-fn/set-annotations:v0.1.4
424+
configMap:
425+
nephio.org/cluster-name: lambda
426+
```
427+
3. The field `status.conditions` is added to the `Kptfile` with the values below. This condition means that the kpt package is not considered to be applied until the condition `config.injection.WorkloadCluster.workload-cluster` is `True`:
428+
```
429+
status:
430+
conditions:
431+
- type: config.injection.WorkloadCluster.workload-cluster
432+
status: "True"
433+
message: injected resource "lambda" from cluster
434+
reason: ConfigInjected
435+
```
436+
4. The `spec` in the WorkloadCluster file `workload-cluster.yaml` is set. This is the specification of the extra configuration that will be carried out on the workload cluster once kind has brought it up:
437+
438+
```
439+
clusterName: lambda
440+
cnis:
441+
- macvlan
442+
- ipvlan
443+
- sriov
444+
masterInterface: eth1
445+
```
446+
5. The amended pipeline specified in the `Kptfile`of the `lambda-cluster` is now re-executed. It was previously executed in step 3 above but there is now an extra mutator added by the package variant. The following changes result:<br>
447+
a. The new mutator added to the `Kptfile` by the package variant adds the annotation `nephio.org/cluster-name: lambda` is added to every resource in the package.
448+
b. The existing annotation in the `Kptfile` (coming from the Kptfile in the parent `cluster-capi-kind` package) sets the value `lambda` of the `spec.clusterName` field in `workload-cluster.yaml` as the value of the `metadata.name` field in the `cluster.yaml` file.
449+
450+
6. The `lambda-cluster` package is now ready to go. It is proposed and approved and the process of cluster creation commences.
451+
452+
### Cluster Creation
453+
TBD.
454+
455+
379456
## pv-rootsync.yaml:
380457

381-
## pv-repo.yaml: creates the Workload cluster repository
458+
TBD.
459+
460+
## pv-repo.yaml: create the workload cluster repo
461+
TBD.
382462

383463

384464
## pv-configsync.yaml:
465+
TBD.
385466

386467

387468
## pv-kindnet.yaml:
469+
TBD.
388470

389471
## pv-local-path-provisioner.yaml:
472+
TBD.
390473

391474
## pv-multus.yaml:
475+
TBD.
476+
392477

393478
## pv-vlanindex.yaml:
479+
TBD.
480+
394481

0 commit comments

Comments
 (0)