├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── Vagrantfile ├── ansible-requirements.yaml ├── argocd-nutshell.yaml ├── config ├── core.yaml ├── default.yaml └── sso.yaml ├── kube └── metallb │ ├── crd │ └── kustomization.yaml │ └── install │ ├── config.yaml │ ├── configmap.yaml │ ├── kustomization.yaml │ └── secret.yaml ├── roles ├── core-argocd │ └── tasks │ │ └── main.yml ├── core-kubernetes │ └── tasks │ │ └── main.yml ├── core-tools │ └── tasks │ │ └── main.yml └── feat-git │ ├── tasks │ ├── git.yml │ └── main.yml │ └── templates │ └── nginx │ └── nginx.conf └── variants ├── core ├── base │ └── kustomization.yaml ├── overlays │ └── argocd-cm.yaml └── patches │ ├── argocd-application-controller.json │ ├── argocd-secret.json │ └── argocd-server.json ├── default ├── base │ └── kustomization.yaml ├── overlays │ ├── argocd-cm.yaml │ └── argocd-server-service.yaml └── patches │ ├── argocd-application-controller.json │ ├── argocd-secret.json │ └── argocd-server.json └── sso ├── base └── kustomization.yaml └── overlays └── argocd-cm.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | .vscode 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog for Argo CD in a nutshell 2 | 3 | ## Unreleased 4 | 5 | ## v0.0.2 - 2020-01-16 6 | 7 | * Make k3s auto-decide on latest version 8 | * Pull in all roles for Kustomize, not just the specified one 9 | * Pull in firefox for CLI SSO and some new variables. 10 | * Allow SSH X11 forwarding in the VM 11 | * New SSO variant for use with GitHub 12 | * Disable traefik to prevent race for metallb IP 13 | 14 | ## v0.0.1 - 2020-01-11 15 | 16 | Initial release 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Jann Fischer 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Argo CD in a nutshell 2 | 3 | Zero-conf, repeatable 4 | [Argo CD](https://argoproj.github.io/argo-cd/) 5 | environments for demoing, development purposes or troubleshooting (i.e. to 6 | reproduce an issue on a clean environment) using 7 | [Vagrant](https://www.vagrantup.com/) 8 | and 9 | [k3s](https://k3s.io/) 10 | in a single-node setup. 11 | 12 | Please be aware that this is work in progress, and mainly serves for my own 13 | purposes. I thought it could be useful enough to share, however, so here it 14 | is. 15 | 16 | ## Getting started 17 | 18 | You will need 19 | [Vagrant](https://www.vagrantup.com/) 20 | and 21 | [VirtualBox](https://www.virtualbox.org/) 22 | installed on your system. Also, this box will set-up a private network with 23 | CIDR range `192.168.56.0/24`, so make sure you don't have this already 24 | setup on your host, or have a route to an already existing net or host in 25 | that range. 26 | 27 | Then: 28 | 29 | ```bash 30 | git clone https://github.com/jannfis/argocd-nutshell 31 | cd argocd-nutshell 32 | vagrant up 33 | ``` 34 | 35 | This will fire up a VM with the default variant of Argo CD up & running. This 36 | can take a couple of minutes, depending on your network speed and general 37 | computer performance specs. 38 | 39 | To make sure everything is up & running, `ssh` into the box and check the pods 40 | status: 41 | 42 | ```shell 43 | $ vagrant ssh 44 | vagrant@argocd-nutshell:~$ kubectl get pods -n argocd 45 | NAME READY STATUS RESTARTS AGE 46 | argocd-redis-6fb68d9df5-sx7xh 1/1 Running 0 4m30s 47 | argocd-dex-server-748c65b578-kqlpp 1/1 Running 0 4m30s 48 | argocd-application-controller-0 1/1 Running 0 4m30s 49 | argocd-repo-server-64f4ddf469-mbdzn 1/1 Running 0 4m30s 50 | argocd-server-846cf6844-9dvcl 1/1 Running 0 4m30s 51 | ``` 52 | 53 | If all pods are running correctly, you can then access the web UI by visiting 54 | 55 | ```shell 56 | https://192.168.56.100 57 | ``` 58 | 59 | The default username is `admin`, and the default password is `admin` as well. 60 | 61 | ## Teardown 62 | 63 | When you had enough testing, simply run 64 | 65 | ```bash 66 | vagrant destroy -f 67 | ``` 68 | 69 | within the directory that contains the `Vagrantfile`. 70 | 71 | ## What's in it? 72 | 73 | On top of the already mentioned K3s cluster and a default installation 74 | of Argo CD with minor customisation (i.e. service of type LoadBalancer and 75 | an admin password set), the following is currently included after the box 76 | has been provisioned: 77 | 78 | * `kubectl` pre-configured and with shell completion set-up 79 | * `kubectx` and `kubens` too, also with shell completion set-up 80 | * a `kustomize` binary in `/usr/local/bin` (version 3.9.1) 81 | * The latest released `argocd` CLI, ready to use logged into the Argo CD 82 | instance 83 | 84 | ## Versions 85 | 86 | By default, the most recent stable versions of Argo CD and K3S will be 87 | installed in the box. 88 | 89 | You can override (pin) the versions installed by the `default` variant by 90 | setting some environment variables before running `vagrant up`: 91 | 92 | * `ARGOCD_VERSION`: This lets you specify another version of the manifests 93 | to install. This can be either a tag name (such as `v1.8.2` or `stable`), 94 | or use `HEAD` to use the latest manifests from `master` branch. 95 | 96 | * `ARGOCD_CLI_VERSION`: Lets you specify the release tag of the Argo CD CLI 97 | to install. The special value `latest` (which is also the default) will 98 | look up the latest released version of the CLI from GitHub and install it. 99 | 100 | * `ARGOCD_IMAGE`: Lets you override the Argo CD container image to use with 101 | the manifests. This must be the full path and tag to the image, e.g. 102 | `quay.io/argoproj/argocd:v1.8.2`. By default, the images as defined in the 103 | manifests will be used. 104 | 105 | * `K3S_VERSION`: The fully qualified version of K3S to install, e.g. 106 | `v1.20.0+k3s2`. Look at the 107 | [K3s releases](https://github.com/k3s-io/k3s/releases) for valid versions. 108 | Pre-releases are not supported by the installer. 109 | 110 | For example, if you want to install Argo CD v1.7.11 with accompanying CLI on a 111 | Kubernetes 1.18.6 cluster, create the box as follows: 112 | 113 | ```bash 114 | ARGOCD_VERSION=v1.7.11 ARGOCD_CLI_VERSION=v1.7.11 K3S_VERSION=v1.18.6+k3s1 vagrant up 115 | ``` 116 | 117 | ## Git repository with test data 118 | 119 | In order to have some test cases ready to use with the new Argo CD environment, 120 | you can have the script automatically setup a Git repository server which 121 | serves a configurable repository clone. It can be activated by setting the 122 | following environment variable before running `vagrant up`: 123 | 124 | ```bash 125 | GIT_ENABLED=true 126 | ``` 127 | 128 | The following environment variables control what is set up: 129 | 130 | * `GIT_CLONE_REPO` - the URL to a repository to clone. Defaults to the Argo CD 131 | example apps repository `https://github.com/argoproj/argocd-example-apps` 132 | 133 | * `GIT_CHECKOUT` - if set to `true`, will checkout the repository from the 134 | environment's own repository server (*not* the upstream repository) in the 135 | home directory of the `vagrant` user. You can then modify, commit and 136 | push from that local checkout without modifying upstream (to keep results 137 | initially predictable). Defaults to `true`. 138 | 139 | * `GIT_CONNECT` - if set to true, will connect the repository within Argo CD, 140 | so it's readily available to use. Defaults to `true`. 141 | 142 | ## Variants 143 | 144 | Variants are certain pre-configured installations of Argo CD that 145 | `argocd-nutshell` can provision for you. 146 | 147 | A variant is specified by launching your box with `ARGOCD_VARIANT` set to 148 | the name of the variant you want to launch. 149 | 150 | ### Single-Sign-On with GitHub 151 | 152 | The variant `sso` sets up Argo CD pre-configured to do SSO with a GitHub org. 153 | You will need to setup a GitHub oauth app for this, that needs to match the 154 | following configuration: 155 | 156 | ![OAuth configuration](docs/images/github-oauth-config.png) 157 | 158 | The client ID, client secret and GitHub org name must be passed to the Vagrant 159 | provisioner like follows: 160 | 161 | ``` 162 | DEX_CLIENT_ID= \ 163 | DEX_CLIENT_SECRET= \ 164 | DEX_GH_ORG_NAME= \ 165 | ARGOCD_VARIANT=sso vagrant up 166 | ``` 167 | 168 | ## Customization 169 | 170 | You can provision custom boxes by doing the following: 171 | 172 | * Create a new YAML configuration in the `config` directory. Have a look at 173 | `config/default.yaml`. Consider all variables mandatory. Be sure to 174 | change `argocd.variant` variable to the name of your new variant, for 175 | example `myvariant`. 176 | 177 | * The Argo CD manifests are rendered via Kustomize. Have a look at the 178 | `variants/default` directory for the default variant that is installed. 179 | It contains Kustomize resources to build the Argo CD manifests. You can 180 | copy its contents to a new folder with the same name as your new variant. 181 | Be aware that the Kustomize resources will be templated by Ansible, and 182 | cannot be rendered using `kustomize` as-is. To troubleshoot, use 183 | `vagrant provision` on changes, and find the final resources on the box 184 | within the `/kustomize` directory. 185 | 186 | * Set `ARGOCD_VARIANT` to the name of the new variant before running `vagrant 187 | up`, i.e. 188 | 189 | ```bash 190 | ARGOCD_VARIANT=myvariant vagrant up 191 | ``` 192 | 193 | And then hope it will work out. 194 | 195 | ## Status 196 | 197 | This has just been born, and is not ready for general consumption. Feel free 198 | to use it in the default configuration. Expect to hack on it. It has lots 199 | and lots of rough edges and pitfalls. 200 | 201 | **YMMV.** 202 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Amount of memory in MiB to assign the VM 5 | VM_MEM=8096 6 | 7 | # IP address of the VM. Must be in a dedicated subnet, that's not yet routed 8 | # on your host. 9 | VM_IPADDR="192.168.56.2" 10 | 11 | # The following environment variables will be set in the box, and are required 12 | # by the ansible provisioner as well. 13 | $set_environment_variables = <