2019-02-21 16:30:13 +00:00
# Contributing
2019-10-17 02:58:42 +00:00
2019-02-11 18:38:43 +00:00
## Before You Start
You must install and run the ArgoCD using a local Kubernetes (e.g. Docker for Desktop or Minikube) first. This will help you understand the application, but also get your local environment set-up.
Then, to get a good grounding in Go, try out [the tutorial ](https://tour.golang.org/ ).
2019-02-21 16:30:13 +00:00
## Pre-requisites
2019-02-11 18:38:43 +00:00
Install:
2018-07-27 23:51:44 +00:00
* [docker ](https://docs.docker.com/install/#supported-platforms )
2019-07-23 09:32:14 +00:00
* [git ](https://git-scm.com/ ) and [git-lfs ](https://git-lfs.github.com/ )
2018-07-27 23:51:44 +00:00
* [golang ](https://golang.org/ )
* [dep ](https://github.com/golang/dep )
* [ksonnet ](https://github.com/ksonnet/ksonnet#install )
* [helm ](https://github.com/helm/helm/releases )
2018-08-15 21:54:56 +00:00
* [kustomize ](https://github.com/kubernetes-sigs/kustomize/releases )
2019-04-17 17:53:37 +00:00
* [kubectl ](https://kubernetes.io/docs/tasks/tools/install-kubectl/ )
* [kubectx ](https://kubectx.dev )
2019-02-11 18:38:43 +00:00
* [minikube ](https://kubernetes.io/docs/setup/minikube/ ) or Docker for Desktop
2018-03-12 21:41:46 +00:00
2019-04-17 17:53:37 +00:00
Brew users can quickly install the lot:
2019-10-17 02:58:42 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-10-17 02:58:42 +00:00
brew install go git-lfs kubectl kubectx dep ksonnet/tap/ks kubernetes-helm kustomize
2019-10-15 16:15:33 +00:00
```
Check the versions:
2019-10-17 02:58:42 +00:00
```bash
2019-10-15 16:15:33 +00:00
go version ;# must be v1.12.x
helm version ;# must be v2.13.x
2019-11-15 19:19:33 +00:00
kustomize version ;# must be v3.1.x
2018-03-12 21:41:46 +00:00
```
2019-02-11 18:38:43 +00:00
Set up environment variables (e.g. is `~/.bashrc` ):
2018-03-12 21:41:46 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-02-11 18:38:43 +00:00
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin
```
2019-05-28 18:39:13 +00:00
Checkout the code:
```bash
go get -u github.com/argoproj/argo-cd
cd ~/go/src/github.com/argoproj/argo-cd
```
2018-02-18 21:16:24 +00:00
## Building
2018-03-12 21:41:46 +00:00
2019-07-21 04:02:40 +00:00
Ensure dependencies are up to date first:
```shell
2019-09-10 20:29:16 +00:00
dep ensure
2019-11-11 17:37:46 +00:00
make dev-tools-image
2019-10-11 18:55:48 +00:00
make install-lint-tools
2018-03-12 21:41:46 +00:00
```
2019-02-11 18:38:43 +00:00
2019-10-15 16:15:33 +00:00
Common make targets:
2019-02-11 18:38:43 +00:00
2019-10-15 16:15:33 +00:00
* `make codegen` - Run code generation
* `make lint` - Lint code
* `make test` - Run unit tests
* `make cli` - Make the `argocd` CLI tool
2018-07-30 23:13:54 +00:00
2019-04-15 20:50:46 +00:00
Check out the following [documentation ](https://github.com/argoproj/argo-cd/blob/master/docs/developer-guide/test-e2e.md ) for instructions on running the e2e tests.
2018-03-12 21:41:46 +00:00
2019-02-11 18:38:43 +00:00
## Running Locally
2018-03-12 21:41:46 +00:00
2019-02-11 18:38:43 +00:00
It is much easier to run and debug if you run ArgoCD on your local machine than in the Kubernetes cluster.
2019-04-03 22:11:48 +00:00
You should scale the deployments to zero:
2019-02-11 18:38:43 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-10-14 15:34:23 +00:00
kubectl -n argocd scale deployment/argocd-application-controller --replicas 0
kubectl -n argocd scale deployment/argocd-dex-server --replicas 0
kubectl -n argocd scale deployment/argocd-repo-server --replicas 0
kubectl -n argocd scale deployment/argocd-server --replicas 0
kubectl -n argocd scale deployment/argocd-redis --replicas 0
2019-02-11 18:38:43 +00:00
```
2019-09-10 20:29:16 +00:00
Download Yarn dependencies and Compile:
```bash
2019-10-17 02:58:42 +00:00
~/go/src/github.com/argoproj/argo-cd/ui
2019-09-10 20:29:16 +00:00
yarn install
yarn build
```
2019-02-20 22:19:07 +00:00
2019-02-11 18:38:43 +00:00
Then start the services:
2018-03-12 21:41:46 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-02-11 18:38:43 +00:00
cd ~/go/src/github.com/argoproj/argo-cd
2019-04-03 22:11:48 +00:00
make start
2018-03-12 21:41:46 +00:00
```
2019-02-11 18:38:43 +00:00
You can now execute `argocd` command against your locally running ArgoCD by appending `--server localhost:8080 --plaintext --insecure` , e.g.:
2018-03-12 21:41:46 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-09-10 20:29:16 +00:00
argocd app create guestbook --path guestbook --repo https://github.com/argoproj/argocd-example-apps.git --dest-server https://kubernetes.default.svc --dest-namespace default --server localhost:8080 --plaintext --insecure
2019-02-11 18:38:43 +00:00
```
2019-10-17 02:58:42 +00:00
You can open the UI: [http://localhost:4000 ](http://localhost:4000 )
2019-02-11 18:38:43 +00:00
2019-10-14 15:34:23 +00:00
As an alternative to using the above command line parameters each time you call `argocd` CLI, you can set the following environment variables:
```bash
export ARGOCD_SERVER=127.0.0.1:8080
export ARGOCD_OPTS="--plaintext --insecure"
```
2019-02-20 22:19:07 +00:00
## Running Local Containers
You may need to run containers locally, so here's how:
Create login to Docker Hub, then login.
2019-04-05 22:12:27 +00:00
```bash
2019-02-20 22:19:07 +00:00
docker login
```
Add your username as the environment variable, e.g. to your `~/.bash_profile` :
2019-04-05 22:12:27 +00:00
```bash
2019-02-20 22:19:07 +00:00
export IMAGE_NAMESPACE=alexcollinsintuit
```
2019-10-14 15:34:23 +00:00
If you don't want to use `latest` as the image's tag (the default), you can set it from the environment too:
2019-02-20 22:19:07 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-10-14 15:34:23 +00:00
export IMAGE_TAG=yourtag
2019-02-20 22:19:07 +00:00
```
2019-10-14 15:34:23 +00:00
Build the image:
2019-02-20 22:19:07 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-02-20 22:19:07 +00:00
DOCKER_PUSH=true make image
```
2019-10-14 15:34:23 +00:00
Update the manifests (be sure to do that from a shell that has above environment variables set)
2019-02-20 22:19:07 +00:00
2019-04-05 22:12:27 +00:00
```bash
2019-02-20 22:19:07 +00:00
make manifests
```
Install the manifests:
2019-04-05 22:12:27 +00:00
```bash
2019-02-20 22:19:07 +00:00
kubectl -n argocd apply --force -f manifests/install.yaml
```
Scale your deployments up:
2019-04-05 22:12:27 +00:00
```bash
2019-10-14 15:34:23 +00:00
kubectl -n argocd scale deployment/argocd-application-controller --replicas 1
kubectl -n argocd scale deployment/argocd-dex-server --replicas 1
kubectl -n argocd scale deployment/argocd-repo-server --replicas 1
kubectl -n argocd scale deployment/argocd-server --replicas 1
kubectl -n argocd scale deployment/argocd-redis --replicas 1
2019-02-20 22:19:07 +00:00
```
2019-04-05 22:12:27 +00:00
Now you can set-up the port-forwarding and open the UI or CLI.