Files
Radon Rosborough 944eaddd8d feat(appset): add support for missingkey=error in ApplicationSets (#13731) (#13733)
* Add support for missingkey=error in ApplicationSets

Signed-off-by: Radon Rosborough <rrosborough@plaid.com>

* options for cluster generator too

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

---------

Signed-off-by: Radon Rosborough <rrosborough@plaid.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
2023-05-30 11:41:29 -04:00
..

How the Cluster Decision Resource generator works for clusterDecisionResource

  1. The Cluster Decision Resource generator reads a configurable status format:
status:
  clusters:
  - name: cluster-01
  - name: cluster-02

This is a common status format. Another format that could be read looks like this:

status:
  decisions:
  - clusterName: cluster-01
    namespace: cluster-01
  - clusterName: cluster-02
    namespace: cluster-02
  1. Any resource that has a list of key / value pairs, where the value matches ArgoCD cluster names can be used.
  2. The key / value pairs found in each element of the list will be available to the template. As well, name and server will still be available to the template.
  3. The Service Account used by the ApplicationSet controller must have access to Get the resource you want to retrieve the duck type definition from
  4. A configMap is used to identify the resource to read status of generated ArgoCD clusters from. You can use multiple resources by creating a ConfigMap for each one in the ArgoCD namespace.
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  apiVersion: group.io/v1
  kind: mykinds
  statusListKey: clusters
  matchKey: name
  • apiVersion - This is the apiVersion of your resource
  • kind - This is the plural kind of your resource
  • statusListKey - Default is 'clusters', this is the key found in your resource's status that is a list of ArgoCD clusters.
  • matchKey - Is the key name found in the cluster list, name and clusterName are the keys in the examples above.

Applying the example

  1. Connect to a cluster with the ApplicationSet controller running
  2. Edit the Role for the ApplicationSet service account, and grant it permission to list the placementdecisions resources, from apiGroups cluster.open-cluster-management.io/v1alpha1
- apiGroups:
  - "cluster.open-cluster-management.io/v1alpha1"
  resources:
  - placementdecisions
  verbs:
  - list
  1. Apply the following controller and associated ManagedCluster CRD's: https://github.com/open-cluster-management/placement
  2. Now apply the PlacementDecision and an ApplicationSet:
kubectl apply -f ./placementdecision.yaml
kubectl apply -f ./configMap.yaml
kubectl apply -f ./ducktype-example.yaml
  1. For now this won't do anything until you create a controller that populates the Status.Decisions array.