Skip to content

Instantly share code, notes, and snippets.

@anais-codefresh
Last active December 21, 2020 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anais-codefresh/070bbf7e63657b1349d83d32b6b2c7b9 to your computer and use it in GitHub Desktop.
Save anais-codefresh/070bbf7e63657b1349d83d32b6b2c7b9 to your computer and use it in GitHub Desktop.
GitOps 2.0 hands-on workshop: Setting up your repositories with ArgoCD and Codefresh
This set-up is based on the following guides:
* https://codefresh.io/docs/docs/ci-cd-guides/gitops-deployments/
* https://codefresh.io/docs/docs/integrations/argo-cd/
* https://argoproj.github.io/argo-cd/getting_started/
Using this repository:
* https://github.com/anais-codefresh/react-article-display
## Prerequisites
1. Codefresh account (either trial version or pro to have access to the GitOps Dashboard)
2. Cloud cluster integrated to your Codefresh Accounnt -- if not, [set-it up now](https://codefresh.io/docs/docs/deploy-to-kubernetes/add-kubernetes-cluster/)
Additionally, you want to be connected to the same cloud cluster in your terminal.
## Set-up ArgoCD
First we are going to create a home for ArgoCD
```
kubectl create namespace argocd
```
Next we can install all resources needed for Argo in the newly created namespace
```
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
```
Next, we install the ArgoCD client
```
brew install argocd
```
Expose the ArgoCD API server
```
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
```
And now access the UI locally by forwarding the port
```
kubectl port-forward svc/argocd-server -n argocd 8080:443
```
Open the UI on http://localhost:8080/
* The username is ’admin’
* The password can be accessed through the following command
```
kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2
```
Make sure to change your password
```
argocd account update-password
```
## Set-up your application
You can either [clone this respository](https://github.com/anais-codefresh/react-article-display)
or
Use your own application, as long as it has Kubernetes manifests, a Helm Chart, Kustomize,
or similar to define your Kubernetes resources.
If using the Argo UI
* Sync manaually
* Choose the cluster where ArgoCD is running; otherwise, check-out the ArgoCD documentation for further details
* Make sure that ArgoCD knows where your Helm Chart and other Kubernetes resources are
Next, make sure that your application is in sync with your git resources. This can be done by just triggering the sync in the UI.
## Install the Codefresh Runner
Now we want to connect ArgoCD to Codefresh. For this, we are going to install the Codefresh CI
```
npm install -g codefresh
```
and then we can connect the ArgoCD runner on our cluster
```
codefresh install gitops argocd-agent
```
It will ask you about several configuration options:
* Make sure to connect to the cloud cluster
* Provide your ArgoCD username and password
* In our case, we want to make sure that resources are auto-synced between Codefresh and ArgoCD
Now we can head over to Codefresh UI and view our application from ArgoCD in the DevOps Insights.
You can create your pipeline in Codefresh using the documentation: https://codefresh.io/docs/docs/ci-cd-guides/gitops-deployments/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment