github.com/argoproj/argo-cd/v2@v2.10.5/docs/developer-guide/running-locally.md (about)

     1  # Running Argo CD locally
     2  
     3  ## Run Argo CD outside of Kubernetes
     4  
     5  During development, it might be viable to run Argo CD outside a Kubernetes 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.
     6  
     7  You will still need a working Kubernetes cluster, as described in the [Toolchain Guide](toolchain-guide.md), where Argo CD will store all of its resources and configuration.
     8  
     9  If you followed the [Toolchain Guide](toolchain-guide.md) in setting up your toolchain, you can run Argo CD locally with these simple steps:
    10  
    11  ### Install Argo CD resources to your cluster
    12  
    13  First push the installation manifest into argocd namespace:
    14  
    15  ```shell
    16  kubectl create namespace argocd
    17  kubectl apply -n argocd --force -f manifests/install.yaml
    18  ```
    19  
    20  ### Scale down any Argo CD instance in your cluster
    21  
    22  Make sure that Argo CD is not running in your development cluster by scaling down the deployments:
    23  
    24  ```shell
    25  kubectl -n argocd scale statefulset/argocd-application-controller --replicas 0
    26  kubectl -n argocd scale deployment/argocd-dex-server --replicas 0
    27  kubectl -n argocd scale deployment/argocd-repo-server --replicas 0
    28  kubectl -n argocd scale deployment/argocd-server --replicas 0
    29  kubectl -n argocd scale deployment/argocd-redis --replicas 0
    30  kubectl -n argocd scale deployment/argocd-applicationset-controller --replicas 0
    31  kubectl -n argocd scale deployment/argocd-notifications-controller --replicas 0
    32  ```
    33  
    34  ### Start local services (virtualized toolchain inside Docker)
    35  
    36  The started services assume you are running in the namespace where Argo CD is installed. You can set the current context default namespace as follows:
    37  
    38  ```bash
    39  kubectl config set-context --current --namespace=argocd
    40  ```
    41  
    42  When you use the virtualized toolchain, starting local services is as simple as running
    43  
    44  ```bash
    45  make start
    46  ```
    47  
    48  This will start all Argo CD services and the UI in a Docker container and expose the following ports to your host:
    49  
    50  * The Argo CD API server on port 8080
    51  * The Argo CD UI server on port 4000
    52  * The Helm registry server on port 5000
    53  
    54  You may get an error listening on port 5000 on macOS:
    55  
    56  ```text
    57  docker: Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use.
    58  ```
    59  
    60  In that case, you can disable "AirPlay Receiver" in macOS System Preferences.
    61  
    62  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.
    63  
    64  As an alternative to using the above command line parameters each time you call `argocd` CLI, you can set the following environment variables:
    65  
    66  ```bash
    67  export ARGOCD_SERVER=127.0.0.1:8080
    68  export ARGOCD_OPTS="--plaintext --insecure"
    69  ```
    70  
    71  ### Start local services (running on local machine)
    72  
    73  The `make start` command of the virtualized toolchain runs the build and programs inside a Docker container using the test tools image. That makes everything repeatable, but can slow down the development workflow. Particularly on macOS where Docker and the Linux kernel run inside a VM, you may want to try developing fully locally.
    74  
    75  Docker should be installed already. Assuming you manage installed software using [Homebrew](https://brew.sh/), you can install other prerequisites like this:
    76  
    77  ```sh
    78  # goreman is used to start all needed processes to get a working Argo CD development
    79  # environment (defined in `Procfile`)
    80  brew install goreman
    81  
    82  # You can use `kind` to run Kubernetes inside Docker. But pointing to any other
    83  # development cluster works fine as well as long as Argo CD can reach it.
    84  brew install kind
    85  ```
    86  
    87  To set up Kubernetes, you can use kind:
    88  
    89  ```sh
    90  kind create cluster --kubeconfig ~/.kube/config-kind
    91  
    92  # The started services assume you are running in the namespace where Argo CD is
    93  # installed. Set the current context default namespace.
    94  export KUBECONFIG=~/.kube/config-kind
    95  kubectl config set-context --current --namespace=argocd
    96  ```
    97  
    98  Follow the above sections "Install Argo CD resources to your cluster" and "Scale down any Argo CD instance in your cluster" to deploy all needed manifests such as config maps.
    99  
   100  Start local services:
   101  
   102  ```sh
   103  # Ensure you point to the correct Kubernetes cluster as shown above. For example:
   104  export KUBECONFIG=~/.kube/config-kind
   105  
   106  make start-local
   107  ```
   108  
   109  This will start all Argo CD services and the UI in a Docker container and expose the following ports to your host:
   110  
   111  * The Argo CD API server on port 8080
   112  * The Argo CD UI server on port 4000
   113  * The Helm registry server on port 5000
   114  
   115  If you get firewall dialogs, for example on macOS, you can click "Deny", since no access from outside your computer is typically desired.
   116  
   117  Check that all programs have started:
   118  
   119  ```text
   120  $ goreman run status
   121  *controller
   122  *api-server
   123  [...]
   124  ```
   125  
   126  If not all critical processes run (marked with `*`), check logs to see why they terminated.
   127  
   128  In case of an error like `gpg: key generation failed: Unknown elliptic curve` (a [gnupg bug](https://dev.gnupg.org/T5444)), disable GPG verification before running `make start-local`:
   129  
   130  ```sh
   131  export ARGOCD_GPG_ENABLED=false
   132  ```
   133  
   134  You may get an error listening on port 5000 on macOS:
   135  
   136  ```text
   137  docker: Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use.
   138  ```
   139  
   140  In that case, you can disable "AirPlay Receiver" in macOS System Preferences.
   141  
   142  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.
   143  
   144  As an alternative to using the above command line parameters each time you call `argocd` CLI, you can set the following environment variables:
   145  
   146  ```bash
   147  export ARGOCD_SERVER=127.0.0.1:8080
   148  export ARGOCD_OPTS="--plaintext --insecure"
   149  ```
   150  
   151  After making a code change, ensure to rebuild and restart the respective service:
   152  
   153  ```sh
   154  # Example for working on the repo server Go code, see other service names in `Procfile`
   155  goreman run restart repo-server
   156  ```
   157  
   158  Clean up when you're done:
   159  
   160  ```sh
   161  kind delete cluster; rm -f ~/.kube/config-kind
   162  ```
   163  
   164  ### Scale up Argo CD in your cluster
   165  
   166  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:
   167  
   168  ```bash
   169  kubectl -n argocd scale statefulset/argocd-application-controller --replicas 1
   170  kubectl -n argocd scale deployment/argocd-dex-server --replicas 1
   171  kubectl -n argocd scale deployment/argocd-repo-server --replicas 1
   172  kubectl -n argocd scale deployment/argocd-server --replicas 1
   173  kubectl -n argocd scale deployment/argocd-redis --replicas 1
   174  ```
   175  
   176  ## Run your own Argo CD images on your cluster
   177  
   178  For your final tests, it might be necessary to build your own images and run them in your development cluster.
   179  
   180  ### Create Docker account and login
   181  
   182  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:
   183  
   184  ```bash
   185  docker login
   186  ```
   187  
   188  ### Create and push Docker images
   189  
   190  You will need to push the built images to your own Docker namespace:
   191  
   192  ```bash
   193  export IMAGE_NAMESPACE=youraccount
   194  ```
   195  
   196  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:
   197  
   198  ```bash
   199  export IMAGE_TAG=1.5.0-myrc
   200  ```
   201  
   202  Then you can build & push the image in one step:
   203  
   204  ```bash
   205  DOCKER_PUSH=true make image
   206  ```
   207  
   208  ### Configure manifests for your image
   209  
   210  With `IMAGE_NAMESPACE` and `IMAGE_TAG` still set, run:
   211  
   212  ```bash
   213  make manifests
   214  ```
   215  
   216  to build a new set of installation manifests which include your specific image reference.
   217  
   218  !!!note
   219      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.
   220  
   221  ### Configure your cluster with custom manifests
   222  
   223  The final step is to push the manifests to your cluster, so it will pull and run your image:
   224  
   225  ```bash
   226  kubectl apply -n argocd --force -f manifests/install.yaml
   227  ```