Skip to content

Commit 980cb1e

Browse files
authored
feat: Add watch selector support to controller manager: Merge pull request #575 from a-hilaly/watch-selectors
feat: Add watch selector support to controller manager
2 parents 8960b99 + 00ed5f5 commit 980cb1e

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

templates/cmd/controller/main.go.tpl

+11-2
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,20 @@ func main() {
107107
for _, namespace := range namespaces {
108108
watchNamespaces[namespace] = ctrlrtcache.Config{}
109109
}
110+
watchSelectors, err := ackCfg.ParseWatchSelectors()
111+
if err != nil {
112+
setupLog.Error(
113+
err, "Unable to parse watch selectors.",
114+
"aws.service", awsServiceAlias,
115+
)
116+
os.Exit(1)
117+
}
110118
mgr, err := ctrlrt.NewManager(ctrlrt.GetConfigOrDie(), ctrlrt.Options{
111119
Scheme: scheme,
112120
Cache: ctrlrtcache.Options{
113-
Scheme: scheme,
114-
DefaultNamespaces: watchNamespaces,
121+
Scheme: scheme,
122+
DefaultNamespaces: watchNamespaces,
123+
DefaultLabelSelector: watchSelectors,
115124
},
116125
WebhookServer: &ctrlrtwebhook.DefaultServer{
117126
Options: ctrlrtwebhook.Options{

templates/helm/templates/deployment.yaml.tpl

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ spec:
5757
- "$(ACK_RESOURCE_TAGS)"
5858
- --watch-namespace
5959
- "$(ACK_WATCH_NAMESPACE)"
60+
- --watch-selectors
61+
- "$(ACK_WATCH_SELECTORS)"
6062
- --deletion-policy
6163
- "$(DELETION_POLICY)"
6264
{{ "{{- if .Values.leaderElection.enabled }}" }}
@@ -103,6 +105,8 @@ spec:
103105
value: {{ "{{ .Values.aws.endpoint_url | quote }}" }}
104106
- name: ACK_WATCH_NAMESPACE
105107
value: {{ IncludeTemplate "watch-namespace" }}
108+
- name: ACK_WATCH_SELECTORS
109+
value: {{ "{{ .Values.watchSelectors }}" }}
106110
- name: DELETION_POLICY
107111
value: {{ "{{ .Values.deletionPolicy }}" }}
108112
- name: LEADER_ELECTION_NAMESPACE

templates/helm/values.schema.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@
210210
},
211211
"watchNamespace": {
212212
"type": "string"
213-
},
213+
},
214+
"watchSelectors": {
215+
"type": "string"
216+
},
214217
"resourceTags": {
215218
"type": "array",
216219
"items": {

templates/helm/values.yaml.tpl

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ installScope: cluster
110110
# You can set multiple namespaces by providing a comma separated list of namespaces. e.g "namespace1,namespace2"
111111
watchNamespace: ""
112112

113+
# Set the value of labelsSelectors to be used by the controller to filter the resources to watch.
114+
# You can set multiple labelsSelectors by providing a comma separated list of a=b arguments. e.g "label1=value1,label2=value2"
115+
watchSelectors: ""
116+
113117
resourceTags:
114118
# Configures the ACK service controller to always set key/value pairs tags on
115119
# resources that it manages.

0 commit comments

Comments
 (0)