Skip to content

Commit 01e1fe5

Browse files
miinsunsvghadi
andauthored
feat: add extra volume and volumeMounts spec to Dex (#1693)
* feat: add Volumes,VolumeMounts field to ArgoCDDexSpec Signed-off-by: miinsun <kor3334@naver.com> * feat: add Volumes, VolumeMounts to dex deployment Signed-off-by: miinsun <kor3334@naver.com> * feat: update deep copy for generated Signed-off-by: miinsun <kor3334@naver.com> * feat: add dex volume unit test Signed-off-by: miinsun <kor3334@naver.com> * docs: add documentation for Dex deployment volumes and volume mounts Signed-off-by: miinsun <kor3334@naver.com> * feat: add e2e test Signed-off-by: miinsun <kor3334@naver.com> * feat: generate operator bundle manifests Signed-off-by: miinsun <kor3334@naver.com> * Update tests/k8s/1-007_validate_volume_mounts/03-install.yaml Co-authored-by: Siddhesh Ghadi <61187612+svghadi@users.noreply.github.com> Signed-off-by: 민선 (minnie) <61786235+miinsun@users.noreply.github.com> * feat: generate operator bundle manifests Signed-off-by: 민선 (minnie) <61786235+miinsun@users.noreply.github.com> * Rebase and revert changes in 0.14.0 manifests Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com> * Add docs Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com> --------- Signed-off-by: miinsun <kor3334@naver.com> Signed-off-by: 민선 (minnie) <61786235+miinsun@users.noreply.github.com> Signed-off-by: Siddhesh Ghadi <sghadi1203@gmail.com> Co-authored-by: Siddhesh Ghadi <61187612+svghadi@users.noreply.github.com> Co-authored-by: Siddhesh Ghadi <sghadi1203@gmail.com>
1 parent 9f2726c commit 01e1fe5

File tree

13 files changed

+5828
-35
lines changed

13 files changed

+5828
-35
lines changed

api/v1beta1/argocd_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ type ArgoCDDexSpec struct {
268268

269269
// Env lets you specify environment variables for Dex.
270270
Env []corev1.EnvVar `json:"env,omitempty"`
271+
272+
// Volumes adds volumes to the dex server container
273+
Volumes []corev1.Volume `json:"volumes,omitempty"`
274+
275+
// VolumeMounts adds volumeMounts to the dex server container
276+
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
271277
}
272278

273279
// ArgoCDGrafanaSpec defines the desired state for the Grafana component.

api/v1beta1/zz_generated.deepcopy.go

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

bundle/manifests/argocd-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ metadata:
247247
capabilities: Deep Insights
248248
categories: Integration & Delivery
249249
certified: "false"
250-
createdAt: "2025-07-24T05:46:40Z"
250+
createdAt: "2025-07-26T07:37:32Z"
251251
description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
252252
operators.operatorframework.io/builder: operator-sdk-v1.35.0
253253
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4

bundle/manifests/argoproj.io_argocds.yaml

Lines changed: 1866 additions & 0 deletions
Large diffs are not rendered by default.

config/crd/bases/argoproj.io_argocds.yaml

Lines changed: 1866 additions & 0 deletions
Large diffs are not rendered by default.

controllers/argocd/dex.go

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,43 @@ func (r *ReconcileArgoCD) reconcileDexDeployment(cr *argoproj.ArgoCD) error {
253253
AddSeccompProfileForOpenShift(r.Client, &deploy.Spec.Template.Spec)
254254

255255
dexEnv := proxyEnvVars()
256+
257+
dexVolumes := []corev1.Volume{
258+
{
259+
Name: "static-files",
260+
VolumeSource: corev1.VolumeSource{
261+
EmptyDir: &corev1.EmptyDirVolumeSource{},
262+
},
263+
},
264+
{
265+
Name: "dexconfig",
266+
VolumeSource: corev1.VolumeSource{
267+
EmptyDir: &corev1.EmptyDirVolumeSource{},
268+
},
269+
},
270+
}
271+
272+
dexVolumeMounts := []corev1.VolumeMount{
273+
{
274+
Name: "static-files",
275+
MountPath: "/shared",
276+
},
277+
{
278+
Name: "dexconfig",
279+
MountPath: "/tmp",
280+
},
281+
}
282+
256283
if cr.Spec.SSO != nil && cr.Spec.SSO.Dex != nil {
257284
dexEnv = append(dexEnv, cr.Spec.SSO.Dex.Env...)
285+
286+
if cr.Spec.SSO.Dex.Volumes != nil {
287+
dexVolumes = append(dexVolumes, cr.Spec.SSO.Dex.Volumes...)
288+
}
289+
290+
if cr.Spec.SSO.Dex.VolumeMounts != nil {
291+
dexVolumeMounts = append(dexVolumeMounts, cr.Spec.SSO.Dex.VolumeMounts...)
292+
}
258293
}
259294

260295
deploy.Spec.Template.Spec.Containers = []corev1.Container{{
@@ -301,16 +336,7 @@ func (r *ReconcileArgoCD) reconcileDexDeployment(cr *argoproj.ArgoCD) error {
301336
Type: "RuntimeDefault",
302337
},
303338
},
304-
VolumeMounts: []corev1.VolumeMount{
305-
{
306-
Name: "static-files",
307-
MountPath: "/shared",
308-
},
309-
{
310-
Name: "dexconfig",
311-
MountPath: "/tmp",
312-
},
313-
},
339+
VolumeMounts: dexVolumeMounts,
314340
}}
315341

316342
deploy.Spec.Template.Spec.InitContainers = []corev1.Container{{
@@ -338,32 +364,11 @@ func (r *ReconcileArgoCD) reconcileDexDeployment(cr *argoproj.ArgoCD) error {
338364
Type: "RuntimeDefault",
339365
},
340366
},
341-
VolumeMounts: []corev1.VolumeMount{
342-
{
343-
Name: "static-files",
344-
MountPath: "/shared",
345-
},
346-
{
347-
Name: "dexconfig",
348-
MountPath: "/tmp",
349-
}},
367+
VolumeMounts: dexVolumeMounts,
350368
}}
351369

352370
deploy.Spec.Template.Spec.ServiceAccountName = fmt.Sprintf("%s-%s", cr.Name, common.ArgoCDDefaultDexServiceAccountName)
353-
deploy.Spec.Template.Spec.Volumes = []corev1.Volume{
354-
{
355-
Name: "static-files",
356-
VolumeSource: corev1.VolumeSource{
357-
EmptyDir: &corev1.EmptyDirVolumeSource{},
358-
},
359-
},
360-
{
361-
Name: "dexconfig",
362-
VolumeSource: corev1.VolumeSource{
363-
EmptyDir: &corev1.EmptyDirVolumeSource{},
364-
},
365-
},
366-
}
371+
deploy.Spec.Template.Spec.Volumes = dexVolumes
367372

368373
existing := newDeploymentWithSuffix("dex-server", "dex-server", cr)
369374
deplExists, err := argoutil.IsObjectFound(r.Client, cr.Namespace, existing.Name, existing)

controllers/argocd/dex_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,93 @@ func TestReconcileArgoCD_reconcileDeployments_Dex_with_resources(t *testing.T) {
229229
}
230230
}
231231

232+
func TestReconcileArgoCD_reconcileDeployments_Dex_with_volumes(t *testing.T) {
233+
logf.SetLogger(ZapLogger(true))
234+
235+
tests := []struct {
236+
name string
237+
setEnvFunc func(*testing.T, string)
238+
argoCD *argoproj.ArgoCD
239+
}{
240+
{
241+
name: "dex with volumes - .spec.sso.provider=dex",
242+
setEnvFunc: nil,
243+
argoCD: makeTestArgoCD(func(cr *argoproj.ArgoCD) {
244+
cr.Spec.SSO = &argoproj.ArgoCDSSOSpec{
245+
Provider: argoproj.SSOProviderTypeDex,
246+
Dex: &argoproj.ArgoCDDexSpec{
247+
Volumes: []corev1.Volume{
248+
{Name: "custom-config", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
249+
},
250+
VolumeMounts: []corev1.VolumeMount{
251+
{Name: "custom-config", MountPath: "/etc/custom-config"},
252+
},
253+
},
254+
}
255+
}),
256+
},
257+
}
258+
259+
for _, test := range tests {
260+
t.Run(test.name, func(t *testing.T) {
261+
262+
resObjs := []client.Object{test.argoCD}
263+
subresObjs := []client.Object{test.argoCD}
264+
runtimeObjs := []runtime.Object{}
265+
sch := makeTestReconcilerScheme(argoproj.AddToScheme)
266+
cl := makeTestReconcilerClient(sch, resObjs, subresObjs, runtimeObjs)
267+
r := makeTestReconciler(cl, sch)
268+
269+
if test.setEnvFunc != nil {
270+
test.setEnvFunc(t, "false")
271+
}
272+
273+
assert.NoError(t, r.reconcileDexDeployment(test.argoCD))
274+
275+
deployment := &appsv1.Deployment{}
276+
assert.NoError(t, r.Client.Get(
277+
context.TODO(),
278+
types.NamespacedName{
279+
Name: test.argoCD.Name + "-dex-server",
280+
Namespace: test.argoCD.Namespace,
281+
},
282+
deployment))
283+
284+
testVolumes := []corev1.Volume{
285+
{
286+
Name: "static-files",
287+
VolumeSource: corev1.VolumeSource{
288+
EmptyDir: &corev1.EmptyDirVolumeSource{},
289+
},
290+
},
291+
{
292+
Name: "dexconfig",
293+
VolumeSource: corev1.VolumeSource{
294+
EmptyDir: &corev1.EmptyDirVolumeSource{},
295+
},
296+
},
297+
{
298+
Name: "custom-config",
299+
VolumeSource: corev1.VolumeSource{
300+
EmptyDir: &corev1.EmptyDirVolumeSource{},
301+
},
302+
},
303+
}
304+
305+
testVolumeMounts := []corev1.VolumeMount{
306+
{Name: "static-files", MountPath: "/shared"},
307+
{Name: "dexconfig", MountPath: "/tmp"},
308+
{Name: "custom-config", MountPath: "/etc/custom-config"},
309+
}
310+
311+
assert.Equal(t, deployment.Spec.Template.Spec.Volumes, testVolumes)
312+
313+
assert.Equal(t, deployment.Spec.Template.Spec.InitContainers[0].VolumeMounts, testVolumeMounts)
314+
assert.Equal(t, deployment.Spec.Template.Spec.Containers[0].VolumeMounts, testVolumeMounts)
315+
})
316+
}
317+
}
318+
232319
func TestReconcileArgoCD_reconcileDexDeployment(t *testing.T) {
233320
logf.SetLogger(ZapLogger(true))
234321
a := makeTestArgoCD()

deploy/olm-catalog/argocd-operator/0.16.0/argocd-operator.v0.16.0.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ metadata:
247247
capabilities: Deep Insights
248248
categories: Integration & Delivery
249249
certified: "false"
250-
createdAt: "2025-07-24T05:46:40Z"
250+
createdAt: "2025-07-26T07:37:32Z"
251251
description: Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
252252
operators.operatorframework.io/builder: operator-sdk-v1.35.0
253253
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4

0 commit comments

Comments
 (0)