2018-06-21 01:40:49 +00:00
# ArgoCD Getting Started
2018-03-09 00:05:16 +00:00
2018-07-27 23:51:44 +00:00
An example guestbook application is provided to demonstrate how ArgoCD works.
2018-03-09 00:05:16 +00:00
## Requirements
2018-07-17 07:38:37 +00:00
* Installed [kubectl ](https://kubernetes.io/docs/tasks/tools/install-kubectl/ ) command-line tool
2018-03-09 00:05:16 +00:00
* Have a [kubeconfig ](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ ) file (default location is `~/.kube/config` ).
2018-07-17 07:38:37 +00:00
## 1. Install ArgoCD
2018-04-23 09:40:13 +00:00
```
2018-07-17 07:38:37 +00:00
kubectl create namespace argocd
2018-08-03 20:39:00 +00:00
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v0.7.1/manifests/install.yaml
2018-04-23 09:40:13 +00:00
```
2018-07-17 07:38:37 +00:00
This will create a new namespace, `argocd` , where ArgoCD services and application resources will live.
2018-04-23 09:40:13 +00:00
2018-07-18 01:03:17 +00:00
NOTE:
* On GKE with RBAC enabled, you may need to grant your account the ability to create new cluster roles
```
2018-07-30 23:13:54 +00:00
kubectl create clusterrolebinding YOURNAME-cluster-admin-binding --clusterrole=cluster-admin --user=YOUREMAIL@gmail.com
2018-07-18 01:03:17 +00:00
```
2018-07-17 07:38:37 +00:00
## 2. Download ArgoCD CLI
2018-03-09 00:05:16 +00:00
2018-07-17 07:38:37 +00:00
Download the latest ArgoCD version:
2018-07-30 23:13:54 +00:00
On Mac:
```
brew install argoproj/tap/argocd
```
On Linux:
2018-03-09 00:05:16 +00:00
```
2018-08-03 20:39:00 +00:00
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v0.7.1/argocd-linux-amd64
2018-07-17 07:38:37 +00:00
chmod +x /usr/local/bin/argocd
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
## 3. Open access to ArgoCD API server
2018-03-09 00:05:16 +00:00
2018-06-21 01:40:49 +00:00
By default, the ArgoCD API server is not exposed with an external IP. To expose the API server,
change the service type to `LoadBalancer` :
2018-03-09 00:05:16 +00:00
```
2018-04-23 09:40:13 +00:00
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
2018-03-09 00:05:16 +00:00
```
2018-05-18 01:28:04 +00:00
## 4. Login to the server from the CLI
2018-03-09 00:05:16 +00:00
2018-07-17 07:38:37 +00:00
Login with using the `admin` user. The initial password is autogenerated to be the pod name of the
ArgoCD API server. This can be retrieved with the command:
```
kubectl get pods -n argocd -l app=argocd-server -o name | cut -d'/' -f 2
```
Using the above password, login to ArgoCD's external IP:
On Minikube:
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
argocd login $(minikube service argocd-server -n argocd --url | cut -d'/' -f 3) --name minikube
2018-03-09 00:05:16 +00:00
```
2018-07-17 07:38:37 +00:00
Other clusters:
```
2018-07-28 01:06:21 +00:00
kubectl get svc -n argocd argocd-server
2018-07-17 07:38:37 +00:00
argocd login < EXTERNAL-IP >
```
After logging in, change the password using the command:
```
argocd account update-password
2018-07-28 01:35:52 +00:00
argocd relogin
2018-07-17 07:38:37 +00:00
```
2018-03-09 00:05:16 +00:00
2018-06-21 01:40:49 +00:00
## 5. Register a cluster to deploy apps to
2018-03-09 00:05:16 +00:00
2018-07-17 07:38:37 +00:00
We will now register a cluster to deploy applications to. First list all clusters contexts in your
kubconfig:
```
argocd cluster add
```
Choose a context name from the list and supply it to `argocd cluster add CONTEXTNAME` . For example,
for minikube context, run:
2018-06-21 01:40:49 +00:00
```
argocd cluster add minikube --in-cluster
```
2018-07-17 07:38:37 +00:00
The above command installs an `argocd-manager` ServiceAccount and ClusterRole into the cluster
associated with the supplied kubectl context. ArgoCD uses the service account token to perform its
management tasks (i.e. deploy/monitoring).
The `--in-cluster` option indicates that the cluster we are registering, is the same cluster that
ArgoCD is running in. This allows ArgoCD to connect to the cluster using the internal kubernetes
hostname (kubernetes.default.svc). When registering a cluster external to ArgoCD, the `--in-cluster`
flag should be omitted.
2018-06-21 01:40:49 +00:00
## 6. Create the application from a git repository
### Creating apps via UI
2018-07-17 07:38:37 +00:00
Open a browser to the ArgoCD external UI, and login using the credentials set in step 4.
2018-03-09 00:05:16 +00:00
2018-07-17 07:38:37 +00:00
On Minikube:
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
minikube service argocd-server -n argocd
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
Connect a git repository containing your apps. An example repository containing a sample
guestbook application is available at https://github.com/argoproj/argocd-example-apps.git.

After connecting a git repository, select the guestbook application for creation:




### Creating apps via CLI
Applications can be also be created using the ArgoCD CLI:
2018-03-09 00:05:16 +00:00
```
2018-07-28 01:06:21 +00:00
argocd app create guestbook-default --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --env default
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
## 7. Sync (deploy) the application
Once the guestbook application is created, you can now view its status:
2018-03-09 00:05:16 +00:00
2018-06-21 01:40:49 +00:00
From UI:

From CLI:
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
$ argocd app get guestbook-default
Name: guestbook-default
Server: https://kubernetes.default.svc
Namespace: default
URL: https://192.168.64.36:31880/applications/argocd/guestbook-default
Environment: default
Repo: https://github.com/argoproj/argocd-example-apps.git
Path: guestbook
Target: HEAD
KIND NAME STATUS HEALTH
Service guestbook-ui OutOfSync
Deployment guestbook-ui OutOfSync
2018-03-09 00:05:16 +00:00
```
The application status is initially in an `OutOfSync` state, since the application has yet to be
2018-04-23 09:40:13 +00:00
deployed, and no Kubernetes resources have been created. To sync (deploy) the application, run:
2018-03-09 00:05:16 +00:00
```
2018-06-21 01:40:49 +00:00
$ argocd app sync guestbook-default
Application: guestbook-default
Operation: Sync
Phase: Succeeded
Message: successfully synced
KIND NAME MESSAGE
Service guestbook-ui service "guestbook-ui" created
Deployment guestbook-ui deployment.apps "guestbook-ui" created
2018-03-09 00:05:16 +00:00
```
2018-07-27 23:51:44 +00:00
This command retrieves the manifests from git repository and performs a `kubectl apply` of the
manifests. The guestbook app is now running and you can now view its resource
2018-06-21 01:40:49 +00:00
components, logs, events, and assessed health:
2018-03-09 00:05:16 +00:00
2018-06-21 01:40:49 +00:00

2018-03-09 00:05:16 +00:00
2018-06-21 01:40:49 +00:00
## 8. Next Steps
2018-07-27 23:51:44 +00:00
ArgoCD supports additional features such as SSO, WebHooks, RBAC, Projects. See the rest of
the [documentation ](./ ) for details.