redhat-developer / gitops-operator

An operator that gets you an ArgoCD for cluster configuration out-of-the-box on OpenShift along with the UI for visualizing environments.
Apache License 2.0
144 stars 271 forks source link

Allow Volumes/VolumeMounts to pass through to the Deployment #652

Open aboukhal opened 6 months ago

aboukhal commented 6 months ago

When trying to apply custom styling to ArgoCD, for example to color the banners as an easy distinction on which Cluster one is currently on, there is a documentation to be found here: https://argo-cd.readthedocs.io/en/stable/operator-manual/custom-styles/

The documentation contains two alternatives on how to achieve that goal:

  1. Manually change the argocd-server-Deployment to mount the additional CSS-File to the file system and use it from there.
  2. Configure an external URL for the CSS file, spin up a web server, service and route just for a single file.

Alternative 1 does not work with the operator because the Deployment gets overwritten by it immediately. Alternative 2 is not a sensible solution unless there is already some central storage for look-and-feels throughout a company. I'm not sure if this actually exists anywhere.

Describe the solution you'd like There should be an option to declare Volumes and VolumeMounts directly in the ArgoCD resource. They should be automatically propagated to the argocd-server Deployment. Since the Deployment only contains one container, it could even be simplified further to a single object in the CRD, that contains all options for Deployment.spec.template.spec.volumes plus the field mountPath. In a first step, ConfigMap and Secret support might even cover the vast majority of use cases.

Describe alternatives you've considered Alternatively, the Operator should not consider added Volumes or VolumeMounts a difference and should not overwrite them, even if something else in the ArgoCD resource has changed that necessitates a change to the Deployment. I believe this solution is worse than the one I suggested but it would still be much better than the Alternative 2 above.

coder-david commented 2 months ago

We're currently trying to implement exactly the same functionality but are unable to do so, due to the current limitations. Following the issue...

aboukhal commented 2 months ago

Our current work-around is to use a repository in our internal Git server that's set to public and contains the CSS files we need. It is very hacky, though.

Jenson3210 commented 2 months ago

What property did you use to setup the connection to this url? Could not find it.

We even tried banner content to already have some distinction, but not showing for us (the content itself is not there, the place is reserved onscreen)

svghadi commented 1 month ago

Mounting extra volumes to repo-server is already supported by the operator. Maybe something similar can be implemented to mount volumes for argocd-server aswell.

Example to mount volumes to repo-server:

apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
  name: argocd-sample
spec:
  repo:
    volumes:
    - name: repo-pv-storage
      persistentVolumeClaim:
        claimName: repo-pv-claim
    volumeMounts:
    - mountPath: /tmp
      name: repo-pv-storage

We also have ongoing efforts to support adding sidecar containers to argocd-server & application-controller deployments. Not sure if that could help in any way for this use case.

aboukhal commented 1 month ago

What property did you use to setup the connection to this url? Could not find it.

We even tried banner content to already have some distinction, but not showing for us (the content itself is not there, the place is reserved onscreen) @Jenson3210

In your ArgoCD resource under spec.extraconfig add a key ui.cssurl and a value of the css file that should be loaded. It must be hosted in a way that your ArgoCD can access it without authentication.

Also there was a bug (that should be fixed in the current version) where the banner appeared empty if the ui.bannerposition wasn't set. The default of top was broken. By setting it explicitly to top it worked fine.

svghadi commented 1 month ago

Hi @aboukhal, the volume/volumeMount enhancement has been implemented in upstream operator (https://github.com/argoproj-labs/argocd-operator/pull/1477). Users can now add new vols and vol mounts to argocd-server and application-controller deployment via ArgoCD CR. It will be available in next release of gitops-operator i.e v1.14.0. I will share the documentation once the release it out.

aboukhal commented 1 month ago

Amazing, thanks a lot @svghadi

Jenson3210 commented 1 month ago

Great! Thanks a lot! We will wait for newest version to have both (volume+banner)