Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Initial commit of labelSelector support for ClusterDecisionResource (#…
Browse files Browse the repository at this point in the history
…272)

* Initial commit of labelSelector support for ClusterDecisionResource

Signed-off-by: Joshua Packer <jpacker@redhat.com>

* Update role documentation for labelSelector change

Signed-off-by: Joshua Packer <jpacker@redhat.com>

* Apply lint changes

Signed-off-by: Joshua Packer <jpacker@redhat.com>
  • Loading branch information
jnpacker authored Jun 22, 2021
1 parent 8d3fa24 commit 2da3206
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 55 deletions.
7 changes: 4 additions & 3 deletions api/v1alpha1/applicationset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ type DuckTypeGenerator struct {
// this includes apiVersion(group/version), kind, matchKey and validation settings
// Name is the resource name of the kind, group and version, defined in the ConfigMapRef
// RequeueAfterSeconds is how long before the duckType will be rechecked for a change
ConfigMapRef string `json:"configMapRef"`
Name string `json:"name"`
RequeueAfterSeconds *int64 `json:"requeueAfterSeconds,omitempty"`
ConfigMapRef string `json:"configMapRef"`
Name string `json:"name,omitempty"`
RequeueAfterSeconds *int64 `json:"requeueAfterSeconds,omitempty"`
LabelSelector metav1.LabelSelector `json:"labelSelector,omitempty"`

Template ApplicationSetTemplate `json:"template,omitempty"`
// Values contains key/value pairs which are passed directly as parameters to the template
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion docs/Generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,16 @@ spec:
generators:
- clusterDecisionResource:
configMapRef: my-configmap # ConfigMap with GVK information for the duck type resource
name: quak # The name of the resource
name: quak # Choose either "name" of the resource or "labelSelector"
labelSelector:
matchLabels: # OPTIONAL
duck: spotted
matchExpression: # OPTIONAL
- key: duck
operator: In
values:
- "spotted"
- "canvasback"
requeueAfterSeconds: 60 # OPTIONAL: Checks for changes every 60sec (default 3min)
template:
metadata:
Expand Down
4 changes: 2 additions & 2 deletions examples/clusterDecisionResource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ data:

# 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 `get` the `placementdecisions` resources, from apiGroups `cluster.open-cluster-management.io/v1alpha1`
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`
```yaml
- apiGroups:
- "cluster.open-cluster-management.io/v1alpha1"
resources:
- placementdecisions
verbs:
- get
- list
```
3. Apply the following controller and associated ManagedCluster CRD's:
https://github.com/open-cluster-management/placement
Expand Down
104 changes: 102 additions & 2 deletions manifests/crds/argoproj.io_applicationsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,54 @@ spec:
is how long before the duckType will be rechecked for
a change
type: string
labelSelector:
description: A label selector is a label query over a set
of resources. The result of matchLabels and matchExpressions
are ANDed. An empty label selector matches all objects.
A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that
relates the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In,
NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values.
If the operator is In or NotIn, the values array
must be non-empty. If the operator is Exists
or DoesNotExist, the values array must be empty.
This array is replaced during a strategic merge
patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs.
A single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field
is "key", the operator is "In", and the values array
contains only "value". The requirements are ANDed.
type: object
type: object
name:
type: string
requeueAfterSeconds:
Expand Down Expand Up @@ -464,7 +512,6 @@ spec:
type: object
required:
- configMapRef
- name
type: object
clusters:
description: ClusterGenerator defines a generator to match against
Expand Down Expand Up @@ -1789,6 +1836,60 @@ spec:
is how long before the duckType will be rechecked
for a change
type: string
labelSelector:
description: A label selector is a label query
over a set of resources. The result of matchLabels
and matchExpressions are ANDed. An empty label
selector matches all objects. A null label selector
matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of
label selector requirements. The requirements
are ANDed.
items:
description: A label selector requirement
is a selector that contains values, a
key, and an operator that relates the
key and values.
properties:
key:
description: key is the label key that
the selector applies to.
type: string
operator:
description: operator represents a key's
relationship to a set of values. Valid
operators are In, NotIn, Exists and
DoesNotExist.
type: string
values:
description: values is an array of string
values. If the operator is In or NotIn,
the values array must be non-empty.
If the operator is Exists or DoesNotExist,
the values array must be empty. This
array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value}
pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions,
whose key field is "key", the operator is
"In", and the values array contains only
"value". The requirements are ANDed.
type: object
type: object
name:
type: string
requeueAfterSeconds:
Expand Down Expand Up @@ -2229,7 +2330,6 @@ spec:
type: object
required:
- configMapRef
- name
type: object
clusters:
description: ClusterGenerator defines a generator
Expand Down
62 changes: 60 additions & 2 deletions manifests/install-with-argo-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,36 @@ spec:
configMapRef:
description: ConfigMapRef is a ConfigMap with the duck type definitions needed to retreive the data this includes apiVersion(group/version), kind, matchKey and validation settings Name is the resource name of the kind, group and version, defined in the ConfigMapRef RequeueAfterSeconds is how long before the duckType will be rechecked for a change
type: string
labelSelector:
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
name:
type: string
requeueAfterSeconds:
Expand Down Expand Up @@ -2132,7 +2162,6 @@ spec:
type: object
required:
- configMapRef
- name
type: object
clusters:
description: ClusterGenerator defines a generator to match against clusters registered with ArgoCD.
Expand Down Expand Up @@ -3188,6 +3217,36 @@ spec:
configMapRef:
description: ConfigMapRef is a ConfigMap with the duck type definitions needed to retreive the data this includes apiVersion(group/version), kind, matchKey and validation settings Name is the resource name of the kind, group and version, defined in the ConfigMapRef RequeueAfterSeconds is how long before the duckType will be rechecked for a change
type: string
labelSelector:
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
properties:
key:
description: key is the label key that the selector applies to.
type: string
operator:
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
type: object
type: object
name:
type: string
requeueAfterSeconds:
Expand Down Expand Up @@ -3515,7 +3574,6 @@ spec:
type: object
required:
- configMapRef
- name
type: object
clusters:
description: ClusterGenerator defines a generator to match against clusters registered with ArgoCD.
Expand Down
Loading

0 comments on commit 2da3206

Please sign in to comment.