Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion argocd-operator/api/v1alpha1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ type ArgoCDCommitServerSpec struct {

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

// Volumes adds volumes to the commit server deployment. A volume with the same
// name as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// ArgoCDDexSpec defines the desired state for the Dex server component.
Expand Down Expand Up @@ -536,7 +542,10 @@ type ArgoCDRepoSpec struct {
// Env lets you specify environment for repo server pods
Env []corev1.EnvVar `json:"env,omitempty"`

// Volumes adds volumes to the repo server deployment
// Volumes adds volumes to the repo server deployment. A volume with the same name
// as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the repo server container
Expand Down
7 changes: 7 additions & 0 deletions argocd-operator/api/v1alpha1/zz_generated.deepcopy.go

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

43 changes: 38 additions & 5 deletions argocd-operator/api/v1beta1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ type ArgoCDApplicationControllerSpec struct {
// by the operator.
// Please note that the command line arguments provided as part of ExtraCommandArgs will not overwrite the default command line arguments.
ExtraCommandArgs []string `json:"extraCommandArgs,omitempty"`
// Volumes adds volumes to the Argo CD Controller container.
// Volumes adds volumes to the Argo CD Controller container. A volume with the
// same name as an operator-managed volume replaces it. Use this to override
// internally managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the Argo CD Controller container.
Expand Down Expand Up @@ -213,7 +216,10 @@ type ArgoCDApplicationSet struct {
// Custom labels to pods deployed by the operator
Labels map[string]string `json:"labels,omitempty"`

// Volumes adds volumes to the Argo CD ApplicationSet Controller container.
// Volumes adds volumes to the Argo CD ApplicationSet Controller container. A volume
// with the same name as an operator-managed volume replaces it. Use this to override
// internally managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the Argo CD ApplicationSet Controller container.
Expand Down Expand Up @@ -270,6 +276,12 @@ type ArgoCDCommitServerSpec struct {

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

// Volumes adds volumes to the commit server deployment. A volume with the same
// name as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// ArgoCDDexSpec defines the desired state for the Dex server component.
Expand Down Expand Up @@ -300,7 +312,10 @@ type ArgoCDDexSpec struct {
// Env lets you specify environment variables for Dex.
Env []corev1.EnvVar `json:"env,omitempty"`

// Volumes adds volumes to the dex server container
// Volumes adds volumes to the dex server container. A volume with the same name
// as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the dex server container
Expand Down Expand Up @@ -375,6 +390,12 @@ type ArgoCDImageUpdaterSpec struct {

// Resources defines the Compute Resources required by the container for Argo CD Image Updater.
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

// Volumes adds volumes to the Image Updater deployment. A volume with the same
// name as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

// ArgoCDImportSpec defines the desired state for the ArgoCD import/restore process.
Expand Down Expand Up @@ -577,6 +598,12 @@ type ArgoCDRedisSpec struct {

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

// Volumes adds volumes to the Redis workloads. A volume with the same name as
// an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`
}

func (a *ArgoCDRedisSpec) IsEnabled() bool {
Expand Down Expand Up @@ -633,7 +660,10 @@ type ArgoCDRepoSpec struct {
// Env lets you specify environment for repo server pods
Env []corev1.EnvVar `json:"env,omitempty"`

// Volumes adds volumes to the repo server deployment
// Volumes adds volumes to the repo server deployment. A volume with the same name
// as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the repo server container
Expand Down Expand Up @@ -787,7 +817,10 @@ type ArgoCDServerSpec struct {
// Enabled is the flag to enable ArgoCD Server during ArgoCD installation. (optional, default `true`)
Enabled *bool `json:"enabled,omitempty"`

// Volumes adds volumes to the Argo CD Server container.
// Volumes adds volumes to the Argo CD Server container. A volume with the same name
// as an operator-managed volume replaces it. Use this to override internally
// managed emptyDir volumes with a Generic Ephemeral Volume
// (ephemeral.volumeClaimTemplate).
Volumes []corev1.Volume `json:"volumes,omitempty"`

// VolumeMounts adds volumeMounts to the Argo CD Server container.
Expand Down
21 changes: 21 additions & 0 deletions argocd-operator/api/v1beta1/zz_generated.deepcopy.go

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

4 changes: 1 addition & 3 deletions argocd-operator/controllers/argocd/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ func (r *ReconcileArgoCD) reconcileApplicationSetDeployment(cr *argoproj.ArgoCD,
},
},
}
if cr.Spec.ApplicationSet.Volumes != nil {
serverVolumes = append(serverVolumes, cr.Spec.ApplicationSet.Volumes...)
}
serverVolumes = mergeOperatorVolumes(serverVolumes, cr.Spec.ApplicationSet.Volumes)
podSpec.Volumes = serverVolumes
addSCMGitlabVolumeMount := false
if scmRootCAConfigMapName := getSCMRootCAConfigMapName(cr); scmRootCAConfigMapName != "" {
Expand Down
1 change: 1 addition & 0 deletions argocd-operator/controllers/argocd/commitserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (r *ReconcileArgoCD) reconcileCommitServerDeployment(cr *argoproj.ArgoCD) e
},
},
}
deploy.Spec.Template.Spec.Volumes = mergeOperatorVolumes(deploy.Spec.Template.Spec.Volumes, cr.Spec.CommitServer.Volumes)

if cr.Spec.CommitServer.InitContainers != nil {
deploy.Spec.Template.Spec.InitContainers = append(deploy.Spec.Template.Spec.InitContainers, cr.Spec.CommitServer.InitContainers...)
Expand Down
12 changes: 5 additions & 7 deletions argocd-operator/controllers/argocd/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b
}}

deploy.Spec.Template.Spec.ServiceAccountName = getServiceAccountName(cr.Name, common.ArgoCDRedisComponent)
deploy.Spec.Template.Spec.Volumes = []corev1.Volume{
deploy.Spec.Template.Spec.Volumes = mergeOperatorVolumes([]corev1.Volume{
{
Name: common.ArgoCDRedisServerTLSSecretName,
VolumeSource: corev1.VolumeSource{
Expand All @@ -516,7 +516,7 @@ func (r *ReconcileArgoCD) reconcileRedisDeployment(cr *argoproj.ArgoCD, useTLS b
},
},
redisVolume,
}
}, cr.Spec.Redis.Volumes)

if cr.Spec.Redis.Annotations != nil {
maps.Copy(deploy.Spec.Template.Annotations, cr.Spec.Redis.Annotations)
Expand Down Expand Up @@ -772,7 +772,7 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
},
}}

deploy.Spec.Template.Spec.Volumes = []corev1.Volume{
deploy.Spec.Template.Spec.Volumes = mergeOperatorVolumes([]corev1.Volume{
{
Name: "config-volume",
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -805,7 +805,7 @@ func (r *ReconcileArgoCD) reconcileRedisHAProxyDeployment(cr *argoproj.ArgoCD) e
},
},
redisAuthVolume,
}
}, cr.Spec.Redis.Volumes)

if IsOpenShiftCluster() {
deploy.Spec.Template.Spec.SecurityContext = &corev1.PodSecurityContext{
Expand Down Expand Up @@ -1096,9 +1096,7 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF
redisAuthVolume,
}

if cr.Spec.Server.Volumes != nil {
serverVolumes = append(serverVolumes, cr.Spec.Server.Volumes...)
}
serverVolumes = mergeOperatorVolumes(serverVolumes, cr.Spec.Server.Volumes)

deploy.Spec.Template.Spec.Volumes = serverVolumes

Expand Down
58 changes: 58 additions & 0 deletions argocd-operator/controllers/argocd/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,64 @@ func TestReconcileArgoCD_reconcileRepoDeployment_volumes(t *testing.T) {
assert.NoError(t, err)
assert.Contains(t, deployment.Spec.Template.Spec.Volumes, customVolume)
})

t.Run("replace operator emptyDir with a generic ephemeral volume", func(t *testing.T) {
storageClass := "managed-csi"
ephemeralVolume := corev1.Volume{
Name: "var-files",
VolumeSource: corev1.VolumeSource{
Ephemeral: &corev1.EphemeralVolumeSource{
VolumeClaimTemplate: &corev1.PersistentVolumeClaimTemplate{
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
StorageClassName: &storageClass,
Resources: corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: resourcev1.MustParse("20Gi"),
},
},
},
},
},
},
}

logf.SetLogger(ZapLogger(true))
a := makeTestArgoCD(func(a *argoproj.ArgoCD) {
a.Spec.Repo.Volumes = []corev1.Volume{ephemeralVolume}
})

resObjs := []client.Object{a}
subresObjs := []client.Object{a}
runtimeObjs := []runtime.Object{}
sch := makeTestReconcilerScheme(argoproj.AddToScheme, promoter.AddToScheme, apiregistrationv1.AddToScheme)
cl := makeTestReconcilerClient(sch, resObjs, subresObjs, runtimeObjs)
r := makeTestReconciler(cl, sch, testclient.NewSimpleClientset())

err := r.reconcileRepoDeployment(a, false)
assert.NoError(t, err)
deployment := &appsv1.Deployment{}
err = r.Get(context.TODO(), types.NamespacedName{
Name: "argocd-repo-server",
Namespace: testNamespace,
}, deployment)
assert.NoError(t, err)

var found *corev1.Volume
count := 0
for i := range deployment.Spec.Template.Spec.Volumes {
volume := &deployment.Spec.Template.Spec.Volumes[i]
if volume.Name != "var-files" {
continue
}
count++
found = volume
}
require.Equal(t, 1, count)
require.NotNil(t, found)
assert.Nil(t, found.EmptyDir)
assert.Equal(t, ephemeralVolume.Ephemeral, found.Ephemeral)
})
}

func TestReconcileArgoCD_reconcile_ServerDeployment_env(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions argocd-operator/controllers/argocd/dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,7 @@ func (r *ReconcileArgoCD) reconcileDexDeployment(cr *argoproj.ArgoCD) error {
if cr.Spec.SSO != nil && cr.Spec.SSO.Dex != nil {
dexEnv = append(dexEnv, cr.Spec.SSO.Dex.Env...)

if cr.Spec.SSO.Dex.Volumes != nil {
dexVolumes = append(dexVolumes, cr.Spec.SSO.Dex.Volumes...)
}
dexVolumes = mergeOperatorVolumes(dexVolumes, cr.Spec.SSO.Dex.Volumes)

if cr.Spec.SSO.Dex.VolumeMounts != nil {
dexVolumeMounts = append(dexVolumeMounts, cr.Spec.SSO.Dex.VolumeMounts...)
Expand Down
1 change: 1 addition & 0 deletions argocd-operator/controllers/argocd/image_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ func (r *ReconcileArgoCD) reconcileImageUpdaterDeployment(cr *argoproj.ArgoCD, s
},
},
}
podSpec.Volumes = mergeOperatorVolumes(podSpec.Volumes, cr.Spec.ImageUpdater.Volumes)

args := []string{"run"}
imageUpdaterTLSProfileArguments := BuildTLSArgsFromClusterTLSProfile(r.CentralTLSConfigProfile)
Expand Down
4 changes: 1 addition & 3 deletions argocd-operator/controllers/argocd/repo_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argocdoperatorv1beta1.Argo
})
}

if cr.Spec.Repo.Volumes != nil {
repoServerVolumes = append(repoServerVolumes, cr.Spec.Repo.Volumes...)
}
repoServerVolumes = mergeOperatorVolumes(repoServerVolumes, cr.Spec.Repo.Volumes)
deploy.Spec.Template.Spec.Volumes = repoServerVolumes

r.injectCATrustToContainers(cr, deploy)
Expand Down
8 changes: 3 additions & 5 deletions argocd-operator/controllers/argocd/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (r *ReconcileArgoCD) reconcileRedisStatefulSet(cr *argoproj.ArgoCD) error {
ss.Spec.Template.Spec.TerminationGracePeriodSeconds = &terminationGracePeriodSeconds

var defaultMode int32 = 493
ss.Spec.Template.Spec.Volumes = []corev1.Volume{
ss.Spec.Template.Spec.Volumes = mergeOperatorVolumes([]corev1.Volume{
{
Name: "config",
VolumeSource: corev1.VolumeSource{
Expand Down Expand Up @@ -404,7 +404,7 @@ func (r *ReconcileArgoCD) reconcileRedisStatefulSet(cr *argoproj.ArgoCD) error {
},
},
redisAuthVolume,
}
}, cr.Spec.Redis.Volumes)

ss.Spec.UpdateStrategy = appsv1.StatefulSetUpdateStrategy{
Type: appsv1.RollingUpdateStatefulSetStrategyType,
Expand Down Expand Up @@ -807,9 +807,7 @@ func (r *ReconcileArgoCD) reconcileApplicationControllerStatefulSet(cr *argoproj
redisAuthVolume,
}

if cr.Spec.Controller.Volumes != nil {
controllerVolumes = append(controllerVolumes, cr.Spec.Controller.Volumes...)
}
controllerVolumes = mergeOperatorVolumes(controllerVolumes, cr.Spec.Controller.Volumes)

podSpec.Volumes = controllerVolumes

Expand Down
Loading