Skip to content

Commit 6aade29

Browse files
committed
fix(config): install Image Updater into argocd namespace by default
Signed-off-by: dkarpele <karpelevich@gmail.com>
1 parent 005a7bc commit 6aade29

18 files changed

+116
-62
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
IMAGE_UPDATER_CONTROLLER_NAMESPACE?=argocd
12
IMAGE_NAMESPACE?=quay.io/argoprojlabs
23
IMAGE_NAME=argocd-image-updater
34
ifdef IMAGE_NAMESPACE
@@ -196,11 +197,11 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
196197
.PHONY: deploy
197198
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
198199
cd config/manager && $(KUSTOMIZE) edit set image argocd-image-updater-controller=${IMG}
199-
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
200+
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -n ${IMAGE_UPDATER_CONTROLLER_NAMESPACE} -f -
200201

201202
.PHONY: undeploy
202203
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
203-
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
204+
$(KUSTOMIZE) build config/default | $(KUBECTL) delete -n ${IMAGE_UPDATER_CONTROLLER_NAMESPACE} --ignore-not-found=$(ignore-not-found) -f -
204205

205206
##@ Dependencies
206207

cmd/run.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,16 @@ This enables a CRD-driven approach to automated image updates with Argo CD.
9999
WithValues(logrusFieldsToLogrValues(common.ControllerLogFields)...)
100100

101101
setupLogger.Info("Controller runtime logger initialized.", "setAppLogLevel", cfg.LogLevel)
102-
setupLogger.Info("starting",
103-
"app", version.BinaryName()+": "+version.Version(),
102+
logFields := []interface{}{
103+
"app", version.BinaryName() + ": " + version.Version(),
104104
"loglevel", strings.ToUpper(cfg.LogLevel),
105105
"interval", argocd.GetPrintableInterval(cfg.CheckInterval),
106106
"healthPort", probeAddr,
107-
)
107+
}
108+
if cfg.ArgocdNamespace != "" {
109+
logFields = append(logFields, "argocdNamespace", cfg.ArgocdNamespace)
110+
}
111+
setupLogger.Info("starting", logFields...)
108112

109113
// Create context with signal handling
110114
ctx := ctrl.SetupSignalHandler()
@@ -285,7 +289,7 @@ This enables a CRD-driven approach to automated image updates with Argo CD.
285289
controllerCmd.Flags().StringVar(&cfg.RegistriesConf, "registries-conf-path", common.DefaultRegistriesConfPath, "path to registries configuration file")
286290
controllerCmd.Flags().IntVar(&cfg.MaxConcurrentApps, "max-concurrent-apps", env.ParseNumFromEnv("MAX_CONCURRENT_APPS", 10, 1, 100), "maximum number of ArgoCD applications that can be updated concurrently (must be >= 1)")
287291
controllerCmd.Flags().IntVar(&MaxConcurrentReconciles, "max-concurrent-reconciles", env.ParseNumFromEnv("MAX_CONCURRENT_RECONCILES", 1, 1, 10), "maximum number of concurrent Reconciles which can be run (must be >= 1)")
288-
controllerCmd.Flags().StringVar(&cfg.ArgocdNamespace, "argocd-namespace", "", "namespace where ArgoCD runs in (current namespace by default)")
292+
controllerCmd.Flags().StringVar(&cfg.ArgocdNamespace, "argocd-namespace", env.GetStringVal("ARGOCD_NAMESPACE", ""), "namespace where ArgoCD runs in (controller's namespace by default)")
289293
controllerCmd.Flags().BoolVar(&warmUpCache, "warmup-cache", true, "whether to perform a cache warm-up on startup")
290294
controllerCmd.Flags().BoolVar(&cfg.DisableKubeEvents, "disable-kube-events", env.GetBoolVal("IMAGE_UPDATER_KUBE_EVENTS", false), "Disable kubernetes events")
291295

cmd/run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestNewRunCommand(t *testing.T) {
4949
asser.Equal(common.DefaultRegistriesConfPath, controllerCommand.Flag("registries-conf-path").Value.String())
5050
asser.Equal(strconv.Itoa(env.ParseNumFromEnv("MAX_CONCURRENT_APPS", 10, 1, 100)), controllerCommand.Flag("max-concurrent-apps").Value.String())
5151
asser.Equal(strconv.Itoa(env.ParseNumFromEnv("MAX_CONCURRENT_RECONCILES", 1, 1, 10)), controllerCommand.Flag("max-concurrent-reconciles").Value.String())
52-
asser.Equal("", controllerCommand.Flag("argocd-namespace").Value.String())
52+
asser.Equal(env.GetStringVal("ARGOCD_NAMESPACE", ""), controllerCommand.Flag("argocd-namespace").Value.String())
5353
asser.Equal("true", controllerCommand.Flag("warmup-cache").Value.String())
5454
asser.Equal(env.GetStringVal("GIT_COMMIT_USER", "argocd-image-updater"), controllerCommand.Flag("git-commit-user").Value.String())
5555
asser.Equal(env.GetStringVal("GIT_COMMIT_EMAIL", "noreply@argoproj.io"), controllerCommand.Flag("git-commit-email").Value.String())

cmd/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Supported registries:
7474
webhookCmd.Flags().StringVar(&cfg.RegistriesConf, "registries-conf-path", common.DefaultRegistriesConfPath, "path to registries configuration file")
7575
webhookCmd.Flags().IntVar(&cfg.MaxConcurrentApps, "max-concurrent-apps", env.ParseNumFromEnv("MAX_CONCURRENT_APPS", 10, 1, 100), "maximum number of ArgoCD applications that can be updated concurrently (must be >= 1)")
7676
webhookCmd.Flags().IntVar(&MaxConcurrentUpdaters, "max-concurrent-updaters", env.ParseNumFromEnv("MAX_CONCURRENT_UPDATERS", 1, 1, 10), "maximum number of concurrent ImageUpdater CRs that can be processed (must be >= 1)")
77-
webhookCmd.Flags().StringVar(&cfg.ArgocdNamespace, "argocd-namespace", "", "namespace where ArgoCD runs in (current namespace by default)")
77+
webhookCmd.Flags().StringVar(&cfg.ArgocdNamespace, "argocd-namespace", env.GetStringVal("ARGOCD_NAMESPACE", ""), "namespace where ArgoCD runs in (controller's namespace by default)")
7878

7979
webhookCmd.Flags().StringVar(&cfg.GitCommitUser, "git-commit-user", env.GetStringVal("GIT_COMMIT_USER", "argocd-image-updater"), "Username to use for Git commits")
8080
webhookCmd.Flags().StringVar(&cfg.GitCommitMail, "git-commit-email", env.GetStringVal("GIT_COMMIT_EMAIL", "noreply@argoproj.io"), "E-Mail address to use for Git commits")

cmd/webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestNewWebhookCommand(t *testing.T) {
2929
asser.Equal(common.DefaultRegistriesConfPath, controllerCommand.Flag("registries-conf-path").Value.String())
3030
asser.Equal(strconv.Itoa(env.ParseNumFromEnv("MAX_CONCURRENT_APPS", 10, 1, 100)), controllerCommand.Flag("max-concurrent-apps").Value.String())
3131
asser.Equal(strconv.Itoa(env.ParseNumFromEnv("MAX_CONCURRENT_UPDATERS", 1, 1, 10)), controllerCommand.Flag("max-concurrent-updaters").Value.String())
32-
asser.Equal("", controllerCommand.Flag("argocd-namespace").Value.String())
32+
asser.Equal(env.GetStringVal("ARGOCD_NAMESPACE", ""), controllerCommand.Flag("argocd-namespace").Value.String())
3333
asser.Equal(env.GetStringVal("GIT_COMMIT_USER", "argocd-image-updater"), controllerCommand.Flag("git-commit-user").Value.String())
3434
asser.Equal(env.GetStringVal("GIT_COMMIT_EMAIL", "noreply@argoproj.io"), controllerCommand.Flag("git-commit-email").Value.String())
3535
asser.Equal(env.GetStringVal("GIT_COMMIT_SIGNING_KEY", ""), controllerCommand.Flag("git-commit-signing-key").Value.String())

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Adds namespace to all resources.
2-
namespace: argocd-image-updater-system
2+
#namespace: argocd-image-updater-system
33

44
# Labels to add to all resources and selectors.
55
#labels:

config/default/metrics_service.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ metadata:
66
app.kubernetes.io/name: argocd-image-updater
77
app.kubernetes.io/managed-by: kustomize
88
name: argocd-image-updater-controller-metrics-service
9-
namespace: argocd-image-updater-system
109
spec:
1110
ports:
1211
- name: https

config/install.yaml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
apiVersion: v1
2-
kind: Namespace
3-
metadata:
4-
labels:
5-
app.kubernetes.io/managed-by: kustomize
6-
app.kubernetes.io/name: argocd-image-updater-system
7-
control-plane: argocd-image-updater-controller
8-
metrics: enabled
9-
name: argocd-image-updater-system
10-
---
111
apiVersion: apiextensions.k8s.io/v1
122
kind: CustomResourceDefinition
133
metadata:
@@ -550,7 +540,6 @@ metadata:
550540
app.kubernetes.io/managed-by: kustomize
551541
app.kubernetes.io/name: argocd-image-updater
552542
name: argocd-image-updater-controller
553-
namespace: argocd-image-updater-system
554543
---
555544
apiVersion: rbac.authorization.k8s.io/v1
556545
kind: Role
@@ -560,7 +549,6 @@ metadata:
560549
app.kubernetes.io/name: argocd-image-updater
561550
app.kubernetes.io/part-of: argocd-image-updater
562551
name: argocd-image-updater
563-
namespace: argocd-image-updater-system
564552
rules:
565553
- apiGroups:
566554
- ""
@@ -579,7 +567,6 @@ metadata:
579567
app.kubernetes.io/managed-by: kustomize
580568
app.kubernetes.io/name: argocd-image-updater
581569
name: argocd-image-updater-leader-election-role
582-
namespace: argocd-image-updater-system
583570
rules:
584571
- apiGroups:
585572
- ""
@@ -697,15 +684,13 @@ metadata:
697684
app.kubernetes.io/name: argocd-image-updater
698685
app.kubernetes.io/part-of: argocd-image-updater
699686
name: argocd-image-updater
700-
namespace: argocd-image-updater-system
701687
roleRef:
702688
apiGroup: rbac.authorization.k8s.io
703689
kind: Role
704690
name: argocd-image-updater
705691
subjects:
706692
- kind: ServiceAccount
707693
name: argocd-image-updater-controller
708-
namespace: argocd-image-updater-system
709694
---
710695
apiVersion: rbac.authorization.k8s.io/v1
711696
kind: RoleBinding
@@ -714,15 +699,13 @@ metadata:
714699
app.kubernetes.io/managed-by: kustomize
715700
app.kubernetes.io/name: argocd-image-updater
716701
name: argocd-image-updater-leader-election-rolebinding
717-
namespace: argocd-image-updater-system
718702
roleRef:
719703
apiGroup: rbac.authorization.k8s.io
720704
kind: Role
721705
name: argocd-image-updater-leader-election-role
722706
subjects:
723707
- kind: ServiceAccount
724708
name: argocd-image-updater-controller
725-
namespace: argocd-image-updater-system
726709
---
727710
apiVersion: rbac.authorization.k8s.io/v1
728711
kind: ClusterRoleBinding
@@ -738,7 +721,7 @@ roleRef:
738721
subjects:
739722
- kind: ServiceAccount
740723
name: argocd-image-updater-controller
741-
namespace: argocd-image-updater-system
724+
namespace: argocd
742725
---
743726
apiVersion: rbac.authorization.k8s.io/v1
744727
kind: ClusterRoleBinding
@@ -751,7 +734,7 @@ roleRef:
751734
subjects:
752735
- kind: ServiceAccount
753736
name: argocd-image-updater-controller
754-
namespace: argocd-image-updater-system
737+
namespace: argocd
755738
---
756739
apiVersion: rbac.authorization.k8s.io/v1
757740
kind: ClusterRoleBinding
@@ -764,7 +747,7 @@ roleRef:
764747
subjects:
765748
- kind: ServiceAccount
766749
name: argocd-image-updater-controller
767-
namespace: argocd-image-updater-system
750+
namespace: argocd
768751
---
769752
apiVersion: v1
770753
kind: ConfigMap
@@ -773,7 +756,6 @@ metadata:
773756
app.kubernetes.io/name: argocd-image-updater-config
774757
app.kubernetes.io/part-of: argocd-image-updater-controller
775758
name: argocd-image-updater-config
776-
namespace: argocd-image-updater-system
777759
---
778760
apiVersion: v1
779761
kind: ConfigMap
@@ -782,7 +764,6 @@ metadata:
782764
app.kubernetes.io/name: argocd-image-updater-ssh-config
783765
app.kubernetes.io/part-of: argocd-image-updater-controller
784766
name: argocd-image-updater-ssh-config
785-
namespace: argocd-image-updater-system
786767
---
787768
apiVersion: v1
788769
kind: Secret
@@ -791,7 +772,6 @@ metadata:
791772
app.kubernetes.io/name: argocd-image-updater-secret
792773
app.kubernetes.io/part-of: argocd-image-updater-controller
793774
name: argocd-image-updater-secret
794-
namespace: argocd-image-updater-system
795775
---
796776
apiVersion: v1
797777
kind: Service
@@ -801,7 +781,6 @@ metadata:
801781
app.kubernetes.io/name: argocd-image-updater
802782
control-plane: argocd-image-updater-controller
803783
name: argocd-image-updater-controller-metrics-service
804-
namespace: argocd-image-updater-system
805784
spec:
806785
ports:
807786
- name: https
@@ -819,7 +798,6 @@ metadata:
819798
app.kubernetes.io/name: argocd-image-updater-controller
820799
control-plane: argocd-image-updater-controller
821800
name: argocd-image-updater-controller
822-
namespace: argocd-image-updater-system
823801
spec:
824802
replicas: 1
825803
selector:
@@ -840,6 +818,12 @@ spec:
840818
command:
841819
- /manager
842820
env:
821+
- name: ARGOCD_NAMESPACE
822+
valueFrom:
823+
configMapKeyRef:
824+
key: argocd.namespace
825+
name: argocd-image-updater-config
826+
optional: true
843827
- name: IMAGE_UPDATER_INTERVAL
844828
valueFrom:
845829
configMapKeyRef:
@@ -1028,7 +1012,6 @@ metadata:
10281012
app.kubernetes.io/name: argocd-image-updater-controller
10291013
control-plane: argocd-image-updater-controller
10301014
name: allow-metrics-traffic
1031-
namespace: argocd-image-updater-system
10321015
spec:
10331016
ingress:
10341017
- from:

config/manager/manager.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
apiVersion: v1
2-
kind: Namespace
3-
metadata:
4-
labels:
5-
control-plane: argocd-image-updater-controller
6-
app.kubernetes.io/name: argocd-image-updater-system
7-
app.kubernetes.io/managed-by: kustomize
8-
metrics: enabled
9-
name: argocd-image-updater-system
10-
---
111
apiVersion: apps/v1
122
kind: Deployment
133
metadata:
144
name: argocd-image-updater-controller
15-
namespace: argocd-image-updater-system
165
labels:
176
control-plane: argocd-image-updater-controller
187
app.kubernetes.io/name: argocd-image-updater-controller
@@ -65,8 +54,15 @@ spec:
6554
args:
6655
- run
6756
image: argocd-image-updater-controller:latest
57+
imagePullPolicy: IfNotPresent
6858
name: argocd-image-updater-controller
6959
env:
60+
- name: ARGOCD_NAMESPACE
61+
valueFrom:
62+
configMapKeyRef:
63+
name: argocd-image-updater-config
64+
key: argocd.namespace
65+
optional: true
7066
- name: IMAGE_UPDATER_INTERVAL
7167
valueFrom:
7268
configMapKeyRef:

config/network-policy/allow-metrics-traffic.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ metadata:
99
app.kubernetes.io/name: argocd-image-updater-controller
1010
app.kubernetes.io/managed-by: kustomize
1111
name: allow-metrics-traffic
12-
namespace: argocd-image-updater-system
1312
spec:
1413
podSelector:
1514
matchLabels:

0 commit comments

Comments
 (0)