6

We have a setup with Traefik as the Ingress Controller / CRD and ArgoCD. We installed ArgoCD into our EKS setup as described in the Argo getting stared guide:

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Now as the docs state the IngressRoute object to configure Traefik correctly looks like this:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: argocd-server
  namespace: argocd
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(`argocd.tekton-argocd.de`)
      priority: 10
      services:
        - name: argocd-server
          port: 80
    - kind: Rule
      match: Host(`argocd.tekton-argocd.de`) && Headers(`Content-Type`, `application/grpc`)
      priority: 11
      services:
        - name: argocd-server
          port: 80
          scheme: h2c
  tls:
    certResolver: default
    

Right now there's a bug in the docs - so be sure to remove the options: {} in order to let Traefik accept the configuration.

Traefik shows everything is fine in the dashboard:

enter image description here

But if we try to access the ArgoCD dashboard at https://argocd.tekton-argocd.de we get multiple HTTP 307 redirects and can't access the dashboard in the end. You can see the redirects inside the developer tools:

enter image description here

Searching for a solution we already found this issue where the problem is described:

The problem is that by default Argo-CD handles TLS termination itself and always redirects HTTP requests to HTTPS. Combine that with an ingress controller that also handles TLS termination and always communicates with the backend service with HTTP and you get Argo-CD's server always responding with a redirects to HTTPS.

Also the solution is sketched:

So one of the solutions would be to disable HTTPS on Argo-CD, which you can do by using the --insecure flag on argocd-server.

But how can we configure the argocd-server Deployment to add the --insecure flag to the argocd-server command - as it is also stated inside the ArgoCD docs?

jonashackt
  • 12,022
  • 5
  • 67
  • 124

2 Answers2

13

0. Why a declarative ArgoCD setup with Kustomize is a great way to configure custom parameters

There are multiple options on how to configure ArgoCD. A great way is to use a declarative approach, which should be the default Kubernetes-style. Skimming the ArgoCD docs there's a additional configuration section where the possible flags of the ConfigMap argocd-cmd-params-cm can be found. The flags are described in argocd-cmd-params-cm.yaml. One of them is the flag server.insecure

## Server properties
# Run server without TLS
server.insecure: "false"

The argocd-server deployment which ships with https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml will use this parameter, if it is defined in the argocd-cmd-params-cm ConfigMap.

In order to declaratively configure the ArgoCD configuration, the ArgoCD docs have a great section on how to do that with Kustomize. In fact the ArgoCD team itself uses this approach to deploy their own ArgoCD instances - a live deployment is available here https://cd.apps.argoproj.io/ and the configuration used can be found on GitHub.

Adopting this to our use case, we need to switch our ArgoCD installation from simply using kubectl apply -f to a Kustomize-based installation. The ArgoCD docs also have a section on how to do this. Here are the brief steps:

1. Create a argocd/installation directory with a new file kustomization.yaml

We slightly enhance the kustomization.yaml proposed in the docs:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - https://raw.githubusercontent.com/argoproj/argo-cd/v2.3.3/manifests/install.yaml

## changes to config maps
patchesStrategicMerge:
  - argocd-cmd-params-cm-patch.yml

namespace: argocd

Since the docs state

It is recommended to include the manifest as a remote resource and apply additional customizations using Kustomize patches.

we use the patchesStrategicMerge configuration key, which contains another new file we need to create called argocd-cmd-params-cm-patch.yml.

2. Create a new file argocd-cmd-params-cm-patch.yml

This new file only contains the configuration we want to change inside the ConfigMap argocd-cmd-params-cm:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cmd-params-cm
data:
  server.insecure: "true"

3. Install ArgoCD using the Kustomization files & kubectl apply -k

There's a separate kustomize CLI one can install e.g. via brew install kustomize. But as Kustomize is build into kubectl we only have to use kubectl apply -k and point that to our newly created argocd/installation directory like this. We just also need to make sure that the argocd namespace is created:

kubectl create namespace argocd --dry-run=client -o yaml | kubectl apply -f -    
kubectl apply -k argocd/installation

This will install ArgoCD and configure the argocd-server deployment to use the --insecure flag as needed to stop Argo from handling the TLS termination itself and giving that responsibility to Traefik. Now accessing https://argocd.tekton-argocd.de should open the ArgoCD dashboard as expected:

enter image description here

jonashackt
  • 12,022
  • 5
  • 67
  • 124
  • 1
    Thanks! this worked for me. However, the only hitch I ran into is that I needed to completely uninstall argocd before `kubectl apply -k directory-path` otherwise I was still getting redirect issues. I uninstalled argocd with this command (note the version is specific to my installation): `kubectl delete -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.0/manifests/install.yaml` – willbush Jun 20 '22 at 23:51
  • For me, it was enough to delete the "server" pod of ArgoCD (thus having it restart). – miracle2k Sep 16 '22 at 10:10
0

You can use this traefik rule:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: argocd-server
  namespace: argocd
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(`argocd.example.com`)
      priority: 10
      services:
        - name: argocd-server
          port: 80
    - kind: Rule
      match: Host(`argocd.example.com`) && Headers(`Content-Type`, `application/grpc`)
      priority: 11
      services:
        - name: argocd-server
          port: 80
          scheme: h2c
  tls: {}

It worked for me using traefik 2.6.3.

The troubleshot is at tls: {}.

Jordi
  • 20,868
  • 39
  • 149
  • 333
  • I'm using Traefik in EKS. AWS NLB is just a pass-through but it throws "Internal server error". argocli throws error as well FATA[0004] rpc error: code = Unknown desc = POST https://argocd-dashboard.xxx.com:443/argocd/session.SessionService/Create failed with status code 500 My Traefik config - Intried inclusing certResolver as Default and my clusterissuer name, still the same result. – Chakaravarthy Natesan Sep 26 '22 at 22:37
  • Same as in argocd documentation. ` services: - name: argocd-server port: 80 - kind: Rule match: Host(argocd-dashboard.xxx.com) && Headers(Content-Type, application/grpc) priority: 11 services: - name: argocd-server port: 80 scheme: h2c tls: certResolver: traefik-letsencrypt-1 # Default or I removed this line as well, still 500 Internal error. secretName: argocd-cert # same content as in traefik-cert domains: - main: argocd-dashboard.xxxx.com ` – Chakaravarthy Natesan Sep 26 '22 at 22:37