<p>We have <a href="https://github.com/jonashackt/tekton-argocd-eks" rel="nofollow noreferrer">a full-blown setup using AWS EKS with Tekton</a> installed and want to use ArgoCD for application deployment.</p>
<p><a href="https://argo-cd.readthedocs.io/en/stable/getting_started/" rel="nofollow noreferrer">As the docs state</a> we installed ArgoCD on EKS in GitHub Actions with:</p>
<pre><code>  - name: Install ArgoCD
    run: |
      echo &quot;--- Create argo namespace and install it&quot;
      kubectl create namespace argocd --dry-run=client -o yaml | kubectl apply -f -
      kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
</code></pre>
<p>We also exposed the ArgoCD server (incl. dashboard) <a href="https://argo-cd.readthedocs.io/en/stable/getting_started/#3-access-the-argo-cd-api-server" rel="nofollow noreferrer">as the docs told us</a>:</p>
<pre><code>  - name: Expose ArgoCD Dashboard
    run: |
      echo &quot;--- Expose ArgoCD Dashboard via K8s Service&quot;
      kubectl patch svc argocd-server -n argocd -p '{&quot;spec&quot;: {&quot;type&quot;: &quot;LoadBalancer&quot;}}'

      echo &quot;--- Wait until Loadbalancer url is present (see https://stackoverflow.com/a/70108500/4964553)&quot;
      until kubectl get service/argocd-server -n argocd --output=jsonpath='{.status.loadBalancer}' | grep &quot;ingress&quot;; do : ; done
</code></pre>
<p>Finally we installed <code>argocd</code> CLI with brew:</p>
<pre><code>      echo &quot;--- Install ArgoCD CLI&quot;
      brew install argocd
</code></pre>
<p>Now how can we do a <code>argocd login</code> with GitHub Actions (without human interaction)? The <code>argocd login</code> command wants a username and password...</p>

jonashackt
<p><a href="https://argo-cd.readthedocs.io/en/stable/getting_started/#4-login-using-the-cli" rel="nofollow noreferrer">The same docs tell us how to extract the password</a> for argo with:</p>
<pre><code>kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=&quot;{.data.password}&quot; | base64 -d; echo
</code></pre>
<p>Obtaining the ArgoCD server's <code>hostname</code> is also no big deal using:</p>
<pre><code>kubectl get service argocd-server -n argocd --output=jsonpath='{.status.loadBalancer.ingress[0].hostname}'
</code></pre>
<p>And as the <code>argocd login</code> command has the parameters <code>--username</code> and <code>--password</code>, <strong>we can craft our login command like this</strong>:</p>
<pre><code>argocd login $(kubectl get service argocd-server -n argocd --output=jsonpath='{.status.loadBalancer.ingress[0].hostname}') --username admin --password $(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=&quot;{.data.password}&quot; | base64 -d; echo) --insecure
</code></pre>
<p>Mind the <code>--insecure</code> to prevent the argo CLI from asking things like <code>WARNING: server certificate had error: x509: certificate is valid for localhost, argocd-server, argocd-server.argocd, argocd-server.argocd.svc, argocd-server.argocd.svc.cluster.local, not a5f715808162c48c1af54069ba37db0e-1371850981.eu-central-1.elb.amazonaws.com. Proceed insecurely (y/n)?</code>.</p>
<p>The successful login should somehow look like this in the GitHub Actions UI (see <a href="https://github.com/jonashackt/tekton-argocd-eks/runs/5105912670?check_suite_focus=true" rel="nofollow noreferrer">a full log here</a>):</p>
<pre><code>'admin:login' logged in successfully
Context 'a5f715808162c48c1af54069ba37db0e-1371850981.eu-central-1.elb.amazonaws.com' updated
</code></pre>
<p>Now your GitHub Actions workflow should be able to interact with the ArgoCD server.</p>
<h2>Prevent error <code>FATA[0000] dial tcp: lookup a965bfb530e8449f5a355f221b2fd107-598531793.eu-central-1.elb.amazonaws.com on 8.8.8.8:53: no such host</code></h2>
<p>This error arises if the <code>argocd-server</code> Kubernetes service is freshly installed right before the <code>argocd login</code> command is run. Then the <code>argocd login</code> command failes for some time until it finally will work correctly.</p>
<p>Assuming some DNS propagation issues we can prevent this error from breaking our CI pipeline by wrapping our <code>argocd login</code> command into an <code>until</code> like already done <a href="https://stackoverflow.com/a/70108997/4964553">in this answer</a>. The full command will then look like this:</p>
<pre class="lang-sh prettyprint-override"><code>until argocd login $(kubectl get service argocd-server -n argocd --output=jsonpath='{.status.loadBalancer.ingress[0].hostname}') --username admin --password $(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=&quot;{.data.password}&quot; | base64 -d; echo) --insecure; do : ; done
</code></pre>
<p>In GitHub Actions this will then look somehow like this:</p>
<pre><code>--- Login argocd CLI - now wrapped in until to prevent FATA[0000] dial tcp: lookup 12345.eu-central-1.elb.amazonaws.com on 8.8.8.8:53: no such host
time=&quot;2022-02-21T12:57:32Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
time=&quot;2022-02-21T12:57:35Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
time=&quot;2022-02-21T12:57:37Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
[...]
time=&quot;2022-02-21T12:58:27Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
time=&quot;2022-02-21T12:58:30Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
time=&quot;2022-02-21T12:58:32Z&quot; level=fatal msg=&quot;dial tcp: lookup a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com on 127.0.0.53:53: no such host&quot;
'admin:login' logged in successfully
Context 'a071bed7e9ea14747951b04360133141-459093397.eu-central-1.elb.amazonaws.com' updated
</code></pre>
<p><a href="https://github.com/jonashackt/tekton-argocd-eks/runs/5274400263?check_suite_focus=true" rel="nofollow noreferrer">Here's also a log</a>.</p>
