Skip to content

Commit

Permalink
feat: Added custom label and annotations to the pods of the server, r…
Browse files Browse the repository at this point in the history
…epo, application set controller, and application controller (argoproj-labs#1532)

* Added custom label and annotations

Signed-off-by: enriqueav99 <[email protected]>

* Added custom label and annotations

Signed-off-by: enriqueav99 <[email protected]>

* missunderstanding

Signed-off-by: enriqueav99 <[email protected]>

* missunderstanding

Signed-off-by: enriqueav99 <[email protected]>

* test

Signed-off-by: enriqueav99 <[email protected]>

* deleted from alpha

Signed-off-by: enriqueav99 <[email protected]>

* added the applicationset and fix test

Signed-off-by: enriqueav99 <[email protected]>

* make bundle

Signed-off-by: enriqueav99 <[email protected]>

* fixs

Signed-off-by: enriqueav99 <[email protected]>

* Deleted the test

Signed-off-by: enriqueav99 <[email protected]>

* Added the test again simplificated to check the CI

Signed-off-by: enriqueav99 <[email protected]>

* original makefile version

Signed-off-by: enriqueav99 <[email protected]>

* resolve conflicts

Signed-off-by: enriqueav99 <[email protected]>

* bundle

Signed-off-by: enriqueav99 <[email protected]>

* bundle

Signed-off-by: enriqueav99 <[email protected]>

* bundle

Signed-off-by: enriqueav99 <[email protected]>

* resolve problems

Signed-off-by: enriqueav99 <[email protected]>

* EOF

Signed-off-by: enriqueav99 <[email protected]>

* refactor

Signed-off-by: enriqueav99 <[email protected]>

* resolve conflicts

Signed-off-by: enriqueav99 <[email protected]>

* resolve conflicts

Signed-off-by: enriqueav99 <[email protected]>

* resolve conflicts

Signed-off-by: enriqueav99 <[email protected]>

* deleted olm 0.12.0 changes and added doc

Signed-off-by: enriqueav99 <[email protected]>

* deleted olm 0.12.0 changes and added doc

Signed-off-by: enriqueav99 <[email protected]>

* deleted olm 0.12.0 changes and added doc

Signed-off-by: enriqueav99 <[email protected]>

* deleted olm 0.12.0 changes and added doc

Signed-off-by: enriqueav99 <[email protected]>

* EOF

Signed-off-by: enriqueav99 <[email protected]>

* EOF

Signed-off-by: enriqueav99 <[email protected]>

* assert test

Signed-off-by: enriqueav99 <[email protected]>

* delete labels and annotations test

Signed-off-by: enriqueav99 <[email protected]>

* delete labels and annotations test

Signed-off-by: enriqueav99 <[email protected]>

* EOF

Signed-off-by: enriqueav99 <[email protected]>

---------

Signed-off-by: enriqueav99 <[email protected]>
  • Loading branch information
enriqueav99 authored Oct 4, 2024
1 parent 6e304b2 commit 3334487
Show file tree
Hide file tree
Showing 17 changed files with 485 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
##@ E2E

e2e: ## Run operator e2e tests
kubectl kuttl test ./tests/k8s --config ./tests/kuttl-tests.yaml
kubectl kuttl test ./tests/k8s --config ./tests/kuttl-tests.yaml

all: test install run e2e ## UnitTest, Run the operator locally and execute e2e tests.

Expand Down
24 changes: 24 additions & 0 deletions api/v1beta1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ type ArgoCDApplicationControllerSpec struct {

// VolumeMounts adds volumeMounts to the Argo CD Controller container.
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`

// Custom annotations to pods deployed by the operator
Annotations map[string]string `json:"annotations,omitempty"`

// Custom labels to pods deployed by the operator
Labels map[string]string `json:"labels,omitempty"`
}

func (a *ArgoCDApplicationControllerSpec) IsEnabled() bool {
Expand Down Expand Up @@ -195,6 +201,12 @@ type ArgoCDApplicationSet struct {

// SCMProviders defines the list of allowed custom SCM provider API URLs
SCMProviders []string `json:"scmProviders,omitempty"`

// Custom annotations to pods deployed by the operator
Annotations map[string]string `json:"annotations,omitempty"`

// Custom labels to pods deployed by the operator
Labels map[string]string `json:"labels,omitempty"`
}

func (a *ArgoCDApplicationSet) IsEnabled() bool {
Expand Down Expand Up @@ -533,6 +545,12 @@ type ArgoCDRepoSpec struct {

// Remote specifies the remote URL of the Repo Server container. (optional, by default, a local instance managed by the operator is used.)
Remote *string `json:"remote,omitempty"`

// Custom annotations to pods deployed by the operator
Annotations map[string]string `json:"annotations,omitempty"`

// Custom labels to pods deployed by the operator
Labels map[string]string `json:"labels,omitempty"`
}

func (a *ArgoCDRepoSpec) IsEnabled() bool {
Expand Down Expand Up @@ -646,6 +664,12 @@ type ArgoCDServerSpec struct {

// VolumeMounts adds volumeMounts to the Argo CD Server container.
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`

// Custom annotations to pods deployed by the operator
Annotations map[string]string `json:"annotations,omitempty"`

// Custom labels to pods deployed by the operator
Labels map[string]string `json:"labels,omitempty"`
}

func (a *ArgoCDServerSpec) IsEnabled() bool {
Expand Down
56 changes: 56 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ metadata:
capabilities: Deep Insights
categories: Integration & Delivery
certified: "false"
createdAt: "2024-09-27T05:27:12Z"
createdAt: "2024-09-16T21:29:22Z"
description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
operators.operatorframework.io/builder: operator-sdk-v1.35.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
Expand Down
40 changes: 40 additions & 0 deletions bundle/manifests/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7269,6 +7269,11 @@ spec:
description: ArgoCDApplicationSet defines whether the Argo CD ApplicationSet
controller should be installed.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
enabled:
description: Enabled is the flag to enable the Application Set
Controller during ArgoCD installation. (optional, default `true`)
Expand Down Expand Up @@ -7400,6 +7405,11 @@ spec:
image:
description: Image is the Argo CD ApplicationSet image (optional)
type: string
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logLevel:
description: LogLevel describes the log level that should be used
by the ApplicationSet controller. Defaults to ArgoCDDefaultLogLevel
Expand Down Expand Up @@ -7677,6 +7687,11 @@ spec:
description: Controller defines the Application Controller options
for ArgoCD.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
appSync:
description: |-
AppSync is used to control the sync frequency, by default the ArgoCD
Expand Down Expand Up @@ -9133,6 +9148,11 @@ spec:
- name
type: object
type: array
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat refers to the log format used by the Application
Controller component. Defaults to ArgoCDDefaultLogFormat if
Expand Down Expand Up @@ -13202,6 +13222,11 @@ spec:
repo:
description: Repo defines the repo server options for Argo CD.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
autotls:
description: |-
AutoTLS specifies the method to use for automatic TLS configuration for the repo server
Expand Down Expand Up @@ -14662,6 +14687,11 @@ spec:
- name
type: object
type: array
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat describes the log format that should be
used by the Repo Server. Defaults to ArgoCDDefaultLogFormat
Expand Down Expand Up @@ -17821,6 +17851,11 @@ spec:
server:
description: Server defines the options for the ArgoCD Server component.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
autoscale:
description: Autoscale defines the autoscale options for the Argo
CD Server component.
Expand Down Expand Up @@ -19450,6 +19485,11 @@ spec:
insecure:
description: Insecure toggles the insecure flag.
type: boolean
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat refers to the log level to be used by the
ArgoCD Server component. Defaults to ArgoCDDefaultLogFormat
Expand Down
40 changes: 40 additions & 0 deletions config/crd/bases/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7258,6 +7258,11 @@ spec:
description: ArgoCDApplicationSet defines whether the Argo CD ApplicationSet
controller should be installed.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
enabled:
description: Enabled is the flag to enable the Application Set
Controller during ArgoCD installation. (optional, default `true`)
Expand Down Expand Up @@ -7389,6 +7394,11 @@ spec:
image:
description: Image is the Argo CD ApplicationSet image (optional)
type: string
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logLevel:
description: LogLevel describes the log level that should be used
by the ApplicationSet controller. Defaults to ArgoCDDefaultLogLevel
Expand Down Expand Up @@ -7666,6 +7676,11 @@ spec:
description: Controller defines the Application Controller options
for ArgoCD.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
appSync:
description: |-
AppSync is used to control the sync frequency, by default the ArgoCD
Expand Down Expand Up @@ -9122,6 +9137,11 @@ spec:
- name
type: object
type: array
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat refers to the log format used by the Application
Controller component. Defaults to ArgoCDDefaultLogFormat if
Expand Down Expand Up @@ -13191,6 +13211,11 @@ spec:
repo:
description: Repo defines the repo server options for Argo CD.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
autotls:
description: |-
AutoTLS specifies the method to use for automatic TLS configuration for the repo server
Expand Down Expand Up @@ -14651,6 +14676,11 @@ spec:
- name
type: object
type: array
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat describes the log format that should be
used by the Repo Server. Defaults to ArgoCDDefaultLogFormat
Expand Down Expand Up @@ -17810,6 +17840,11 @@ spec:
server:
description: Server defines the options for the ArgoCD Server component.
properties:
annotations:
additionalProperties:
type: string
description: Custom annotations to pods deployed by the operator
type: object
autoscale:
description: Autoscale defines the autoscale options for the Argo
CD Server component.
Expand Down Expand Up @@ -19439,6 +19474,11 @@ spec:
insecure:
description: Insecure toggles the insecure flag.
type: boolean
labels:
additionalProperties:
type: string
description: Custom labels to pods deployed by the operator
type: object
logFormat:
description: LogFormat refers to the log level to be used by the
ArgoCD Server component. Defaults to ArgoCDDefaultLogFormat
Expand Down
15 changes: 14 additions & 1 deletion controllers/argocd/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD,
}
}

if cr.Spec.ApplicationSet.Annotations != nil {
deploy.Spec.Template.Annotations = cr.Spec.ApplicationSet.Annotations
}

if cr.Spec.ApplicationSet.Labels != nil {
for key, value := range cr.Spec.ApplicationSet.Labels {
deploy.Spec.Template.Labels[key] = value
}
}

podSpec.Containers = []corev1.Container{
r.applicationSetContainer(cr, addSCMGitlabVolumeMount),
}
Expand All @@ -263,7 +273,8 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD,
!reflect.DeepEqual(existing.Spec.Selector, deploy.Spec.Selector) ||
!reflect.DeepEqual(existing.Spec.Template.Spec.NodeSelector, deploy.Spec.Template.Spec.NodeSelector) ||
!reflect.DeepEqual(existing.Spec.Template.Spec.Tolerations, deploy.Spec.Template.Spec.Tolerations) ||
!reflect.DeepEqual(existing.Spec.Template.Spec.Containers[0].SecurityContext, deploy.Spec.Template.Spec.Containers[0].SecurityContext)
!reflect.DeepEqual(existing.Spec.Template.Spec.Containers[0].SecurityContext, deploy.Spec.Template.Spec.Containers[0].SecurityContext) ||
!reflect.DeepEqual(existing.Spec.Template.Annotations, deploy.Spec.Template.Annotations)

// If the Deployment already exists, make sure the values we care about are up-to-date
if deploymentsDifferent {
Expand All @@ -276,6 +287,8 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD,
existing.Spec.Template.Spec.NodeSelector = deploy.Spec.Template.Spec.NodeSelector
existing.Spec.Template.Spec.Tolerations = deploy.Spec.Template.Spec.Tolerations
existing.Spec.Template.Spec.Containers[0].SecurityContext = deploy.Spec.Template.Spec.Containers[0].SecurityContext
existing.Spec.Template.Annotations = deploy.Spec.Template.Annotations

return r.Client.Update(context.TODO(), existing)
}
return nil // Deployment found with nothing to do, move along...
Expand Down
Loading

0 comments on commit 3334487

Please sign in to comment.