Skip to content

Commit fb52a2a

Browse files
committed
feat(ImageUpdater): Add ImageUpdater controller
Signed-off-by: Denis Karpelevich <[email protected]>
1 parent ef71979 commit fb52a2a

File tree

14 files changed

+1421
-198
lines changed

14 files changed

+1421
-198
lines changed

api/v1beta1/argocd_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ type ArgoCDHASpec struct {
325325
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
326326
}
327327

328+
// ArgoCDImageUpdaterSpec defines whether the Argo CD Image Updater controller should be installed.
329+
type ArgoCDImageUpdaterSpec struct {
330+
// Enabled defines whether argocd image updater controller should be deployed or not
331+
Enabled bool `json:"enabled"`
332+
333+
// Env let you specify environment variables for ImageUpdater pods
334+
Env []corev1.EnvVar `json:"env,omitempty"`
335+
336+
// Resources defines the Compute Resources required by the container for Argo CD Image Updater.
337+
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
338+
}
339+
328340
// ArgoCDImportSpec defines the desired state for the ArgoCD import/restore process.
329341
type ArgoCDImportSpec struct {
330342
// Name of an ArgoCDExport from which to import data.
@@ -885,6 +897,9 @@ type ArgoCDSpec struct {
885897
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Image",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldGroup:ArgoCD","urn:alm:descriptor:com.tectonic.ui:text"}
886898
Image string `json:"image,omitempty"`
887899

900+
// ImageUpdater defines whether the Argo CD ImageUpdater controller should be installed.
901+
ImageUpdater ArgoCDImageUpdaterSpec `json:"imageUpdater,omitempty"`
902+
888903
// Import is the import/restore options for ArgoCD.
889904
Import *ArgoCDImportSpec `json:"import,omitempty"`
890905

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import (
5757
"sigs.k8s.io/controller-runtime/pkg/healthz"
5858
"sigs.k8s.io/controller-runtime/pkg/log/zap"
5959

60+
imageupdaterv1alpha1 "github.com/argoproj-labs/argocd-image-updater/api/v1alpha1"
6061
v1alpha1 "github.com/argoproj-labs/argocd-operator/api/v1alpha1"
6162
v1beta1 "github.com/argoproj-labs/argocd-operator/api/v1beta1"
6263
"github.com/argoproj-labs/argocd-operator/version"
@@ -73,6 +74,7 @@ func init() {
7374

7475
utilruntime.Must(v1alpha1.AddToScheme(scheme))
7576
utilruntime.Must(v1beta1.AddToScheme(scheme))
77+
utilruntime.Must(imageupdaterv1alpha1.AddToScheme(scheme))
7678
//+kubebuilder:scaffold:scheme
7779
}
7880

common/defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ vs-ssh.visualstudio.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7Hr1oTWqNqOlzGJOf
289289

290290
// ArgoCDAgentPrincipalDefaultImageName is the default image name for the ArgoCD agent principal.
291291
ArgoCDAgentPrincipalDefaultImageName = "quay.io/argoprojlabs/argocd-agent:v0.3.2"
292+
293+
// ArgoCDImageUpdaterControllerComponent is the name of the Image Updater controller control plane component
294+
ArgoCDImageUpdaterControllerComponent = "argocd-image-updater-controller"
292295
)
293296

294297
// DefaultLabels returns the default set of labels for controllers.

config/crd/bases/argoproj.io_argocds.yaml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16053,6 +16053,198 @@ spec:
1605316053
image:
1605416054
description: Image is the ArgoCD container image for all ArgoCD components.
1605516055
type: string
16056+
imageUpdater:
16057+
description: ImageUpdater defines whether the Argo CD ImageUpdater
16058+
controller should be installed.
16059+
properties:
16060+
enabled:
16061+
description: Enabled defines whether argocd image updater controller
16062+
should be deployed or not
16063+
type: boolean
16064+
env:
16065+
description: Env let you specify environment variables for ImageUpdater
16066+
pods
16067+
items:
16068+
description: EnvVar represents an environment variable present
16069+
in a Container.
16070+
properties:
16071+
name:
16072+
description: Name of the environment variable. Must be a
16073+
C_IDENTIFIER.
16074+
type: string
16075+
value:
16076+
description: |-
16077+
Variable references $(VAR_NAME) are expanded
16078+
using the previously defined environment variables in the container and
16079+
any service environment variables. If a variable cannot be resolved,
16080+
the reference in the input string will be unchanged. Double $$ are reduced
16081+
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
16082+
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
16083+
Escaped references will never be expanded, regardless of whether the variable
16084+
exists or not.
16085+
Defaults to "".
16086+
type: string
16087+
valueFrom:
16088+
description: Source for the environment variable's value.
16089+
Cannot be used if value is not empty.
16090+
properties:
16091+
configMapKeyRef:
16092+
description: Selects a key of a ConfigMap.
16093+
properties:
16094+
key:
16095+
description: The key to select.
16096+
type: string
16097+
name:
16098+
default: ""
16099+
description: |-
16100+
Name of the referent.
16101+
This field is effectively required, but due to backwards compatibility is
16102+
allowed to be empty. Instances of this type with an empty value here are
16103+
almost certainly wrong.
16104+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
16105+
type: string
16106+
optional:
16107+
description: Specify whether the ConfigMap or its
16108+
key must be defined
16109+
type: boolean
16110+
required:
16111+
- key
16112+
type: object
16113+
x-kubernetes-map-type: atomic
16114+
fieldRef:
16115+
description: |-
16116+
Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
16117+
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
16118+
properties:
16119+
apiVersion:
16120+
description: Version of the schema the FieldPath
16121+
is written in terms of, defaults to "v1".
16122+
type: string
16123+
fieldPath:
16124+
description: Path of the field to select in the
16125+
specified API version.
16126+
type: string
16127+
required:
16128+
- fieldPath
16129+
type: object
16130+
x-kubernetes-map-type: atomic
16131+
resourceFieldRef:
16132+
description: |-
16133+
Selects a resource of the container: only resources limits and requests
16134+
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
16135+
properties:
16136+
containerName:
16137+
description: 'Container name: required for volumes,
16138+
optional for env vars'
16139+
type: string
16140+
divisor:
16141+
anyOf:
16142+
- type: integer
16143+
- type: string
16144+
description: Specifies the output format of the
16145+
exposed resources, defaults to "1"
16146+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
16147+
x-kubernetes-int-or-string: true
16148+
resource:
16149+
description: 'Required: resource to select'
16150+
type: string
16151+
required:
16152+
- resource
16153+
type: object
16154+
x-kubernetes-map-type: atomic
16155+
secretKeyRef:
16156+
description: Selects a key of a secret in the pod's
16157+
namespace
16158+
properties:
16159+
key:
16160+
description: The key of the secret to select from. Must
16161+
be a valid secret key.
16162+
type: string
16163+
name:
16164+
default: ""
16165+
description: |-
16166+
Name of the referent.
16167+
This field is effectively required, but due to backwards compatibility is
16168+
allowed to be empty. Instances of this type with an empty value here are
16169+
almost certainly wrong.
16170+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
16171+
type: string
16172+
optional:
16173+
description: Specify whether the Secret or its key
16174+
must be defined
16175+
type: boolean
16176+
required:
16177+
- key
16178+
type: object
16179+
x-kubernetes-map-type: atomic
16180+
type: object
16181+
required:
16182+
- name
16183+
type: object
16184+
type: array
16185+
resources:
16186+
description: Resources defines the Compute Resources required
16187+
by the container for Argo CD Image Updater.
16188+
properties:
16189+
claims:
16190+
description: |-
16191+
Claims lists the names of resources, defined in spec.resourceClaims,
16192+
that are used by this container.
16193+
16194+
This is an alpha field and requires enabling the
16195+
DynamicResourceAllocation feature gate.
16196+
16197+
This field is immutable. It can only be set for containers.
16198+
items:
16199+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
16200+
properties:
16201+
name:
16202+
description: |-
16203+
Name must match the name of one entry in pod.spec.resourceClaims of
16204+
the Pod where this field is used. It makes that resource available
16205+
inside a container.
16206+
type: string
16207+
request:
16208+
description: |-
16209+
Request is the name chosen for a request in the referenced claim.
16210+
If empty, everything from the claim is made available, otherwise
16211+
only the result of this request.
16212+
type: string
16213+
required:
16214+
- name
16215+
type: object
16216+
type: array
16217+
x-kubernetes-list-map-keys:
16218+
- name
16219+
x-kubernetes-list-type: map
16220+
limits:
16221+
additionalProperties:
16222+
anyOf:
16223+
- type: integer
16224+
- type: string
16225+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
16226+
x-kubernetes-int-or-string: true
16227+
description: |-
16228+
Limits describes the maximum amount of compute resources allowed.
16229+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
16230+
type: object
16231+
requests:
16232+
additionalProperties:
16233+
anyOf:
16234+
- type: integer
16235+
- type: string
16236+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
16237+
x-kubernetes-int-or-string: true
16238+
description: |-
16239+
Requests describes the minimum amount of compute resources required.
16240+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
16241+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
16242+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
16243+
type: object
16244+
type: object
16245+
required:
16246+
- enabled
16247+
type: object
1605616248
import:
1605716249
description: Import is the import/restore options for ArgoCD.
1605816250
properties:

config/rbac/role.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ rules:
5959
- deployments/finalizers
6060
verbs:
6161
- update
62+
- apiGroups:
63+
- argocd-image-updater.argoproj.io
64+
resources:
65+
- imageupdaters
66+
- imageupdaters/finalizers
67+
verbs:
68+
- '*'
6269
- apiGroups:
6370
- argoproj.io
6471
resources:

controllers/argocd/argocd_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ var ActiveInstanceMap = make(map[string]string)
115115
//+kubebuilder:rbac:groups=argoproj.io,resources=notificationsconfigurations;notificationsconfigurations/finalizers,verbs=*
116116
//+kubebuilder:rbac:groups="apiregistration.k8s.io",resources="apiservices",verbs=get;list
117117
//+kubebuilder:rbac:groups=argoproj.io,resources=namespacemanagements;namespacemanagements/finalizers;namespacemanagements/status,verbs=*
118+
//+kubebuilder:rbac:groups=argocd-image-updater.argoproj.io,resources=imageupdaters;imageupdaters/finalizers,verbs=*
118119

119120
// Reconcile is part of the main kubernetes reconciliation loop which aims to
120121
// move the current state of the cluster closer to the desired state.

0 commit comments

Comments
 (0)