github.com/argoproj/argo-cd/v3@v3.2.1/docs/developer-guide/running-locally.md (about) 1 # Running Argo CD locally 2 3 ## Prerequisites 4 1. [Development Environment](development-environment.md) 5 2. [Toolchain Guide](toolchain-guide.md) 6 3. [Development Cycle](development-cycle.md) 7 8 ## Preface 9 During development, it is recommended to start with Argo CD running locally (outside of a K8s cluster). This will greatly speed up development, as you don't have to constantly build, push and install new Argo CD Docker images with your latest changes. 10 11 After you have tested locally, you can move to the second phase of building a docker image, running Argo CD in your cluster and testing further. 12 13 For both cases, you will need a working K8s cluster, where Argo CD will store all of its resources and configuration. 14 15 In order to have all the required resources in your cluster, you will deploy Argo CD from your development branch and then scale down all it's instances. 16 This will ensure you have all the relevant configuration (such as Argo CD Config Maps and CRDs) in the cluster while the instances themselves are stopped. 17 18 ### Deploy Argo CD resources to your cluster 19 20 First push the installation manifest into argocd namespace: 21 22 ```shell 23 kubectl create namespace argocd 24 kubectl apply -n argocd --force -f manifests/install.yaml 25 ``` 26 27 The services you will start later assume you are running in the namespace where Argo CD is installed. You can set the current context default namespace as follows: 28 29 ```bash 30 kubectl config set-context --current --namespace=argocd 31 ``` 32 33 ### Scale down any Argo CD instance in your cluster 34 35 Make sure that Argo CD is not running in your development cluster by scaling down the deployments: 36 37 ```shell 38 kubectl -n argocd scale statefulset/argocd-application-controller --replicas 0 39 kubectl -n argocd scale deployment/argocd-dex-server --replicas 0 40 kubectl -n argocd scale deployment/argocd-repo-server --replicas 0 41 kubectl -n argocd scale deployment/argocd-server --replicas 0 42 kubectl -n argocd scale deployment/argocd-redis --replicas 0 43 kubectl -n argocd scale deployment/argocd-applicationset-controller --replicas 0 44 kubectl -n argocd scale deployment/argocd-notifications-controller --replicas 0 45 ``` 46 47 ## Running Argo CD locally, outside of K8s cluster 48 #### Prerequisites 49 1. [Deploy Argo CD resources to your cluster](running-locally.md#deploy-argo-cd-resources-to-your-cluster) 50 2. [Scale down any Argo CD instance in your cluster](running-locally.md#scale-down-any-argo-cd-instance-in-your-cluster) 51 52 ### Start local services (virtualized toolchain) 53 When you use the virtualized toolchain, starting local services is as simple as running 54 55 ```bash 56 cd argo-cd 57 make start 58 ``` 59 60 By default, Argo CD uses Docker. To use Podman instead, set the `DOCKER` environment variable to `podman` before running the `make` command: 61 62 ```shell 63 cd argo-cd 64 DOCKER=podman make start 65 ``` 66 67 This will start all Argo CD services and the UI in a Docker container and expose the following ports to your host: 68 69 * The Argo CD API server on port 8080 70 * The Argo CD UI server on port 4000 71 * The Helm registry server on port 5000 72 73 You can now use either the web UI by pointing your browser to `http://localhost:4000` or use the CLI against the API at `http://localhost:8080`. Be sure to use the `--insecure` and `--plaintext` options to the CLI. Webpack will take a while to bundle resources initially, so the first page load can take several seconds or minutes. 74 75 As an alternative to using the above command line parameters each time you call `argocd` CLI, you can set the following environment variables: 76 77 ```bash 78 export ARGOCD_SERVER=127.0.0.1:8080 79 export ARGOCD_OPTS="--plaintext --insecure" 80 ``` 81 82 ### Start local services (local toolchain) 83 When you use the local toolchain, starting local services can be performed in 3 ways: 84 85 #### With "make start-local" 86 ```shell 87 cd argo-cd 88 make start-local ARGOCD_GPG_ENABLED=false 89 ``` 90 91 #### With "make run" 92 ```shell 93 cd argo-cd 94 make run ARGOCD_GPG_ENABLED=false 95 ``` 96 97 #### With "goreman start" 98 ```shell 99 cd argo-cd 100 ARGOCD_GPG_ENABLED=false && goreman start 101 ``` 102 103 Any of those options will start all Argo CD services and the UI: 104 105 * The Argo CD API server on port 8080 106 * The Argo CD UI server on port 4000 107 * The Helm registry server on port 5000 108 109 110 Check that all programs have started: 111 112 ```text 113 $ goreman run status 114 *controller 115 *api-server 116 [...] 117 ``` 118 119 If some of the processes fail to start (not marked with `*`), check logs to see why they are not running. The logs are on `DEBUG` level by default. If the logs are too noisy to find the problem, try editing log levels for the commands in the `Procfile` in the root of the Argo CD repo. 120 121 You can now use either use the web UI by pointing your browser to `http://localhost:4000` or use the CLI against the API at `http://localhost:8080`. Be sure to use the `--insecure` and `--plaintext` options to the CLI. Webpack will take a while to bundle resources initially, so the first page load can take several seconds or minutes. 122 123 As an alternative to using the above command line parameters each time you call `argocd` CLI, you can set the following environment variables: 124 125 ```bash 126 export ARGOCD_SERVER=127.0.0.1:8080 127 export ARGOCD_OPTS="--plaintext --insecure" 128 ``` 129 ### Making code changes while Argo CD is running on your machine 130 131 #### Docs Changes 132 133 Modifying the docs auto-reloads the changes on the [documentation website](https://argo-cd.readthedocs.io/) that can be locally built using `make serve-docs-local` command. 134 Once running, you can view your locally built documentation on port 8000. 135 136 Read more about this [here](https://argo-cd.readthedocs.io/en/latest/developer-guide/docs-site/). 137 138 #### UI Changes 139 140 Modifying the User-Interface (by editing .tsx or .scss files) auto-reloads the changes on port 4000. 141 142 #### Backend Changes 143 144 Modifying the API server, repo server, or a controller requires restarting the current `make start` for virtualized toolchain. 145 For `make start-local` with the local toolchain, it is enough to rebuild and restart only the respective service: 146 147 ```sh 148 # Example for working on the repo server Go code, see other service names in `Procfile` 149 goreman run restart repo-server 150 ``` 151 152 #### CLI Changes 153 154 Modifying the CLI requires restarting the current `make start` or `make start-local` session to reflect the changes. Those targets also rebuild the CLI. 155 156 To test most CLI commands, you will need to log in. 157 158 First, get the auto-generated secret: 159 160 ```shell 161 kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo 162 ``` 163 164 Then log in using that password and username `admin`: 165 166 ```shell 167 dist/argocd login localhost:8080 168 ``` 169 170 ## Running Argo CD inside of K8s cluster 171 ### Scale up Argo CD in your cluster 172 173 Once you have finished testing your changes locally and want to bring back Argo CD in your development cluster, simply scale the deployments up again: 174 175 ```bash 176 kubectl -n argocd scale statefulset/argocd-application-controller --replicas 1 177 kubectl -n argocd scale deployment/argocd-applicationset-controller --replicas 1 178 kubectl -n argocd scale deployment/argocd-dex-server --replicas 1 179 kubectl -n argocd scale deployment/argocd-repo-server --replicas 1 180 kubectl -n argocd scale deployment/argocd-server --replicas 1 181 kubectl -n argocd scale deployment/argocd-redis --replicas 1 182 kubectl -n argocd scale deployment/argocd-notifications-controller --replicas 1 183 ``` 184 185 ### Run your own Argo CD images on your cluster 186 187 For your final tests, it might be necessary to build your own images and run them in your development cluster. 188 189 #### Create Docker account and login 190 191 You might need to create an account on [Docker Hub](https://hub.docker.com) if you don't have one already. Once you created your account, login from your development environment: 192 193 ```bash 194 docker login 195 ``` 196 197 #### Create and push Docker images 198 199 You will need to push the built images to your own Docker namespace: 200 201 ```bash 202 export IMAGE_NAMESPACE=youraccount 203 ``` 204 205 If you don't set `IMAGE_TAG` in your environment, the default of `:latest` will be used. To change the tag, export the variable in the environment: 206 207 ```bash 208 export IMAGE_TAG=1.5.0-myrc 209 ``` 210 211 Then you can build & push the image in one step: 212 213 ```bash 214 DOCKER_PUSH=true make image 215 ``` 216 217 #### Configure manifests for your image 218 219 With `IMAGE_NAMESPACE` and `IMAGE_TAG` still set, run: 220 221 ```bash 222 make manifests 223 ``` 224 225 or 226 227 ```bash 228 make manifests-local 229 ``` 230 231 (depending on your toolchain) to build a new set of installation manifests which include your specific image reference. 232 233 !!!note 234 Do not commit these manifests to your repository. If you want to revert the changes, the easiest way is to unset `IMAGE_NAMESPACE` and `IMAGE_TAG` from your environment and run `make manifests` again. This will re-create the default manifests. 235 236 #### Configure your cluster with custom manifests 237 238 The final step is to push the manifests to your cluster, so it will pull and run your image: 239 240 ```bash 241 kubectl apply -n argocd --force -f manifests/install.yaml 242 ```