Skip to content

Commit

Permalink
allow enabling ArgoCD workloads independently
Browse files Browse the repository at this point in the history
Signed-off-by: ishitasequeira <[email protected]>
  • Loading branch information
ishitasequeira committed Oct 19, 2023
1 parent 6b3fbb6 commit 669c43b
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 2 deletions.
7 changes: 7 additions & 0 deletions api/v1alpha1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ type ArgoCDRedisSpec struct {
// The value specified here can currently be:
// - openshift - Use the OpenShift service CA to request TLS config
AutoTLS string `json:"autotls,omitempty"`

// Enabled is the flag to enable Redis during ArgoCD installation. (optional, default `true`)
// +optional
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDRepoSpec defines the desired state for the Argo CD repo server component.
Expand Down Expand Up @@ -467,6 +471,9 @@ type ArgoCDRepoSpec struct {

// SidecarContainers defines the list of sidecar containers for the repo server deployment
SidecarContainers []corev1.Container `json:"sidecarContainers,omitempty"`

// Enabled is the flag to enable Repo Server during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDRouteSpec defines the desired state for an OpenShift Route.
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

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

// Env lets you specify environment for application controller pods
Env []corev1.EnvVar `json:"env,omitempty"`

// Enabled is the flag to enable the Application Controller during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDApplicationControllerShardSpec defines the options available for enabling sharding for the Application Controller component.
Expand Down Expand Up @@ -162,6 +165,9 @@ type ArgoCDApplicationSet struct {

// SCMRootCAConfigMap is the name of the config map that stores the Gitlab SCM Provider's TLS certificate which will be mounted on the ApplicationSet Controller (optional).
SCMRootCAConfigMap string `json:"scmRootCAConfigMap,omitempty"`

// Enabled is the flag to enable the Application Set Controller during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDCASpec defines the CA options for ArgCD.
Expand Down Expand Up @@ -410,6 +416,10 @@ type ArgoCDRedisSpec struct {
// The value specified here can currently be:
// - openshift - Use the OpenShift service CA to request TLS config
AutoTLS string `json:"autotls,omitempty"`

// Enabled is the flag to enable Redis during ArgoCD installation. (optional, default `true`)
// +optional
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDRepoSpec defines the desired state for the Argo CD repo server component.
Expand Down Expand Up @@ -470,6 +480,9 @@ type ArgoCDRepoSpec struct {

// SidecarContainers defines the list of sidecar containers for the repo server deployment
SidecarContainers []corev1.Container `json:"sidecarContainers,omitempty"`

// Enabled is the flag to enable Repo Server during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDRouteSpec defines the desired state for an OpenShift Route.
Expand Down Expand Up @@ -560,6 +573,9 @@ type ArgoCDServerSpec struct {
// ExtraCommandArgs will not be added, if one of these commands is already part of the server command
// with same or different value.
ExtraCommandArgs []string `json:"extraCommandArgs,omitempty"`

// Enabled is the flag to enable ArgoCD Server during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`
}

// ArgoCDServerServiceSpec defines the Service options for Argo CD Server component.
Expand Down
25 changes: 25 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.

28 changes: 28 additions & 0 deletions bundle/manifests/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,10 @@ spec:
description: DisableTLSVerification defines whether redis server
API should be accessed using strict TLS validation
type: boolean
enabled:
description: Enabled is the flag to enable Redis during ArgoCD
installation. (optional, default `true`)
type: boolean
image:
description: Image is the Redis container image.
type: string
Expand Down Expand Up @@ -1399,6 +1403,10 @@ spec:
can currently be: - openshift - Use the OpenShift service CA
to request TLS config'
type: string
enabled:
description: Enabled is the flag to enable Repo Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for repo server
pods
Expand Down Expand Up @@ -6500,6 +6508,10 @@ spec:
description: ArgoCDApplicationSet defines whether the Argo CD ApplicationSet
controller should be installed.
properties:
enabled:
description: Enabled is the flag to enable the Application Set
Controller during ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for applicationSet
controller pods
Expand Down Expand Up @@ -6829,6 +6841,10 @@ spec:
to a duration, e.g. 10m or 600s to control the synchronisation
frequency."
type: string
enabled:
description: Enabled is the flag to enable the Application Controller
during ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for application
controller pods
Expand Down Expand Up @@ -7753,6 +7769,10 @@ spec:
description: DisableTLSVerification defines whether redis server
API should be accessed using strict TLS validation
type: boolean
enabled:
description: Enabled is the flag to enable Redis during ArgoCD
installation. (optional, default `true`)
type: boolean
image:
description: Image is the Redis container image.
type: string
Expand Down Expand Up @@ -7796,6 +7816,10 @@ spec:
can currently be: - openshift - Use the OpenShift service CA
to request TLS config'
type: string
enabled:
description: Enabled is the flag to enable Repo Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for repo server
pods
Expand Down Expand Up @@ -12200,6 +12224,10 @@ spec:
required:
- enabled
type: object
enabled:
description: Enabled is the flag to enable ArgoCD Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for API server pods
items:
Expand Down
28 changes: 28 additions & 0 deletions config/crd/bases/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,10 @@ spec:
description: DisableTLSVerification defines whether redis server
API should be accessed using strict TLS validation
type: boolean
enabled:
description: Enabled is the flag to enable Redis during ArgoCD
installation. (optional, default `true`)
type: boolean
image:
description: Image is the Redis container image.
type: string
Expand Down Expand Up @@ -1390,6 +1394,10 @@ spec:
can currently be: - openshift - Use the OpenShift service CA
to request TLS config'
type: string
enabled:
description: Enabled is the flag to enable Repo Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for repo server
pods
Expand Down Expand Up @@ -6491,6 +6499,10 @@ spec:
description: ArgoCDApplicationSet defines whether the Argo CD ApplicationSet
controller should be installed.
properties:
enabled:
description: Enabled is the flag to enable the Application Set
Controller during ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for applicationSet
controller pods
Expand Down Expand Up @@ -6820,6 +6832,10 @@ spec:
to a duration, e.g. 10m or 600s to control the synchronisation
frequency."
type: string
enabled:
description: Enabled is the flag to enable the Application Controller
during ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for application
controller pods
Expand Down Expand Up @@ -7744,6 +7760,10 @@ spec:
description: DisableTLSVerification defines whether redis server
API should be accessed using strict TLS validation
type: boolean
enabled:
description: Enabled is the flag to enable Redis during ArgoCD
installation. (optional, default `true`)
type: boolean
image:
description: Image is the Redis container image.
type: string
Expand Down Expand Up @@ -7787,6 +7807,10 @@ spec:
can currently be: - openshift - Use the OpenShift service CA
to request TLS config'
type: string
enabled:
description: Enabled is the flag to enable Repo Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for repo server
pods
Expand Down Expand Up @@ -12191,6 +12215,10 @@ spec:
required:
- enabled
type: object
enabled:
description: Enabled is the flag to enable ArgoCD Server during
ArgoCD installation. (optional, default `true`)
type: boolean
env:
description: Env lets you specify environment for API server pods
items:
Expand Down
32 changes: 32 additions & 0 deletions controllers/argocd/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,11 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b

existing := newDeploymentWithSuffix("redis", "redis", cr)
if argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing) {
if !IsComponentEnabled(cr.Spec.Redis.Enabled) {
// Deployment exists but component enabled flag has been set to false, delete the Deployment
log.Info("Redis exists but should be disabled. Deleting existing redis.")
return r.Client.Delete(context.TODO(), deploy)
}
if cr.Spec.HA.Enabled {
// Deployment exists but HA enabled flag has been set to true, delete the Deployment
return r.Client.Delete(context.TODO(), deploy)
Expand Down Expand Up @@ -660,6 +665,11 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b
return nil // Deployment found with nothing to do, move along...
}

if !IsComponentEnabled(cr.Spec.Redis.Enabled) {
log.Info("Redis disabled. Skipping starting redis.")
return nil
}

if cr.Spec.HA.Enabled {
return nil // HA enabled, do nothing.
}
Expand Down Expand Up @@ -1103,6 +1113,13 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoproj.ArgoCD, useTLSFor

existing := newDeploymentWithSuffix("repo-server", "repo-server", cr)
if argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing) {

if !IsComponentEnabled(cr.Spec.Repo.Enabled) {
log.Info("Existing ArgoCD Repo Server found but should be disabled. Deleting Repo Server")
// Delete existing deployment for ArgoCD Repo Server, if any ..
return nil
}

changed := false
actualImage := existing.Spec.Template.Spec.Containers[0].Image
desiredImage := getRepoServerContainerImage(cr)
Expand Down Expand Up @@ -1171,6 +1188,11 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoproj.ArgoCD, useTLSFor
return nil // Deployment found with nothing to do, move along...
}

if !IsComponentEnabled(cr.Spec.Repo.Enabled) {
log.Info("ArgoCD Repo disabled. Skipping starting ArgoCD Repo.")
return nil
}

if err := controllerutil.SetControllerReference(cr, deploy, r.Scheme); err != nil {
return err
}
Expand Down Expand Up @@ -1292,6 +1314,11 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF

existing := newDeploymentWithSuffix("server", "server", cr)
if argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing) {
if !IsComponentEnabled(cr.Spec.Server.Enabled) {
log.Info("Existing ArgoCD Server found but should be disabled. Deleting ArgoCD Server")
// Delete existing deployment for ArgoCD Server, if any ..
return nil
}
actualImage := existing.Spec.Template.Spec.Containers[0].Image
desiredImage := getArgoContainerImage(cr)
changed := false
Expand Down Expand Up @@ -1337,6 +1364,11 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF
return nil // Deployment found with nothing to do, move along...
}

if !IsComponentEnabled(cr.Spec.Controller.Enabled) {
log.Info("ArgoCD Repo Server disabled. Skipping starting repo server.")
return nil
}

if err := controllerutil.SetControllerReference(cr, deploy, r.Scheme); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 669c43b

Please sign in to comment.