Skip to content

Commit

Permalink
Update addon README (vmware-tanzu#730)
Browse files Browse the repository at this point in the history
Signed-off-by: Lucheng Bao <luchengb@vmware.com>
  • Loading branch information
blc1996 authored Oct 1, 2021
1 parent d15a82a commit 3941ddc
Showing 1 changed file with 22 additions and 102 deletions.
124 changes: 22 additions & 102 deletions addons/README.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,22 @@
# How to add an addon template

This directory hosts the addon templates. If you want to add a new addon template, create a new folder named after the new addon.

Current addon templates:

* addon-manager
* antrea
* calico
* kapp-controller
* metrics-server
* pinniped
* vsphere_cpi
* vsphere_csi

## Folder Structure

```sh
.
+-- examples (optinal)
| +-- example_values.yaml
| +-- ....
+-- tempaltes
| +-- base-files
| +-- libs
| +-- overlays
| +-- values.star
| +-- values.yaml
| +-- imageInfo.yaml
+-- Makefile
```

### examples (optional)

Put sample `values.yaml` files here. These files can be examples that represent some specific use cases, for more details refer to [pinniped examples](pinniped/examples)

### templates

This is where to put the ytt template files.

#### base files

YTT base files. Ideally, they should not contain any YTT functions or variables. All customizations to the manifests should better happen in Overlays.

#### libs

Custom YTT fuctions that might be used by the Overlays.

#### overlays

YTT overlays that customize the yaml manifests. For more details about TYY overlay, please refer to [this link](https://carvel.dev/ytt/#example:example-overlay-files)

#### values.star and values.yaml

Define the input validation funtion in `values.star`. Follow the `starlarks` language syntax in this file. Input validation is optional.

Define all the configurable values in `values.yaml`. These values will be used by overlay to customize the yaml manifests. Please don't include any image related information in values.yaml, those should follow a standardized format and be put into `imageInfo.yaml`.

#### imageInfo.yaml

Put all the information related to images used by the template in `imageInfo.yaml`. The structure of this file looks like

```yaml
#@data/values
#@overlay/match-child-defaults missing_ok=True
---
imageInfo:
imageRepository: <your-image-repository>
imagePullPolicy: IfNotPresent
images:
<image-name-1>:
imagePath: <image-path-1>
tag: <image-tag-1>
<image-name-2>:
imagePath: <image-path-2>
tag: <image-tag-2>
...
```

The `<image-name-x>` should be exactly the same as the image names for your addon in TKR BOM.

### Makefile

The Makefile should follow the current examples. Change the following variables to match your addon.

* `IMG_CATEGORY := csi`
* `IMG_CLUSTER_TYPE := management workload` (What types of cluster should the addon run on)
* `ADDON_NAME := vsphere-csi`
* `IMG_NAME ?= vsphere-csi-templates`

## Template image and BOM

After the template is successfully created, you need to change two files to make sure the template image and BOM contents are correctly generated.

### ./Makefile

* After line 19, add the newly added template image name `<ADDON_NAME>_TEMPLATES_IMAGE_NAME ?= <addon-name>-templates`
* In `Addon templates` section, follow the examples to add the new addon to all three targets, which are `build-addon-template-images`, `save-addon-template-images` and `push-addon-template-images`

### ./bom/Makefile

In line 8 of `./bom/Makefile` add your newly added `ADDON_NAME` to the list of `OBJECTS`
### Tanzu Addons Manager

Tanzu Addons Manager manages the lifecycle of core addons like CNI, CPI, CSI, etc. It utilizes Kapp-controller's [packaging API](https://carvel.dev/kapp-controller/docs/latest/packaging/) and [App CR](https://carvel.dev/kapp-controller/docs/latest/app-spec/) to do the core addons lifecycle management.

#### Watch
Tanzu Addons Manager watches the following
- Addons secret
- Cluster CR
- Kubeadm control plane
- BOM configmap

#### Workflow of Tanzu Addons Manager
1. receives a request
2. reconciles the core package repository according to the TKR BOM configmap of the cluster
3. reconciles all the addons secrets
1. If it's a remote app (App CR that lives in one cluster but deploys resources in another cluster)
- Creates/updates addon data values secret on mgmt cluster
- Get the remote cluster kubeconfig
- Create/updates remote App CR in mgmt cluster that deploys resources in a remote cluster
2. If it's not a remote app
- Creates/updates addon data values secret on the cluster that the addons secret points to
- Creates/updates packageInstall CR on the cluster that the addons secret points to

0 comments on commit 3941ddc

Please sign in to comment.