Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added custom label and annotations to the pods of the server, repo, application set controller, and application controller #1532

Merged
merged 36 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e709c03
Added custom label and annotations
enriqueav99 Aug 30, 2024
89f537d
Added custom label and annotations
enriqueav99 Aug 30, 2024
55b01a2
missunderstanding
enriqueav99 Aug 30, 2024
fde3595
missunderstanding
enriqueav99 Aug 30, 2024
e00ac67
test
enriqueav99 Aug 31, 2024
08f7eb4
deleted from alpha
enriqueav99 Aug 31, 2024
4543852
added the applicationset and fix test
enriqueav99 Aug 31, 2024
ddf959b
make bundle
enriqueav99 Aug 31, 2024
789b853
fixs
enriqueav99 Aug 31, 2024
33f43e1
Deleted the test
enriqueav99 Aug 31, 2024
d306554
Added the test again simplificated to check the CI
enriqueav99 Sep 1, 2024
22b1652
original makefile version
enriqueav99 Sep 2, 2024
86ab541
resolve conflicts
enriqueav99 Sep 4, 2024
fdc8737
Merge branch 'master' into custom-labels-annotations
enriqueav99 Sep 4, 2024
0b2b49f
Merge branch 'master' into custom-labels-annotations
enriqueav99 Sep 4, 2024
45fb7dc
bundle
enriqueav99 Sep 4, 2024
991e546
bundle
enriqueav99 Sep 4, 2024
23bc885
bundle
enriqueav99 Sep 4, 2024
9e6e4a7
resolve problems
enriqueav99 Sep 4, 2024
d890ba7
EOF
enriqueav99 Sep 4, 2024
a1cec9e
refactor
enriqueav99 Sep 16, 2024
85b959f
resolve conflicts
enriqueav99 Sep 16, 2024
d4e6324
Merge branch 'master'
enriqueav99 Sep 16, 2024
03de009
resolve conflicts
enriqueav99 Sep 16, 2024
13bf3a4
resolve conflicts
enriqueav99 Sep 16, 2024
e703bf8
deleted olm 0.12.0 changes and added doc
enriqueav99 Sep 30, 2024
fd7425b
deleted olm 0.12.0 changes and added doc
enriqueav99 Sep 30, 2024
f275c85
deleted olm 0.12.0 changes and added doc
enriqueav99 Sep 30, 2024
1dc7cb9
deleted olm 0.12.0 changes and added doc
enriqueav99 Sep 30, 2024
391134b
EOF
enriqueav99 Sep 30, 2024
34795fd
EOF
enriqueav99 Sep 30, 2024
3ff3e34
assert test
enriqueav99 Sep 30, 2024
527a910
delete labels and annotations test
enriqueav99 Sep 30, 2024
9b9ca0a
delete labels and annotations test
enriqueav99 Sep 30, 2024
228e376
Merge branch 'master' into custom-labels-annotations
enriqueav99 Oct 3, 2024
8dee9fb
EOF
enriqueav99 Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -529,6 +541,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 @@ -638,6 +656,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
Loading