Iterating on a core package #2693
Replies: 2 comments
-
first of all - thank you for writing this up. i work on the pinniped package and definitely have this same development workflow conundrum.
i wrote a script that pushes the in-tree pinniped package and patches it into the cluster. i do this (roughly) by:
this script is extremely janky. i think i like your way better. i am going to try it out.
i wonder if tce could offer a one-shot script or Makefile target to do what you outlined above 😏 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the write up! The addons team will think about all the challenges faced by the developers and try to come up with something more developer friendly during code orange. The current situation is mainly caused by the following two considerations:
We understand the pain points and will circle back when we have something solid. To answer the questions
|
Beta Was this translation helpful? Give feedback.
-
Development workflow for core packages
What we're trying to accomplish
When making changes to a core package that is involved in bootstrap, it is difficult to verify the changes will have the desired effects until the changes are committed, merged, and integrated into a build. The TKR is an output of this build process, and the TKR describes what packages shall be installed into a bootstrapped cluster. Building and injecting a modified TKR into the deploy of a cluster is a non trivial process that we've not found an easy way to do. One issue is that the Core package repo is not a part of TCE. As an alternative to building a TKR, these notes attempt to document processes for iterating on changes to a core package, building and deploying. An important part to be verified is that the changes made to a package will have the desired effect during bootstrap.
There are simpler ways to experiment with changes to a core package that are not explained here i.e. pausing a PackageInstall and editing its components on a live cluster. The described workflow attempts to more completely validate changes to a package, incorporating more tooling, and testing the boostrap lifecycle. This gives increased confidence the package changes work as desired.
3 Phases of package deployment
The deployment of Packages to a new management cluster can be described in 3 phases. Included in the packages deployed are the CNI, CPI, kapp-controller, tanzu-addons-manager, and various other controllers.
Each of the phases results in the same packages and configuration on the cluster, but each phase accomplishes it in different ways. Difficultly begins when attempting to change the packages i.e a later phase can end up overwriting an attempted modification.
Phase 1
When the tanzu CLI is invoked, templates are written to
~/.config/tanzu
, then values are interpolated, producing a set of yaml documents describing how the bootstrap cluster should set up the management cluster. Some of these documents are ClusterResourceSets (CRS) which contain Deployments and DaemonSets making up the CNI, CPI, kapp-controller etc.The CRSs are applied to the bootstrap cluster, which in turn applies the CNI, CPI, kapp-controller, etc. specified by the CRSs, to the new management cluster. Templates in
~/.config/tanzu/tkg/providers/
are vendir'd from actual packages in TCE, so that these DaemonSets and Deployments are configured similarly to the way that kapp-controller will deploy them in the next phase, but they're not yet specified by PackageInstalls, nor managed by kapp-controller.Historically, this process is similar to how core components were installed. However, packages are layered on top of these components today.
The set of yaml documents copied from the local CLI machine also contain the TKR, which contains information that will later be used to derive PackageInstalls. It may be tempting to modify this TKR by editing its template in
~/.config/tanzu
before invoking the CLI, but it is ineffectual because it is overwritten in Phase 3.Phase 2
The tanzu-addons-manager running on the management cluster, deployed in phase 1, consumes the TKR and translates the contents into PackageInstalls. At this point kapp-controller reconciles the PackageInstalls into the DaemonSets and Deployments that were deployed in phase 1. The management-cluster has now pivoted, and now kapp-controller and tanzu-addons-manager are now managing the CNI and CPI as PackageInstalls.
Phase 3
In this phase, the tkr-controller-manager is now able to start, now that the CNI is initialized and running. The tkr-controller-manager is configured to download the TKR image bundle from an image repository. Once retrieved, it overwrites the TKR written in the first phase. The downloaded TKR, of course, does not contain any of the modifications that may have been done on the machine where the CLI is running. The tanzu-addons-manager then rewrites the PackageInstalls written in phase 2 so that the cluster conforms to the downloaded TKR.
A workflow we came up with
The following is an example of the process that can be use to iterate on a modification to the antrea cni core package. This change is to add an annotation to the antrea DaemonSet. Also, for the sake of this example, the assumption is that the change to the DaemonSet will have some effect on the behavior of the package/cluster.
The workflow described takes advantage of of one the behaviors of the tanzu-addons-manager. One of its responsibilities is to write PackageInstalls. The PackageInstalls the tanzu-addons-manager writes do not have specific version information. kapp-controller reconciles the PackageInstalls and uses the highest versioned available Package matching the PackageInstall.
On an existing cluster, perform the following steps to iterate on building and deploying a modified package version on a running cluster.
antrea.yaml
file.spec.refName
andspec.version
of the package with some higher dev version: e.g0.13.4-dev
. Perhaps there is a better versioning scheme to use for development packages that doesn't bump the minor, but this is what worked.imgpkgBundle.image
to use the image just pushed in the previous step.Deploy a cluster with the updated package
Once satisfied with the package modifications on running cluster, deploy a new management cluster with the updated package, so that the behavior of the modified package can be verified to work at bootstrap time. To get the updated Package onto a newly created cluster, create a ClusterResourceSet and Secret.
~/.config/tanzu
directoryspec.version
is higher than what is specified in the TKR. In this example, create the following yaml file at~/.config/tanzu/tkg/providers/ytt/04_user_customizations/antra_dev_package.yaml
with this content:SUPPRESS_PROVIDERS_UPDATE
environment variable to prevent the cli from overwriting the customizations.Questions we have
Beta Was this translation helpful? Give feedback.
All reactions