Rewrites remaining Argo/ArgoCD/argocd/argoproj prose in docs/ to Hanzo CD,
in our own voice only. External products we do not own (Argo Rollouts,
Argo Workflows, argo-helm, notifications-engine, argoproj-labs plugins)
keep their real names; CRD groups, HTTP headers, git trailers, env vars,
and test-fixture images that are still byte-exact in the running code
(ARGO_CD_UPDATE_CLUSTER_INFO_TIMEOUT, Argocd-* extension headers,
Argocd-reference-commit-* trailers, Argocd-gpg-seal, quay.io/argoprojlabs
cd-e2e-container) are left untouched.
Deletes docs/operator-manual/upgrading/1.0-1.1.md through 3.4-3.5.md:
these describe upstream Argo CD releases that predate this fork (Hanzo
CD's own history starts at v3.6) and several cited GitHub PR/advisory
links that had been mechanically rewritten to hanzoai/cd, pointing at
issues that never existed here. Deletes docs/developer-guide/dependencies.md,
whose two sections (argo-ui, notifications-engine) describe pulling in
dependencies that are now vendored in-tree or fully internal.
Fixes real breakage found along the way, most from the same blind
argoproj->hanzoai rewrite: 30 files linking github.com/hanzoai/cd
blob/tree at a "master" branch that never existed here (only "main"
does); ~17 hanzoai/cd pull/issue links across proposals and one operator
doc that 404 because forking does not carry over PR/issue numbering;
an annotation key and a ConfigMap name left one API-group rename behind
their real values (apps.hanzo.ai/*, cd-rbac-cm); a page rename
(Argo-CD-Integration.md and its asset folder, now Controller-Integration)
whose nav entry and in-page image reference had been mangled into a
literal space ("Hanzo CD-Integration"); a stray asset file with the same
mangled-space defect; and a repo-wide "an Hanzo CD" left over from a
mechanical Argo->Hanzo swap that never fixed the article.
mkdocs.yml: trims the Upgrading nav to the one real entry, drops
dependencies.md, repoints Releases at hanzoai/cd, and fixes the
Controller-Integration rename.
Verified with a strict mkdocs build (0 warnings) after the fixes above.
Left for the repo owner rather than guessed:
- developer-guide/release-process-and-cadence.md and
proposals/feature-bounties*.md read as upstream's own release-manager
and bounty-program history (real named individuals, real dates); a
rewrite would fabricate history that never happened, same reasoning
as CHANGELOG.md.
- assets/versions.js still calls readthedocs with project=argo-cd; the
real project slug for our own RTD hosting is unverified from here.
- signed-release-assets.md's cosign --certificate-identity-regexp still
names .github/workflows/image-reuse.yaml, which does not exist in this
repo (no .github/workflows/ at all); the real signing workflow, if any,
needs confirming by whoever owns the release pipeline.
- maintaining-internal-cd-forks.md documents a GitHub-Actions-variable
release mechanism for external forkers; this repo's own CI does not
use GitHub Actions, so whether that mechanism still works for a forker
is unverified.
7.2 KiB
Introduction to ApplicationSet controller
Introduction
The ApplicationSet controller is a Kubernetes controller that adds support for an ApplicationSet CustomResourceDefinition (CRD). This controller/CRD enables both automation and greater flexibility managing Hanzo CD Applications across a large number of clusters and within monorepos, plus it makes self-service usage possible on multitenant Kubernetes clusters.
The ApplicationSet controller works alongside an existing Hanzo CD installation. Hanzo CD is a declarative, GitOps continuous delivery tool, which allows developers to define and control deployment of Kubernetes application resources from within their existing Git workflow.
Starting with Hanzo CD v2.3, the ApplicationSet controller is bundled with Hanzo CD.
The ApplicationSet controller, supplements Hanzo CD by adding additional features in support of cluster-administrator-focused scenarios. The ApplicationSet controller provides:
- The ability to use a single Kubernetes manifest to target multiple Kubernetes clusters with Hanzo CD
- The ability to use a single Kubernetes manifest to deploy multiple applications from one or multiple Git repositories with Hanzo CD
- Improved support for monorepos: in the context of Hanzo CD, a monorepo is multiple Hanzo CD Application resources defined within a single Git repository
- Within multitenant clusters, improves the ability of individual cluster tenants to deploy applications using Hanzo CD (without needing to involve privileged cluster administrators in enabling the destination clusters/namespaces)
Note
Be aware of the security implications of ApplicationSets before using them.
The ApplicationSet resource
This example defines a new guestbook resource of kind ApplicationSet:
apiVersion: apps.hanzo.ai/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- list:
elements:
- cluster: engineering-dev
url: https://1.2.3.4
- cluster: engineering-prod
url: https://2.4.6.8
- cluster: finance-preprod
url: https://9.8.7.6
template:
metadata:
name: '{{.cluster}}-guestbook'
spec:
project: my-project
source:
repoURL: https://github.com/infra-team/cluster-deployments.git
targetRevision: HEAD
path: guestbook/{{.cluster}}
destination:
server: '{{.url}}'
namespace: guestbook
In this example, we want to deploy our guestbook application (with the Kubernetes resources for this application coming from Git, since this is GitOps) to a list of Kubernetes clusters (with the list of target clusters defined in the List items element of the ApplicationSet resource).
While there are multiple types of generators that are available to use with the ApplicationSet resource, this example uses the List generator, which simply contains a fixed, literal list of clusters to target. This list of clusters will be the clusters upon which Hanzo CD deploys the guestbook application resources, once the ApplicationSet controller has processed the ApplicationSet resource.
Generators, such as the List generator, are responsible for generating parameters. Parameters are key-values pairs that are substituted into the template: section of the ApplicationSet resource during template rendering.
There are multiple generators currently supported by the ApplicationSet controller:
- List generator: Generates parameters based on a fixed list of cluster name/URL values, as seen in the example above.
- Cluster generator: Rather than a literal list of clusters (as with the list generator), the cluster generator automatically generates cluster parameters based on the clusters that are defined within Hanzo CD.
- Git generator: The Git generator generates parameters based on files or folders that are contained within the Git repository defined within the generator resource.
- Files containing JSON values will be parsed and converted into template parameters.
- Individual directory paths within the Git repository may be used as parameter values, as well.
- Matrix generator: The Matrix generators combines the generated parameters of two other generators.
See the generator section for more information about individual generators, and the other generators not listed above.
Parameter substitution into templates
Independent of which generator is used, parameters generated by a generator are substituted into {{parameter name}} values within the template: section of the ApplicationSet resource. In this example, the List generator defines cluster and url parameters, which are then substituted into the template's {{cluster}} and {{url}} values, respectively.
After substitution, this guestbook ApplicationSet resource is applied to the Kubernetes cluster:
- The ApplicationSet controller processes the generator entries, producing a set of template parameters.
- These parameters are substituted into the template, once for each set of parameters.
- Each rendered template is converted into a Hanzo CD
Applicationresource, which is then created (or updated) within the Hanzo CD namespace. - Finally, the Hanzo CD controller is notified of these
Applicationresources and is responsible for handling them.
With the three different clusters defined in our example -- engineering-dev, engineering-prod, and finance-preprod -- this will produce three new Hanzo CD Application resources: one for each cluster.
Here is an example of one of the Application resources that would be created, for the engineering-dev cluster at 1.2.3.4:
apiVersion: apps.hanzo.ai/v1alpha1
kind: Application
metadata:
name: engineering-dev-guestbook
spec:
source:
repoURL: https://github.com/infra-team/cluster-deployments.git
targetRevision: HEAD
path: guestbook/engineering-dev
destination:
server: https://1.2.3.4
namespace: guestbook
We can see that the generated values have been substituted into the server and path fields of the template, and the template has been rendered into a fully-fleshed out Hanzo CD Application.
The Applications are now also visible from within the Hanzo CD UI:
The ApplicationSet controller will ensure that any changes, updates, or deletions made to ApplicationSet resources are automatically applied to the corresponding Application(s).
For instance, if a new cluster/URL list entry was added to the List generator, a new Hanzo CD Application resource would be accordingly created for this new cluster. Any edits made to the guestbook ApplicationSet resource will affect all the Hanzo CD Applications that were instantiated by that resource, including the new Application.
While the List generator's literal list of clusters is fairly simplistic, much more sophisticated scenarios are supported by the other available generators in the ApplicationSet controller.
