Skip to content

Commit

Permalink
improved docs (#440)
Browse files Browse the repository at this point in the history
Signed-off-by: roi.kramer <[email protected]>
  • Loading branch information
roi-codefresh authored Mar 15, 2023
1 parent e14321e commit 9f3b0cc
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 50 deletions.
32 changes: 32 additions & 0 deletions docs/Advanced-Installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Advanced Installation Options


### Bootstrap under a specific path
If you want the autopilot managed folder structure to reside under some sub-folder in your repository, you can also export the following env variable:
```
export GIT_REPO=https://github.com/owner/name.git/some/relative/path
```
You should see the `bootstrap/` directory under `/some/relative/path/bootstrap`.

### Bootstrap on a specific branch
If you want to use a specific branch for your GitOps repository operations, you can use the `ref` query parameter:
```
export GIT_REPO=https://github.com/owner/name?ref=gitops_branch
```

!!! note
When running commands that commit or write to the repository, the value of `ref` can only be a branch.


!!! tip
When running commands that commit or write to the repository you may also specify the `-b`, this would create the branch specified in `ref` if it doesn't exist.

Note that when doing so the new branch would be created from the default branch.



### High Availability
You can bootstrap Argo CD in high-availability mode using the [App Specifier](App-Specifier/):
```
argocd-autopilot repo bootstrap --app https://github.com/argoproj-labs/argocd-autopilot/manifests/ha
```
91 changes: 41 additions & 50 deletions docs/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,39 @@ This guide assumes you are familiar with Argo CD and its basic concepts. See the
* Installed [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) command-line tool
* Have a [kubeconfig](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) file (default location is `~/.kube/config`)

### Git Authentication
Make sure to have a [valid token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
![Github token](assets/github_token.png)
### Export a Git Token
```
export GIT_TOKEN=ghp_PcZ...IP0
```

Make sure you export a [valid token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the required scopes.
![Github token](assets/github_token.png)

### Export Clone URL
You can use any clone URL to a valid git repo, provided that the token you supplied earlier will allow cloning from, and pushing to it.
If the repository does not exist, bootstrapping it will also create it as a private repository.
```
export GIT_REPO=https://github.com/owner/name
```

#### Using a Specific Installation Path
If you want the autopilot-managed folder structure to reside under some sub-folder in your repository, you can also append the path:
```
export GIT_REPO=https://github.com/owner/name/some/relative/path
```

#### Using a Specific Branch
If you want to use a specific branch for your GitOps repository operations, you can use the `ref` query parameter:
```
export GIT_REPO=https://github.com/owner/name?ref=gitops_branch
```

!!! note
When running commands that commit or write to the repository, the value of `ref` can only be a branch.


!!! tip
When running commands that commit or write to the repository you may also specify the `-b`, this would create the branch specified in `ref` if it doesn't exist.

Note that when doing so the new branch would be create from the default branch.
#### Using a Specific git Provider
You can add the `--provider` flag to the `repo bootstrap` command, to enforce using a specific provider when creating a new repository. If the value is not supplied, the code will attempt to infer it from the clone URL.

Autopilot currently supports a variaty of git providers, you should check if yours is currently supported [here](./Git-Providers.md).

#### Using a Specific git Provider
You can add the `--provider` flag to the `repo bootstrap` command, to enforce using a specific provider when creating a new repository. If the value is not supplied, autopilot will attempt to infer it from the clone URL.
Autopilot currently supports `github`, `gitlab`, `bitbucket` (Cloud), `bitbucket-server` (on-prem), `azure` (Azure DevOps Repos), and `gitea` as SCM providers.

All the following commands will use the variables you supplied in order to manage your GitOps repository.
## Bootstrap Argo-CD

## Set up the GitOps Repository
Now that you have exported the `GIT_TOKEN` and `GIT_REPO` environment variables you can run the bootstrap command:
```
argocd-autopilot repo bootstrap
```
The execution might take several minutes, while your k8s cluster downloads the required images for Argo CD.
Once it completes, you will get the initial Argo CD admin password, as well as the command to run to enable port-forwarding:

This command will install Argo-CD on your current Kubernetes context in the `argocd` namespace. You might need to wait a few minutes while the required images are being pulled.

After Argo-CD is up and running autopilot will push the installation manifests to the installation repository and create the `autopilot-bootstrap` application in the cluster. This will in turn deploy the `argo-cd` application, making Argo-CD manage itself, completing the bootstrap process.

Before the bootstrap command is finished it will print out the initial Argo-CD admin password, as well as the command to run to enable port-forwarding:
```
INFO argocd initialized. password: pfrDVRJZtHYZKzBv
INFO run:
Expand All @@ -64,45 +49,51 @@ INFO run:
```
<sub>(Your initial password will be different)</sub>

Execute the port-forward command, and browse to http://localhost:8080. Log in using username `admin`, and the password from the previous step. your initial Argo CD deployment should look like this:
Execute the port forward command, and browse to `http://localhost:8080`. You can log in with user: `admin`, and the password from the previous step.

Your initial Argo CD should have the following applications:

* `autopilot-bootstrap` - References the `bootstrap` directory in the GitOps repository, and manages the other 2 applications
* `argo-cd` - References the `bootstrap/argo-cd` folder, and manages the Argo CD deployment itself (including Argo CD ApplicationSet)
* `root` - References the `projects` directiry in the repo. The folder contains only an empty `DUMMY` file after the bootstrap command, so no projects will be created

<!-- FIXME: Screenshot is outdated; missing the `cluster-resources-in-cluster` Application introduced with #79. -->
![Step 1](assets/getting_started_1.png)

### Recovering Argo CD from an existing repository
```
argocd-autopilot repo bootstrap --recover \
--app "github.com/git-user/repo-name/bootstrap" #optional
```

In case of a cluster failure, you can recover Argo CD from an existing repository using `--recover` flag. You can optionally use it with `--app` flag to specify the path to the existing Argo CD manifests.
## Create a Project
Projects provide a way to logically group applications and easily control things such as defaults and restrictions.

### Using Argo CD HA
Using Argo CD HA with Argo CD Autopilot is fully supported. Bootstrap Argo CD with high-availability using the [App Specifier](App-Specifier/) model `argocd-autopilot repo bootstrap --app https://github.com/argoproj-labs/argocd-autopilot/manifests/ha`.
Projects may also be used to deploy applications to different kubernetes clusters.

### Running Applications:
* autopilot-bootstrap - References the `bootstrap` directory in the GitOps repository, and manages the other 2 applications
* argo-cd - References the `bootstrap/argo-cd` folder, and manages the Argo CD deployment itself (including Argo CD ApplicationSet)
* root - References the `projects` directory in the repo. The folder contains only an empty `DUMMY` file after the bootstrap command, so no projects will be created

## Add a Project and an Application
Execute the following commands to create a `testing` project, and add an example application to it:
To create your first project run the following command:
```
argocd-autopilot project create testing
```
This will create the `testing` [AppProject](https://argo-cd.readthedocs.io/en/stable/user-guide/projects/) and [ApplicationSet](https://argo-cd.readthedocs.io/en/stable/user-guide/application-set/). You should see that it was pushed to your installation repository under `/projects/testing.yaml`

## Add an Application
Now that you have your first project, Argo-CD applications can be added to it and deployed with a simple command:
```
argocd-autopilot app create hello-world --app github.com/argoproj-labs/argocd-autopilot/examples/demo-app/ -p testing --wait-timeout 2m
```
<sub>* notice the trailing slash in the URL</sub>

After the application is created, and after Argo CD has finished its sync cycle, your new project will appear under the *Root* application:
This will create an application with the name `hello-world` and add it to the `testing` project.

After the application is created, and Argo-CD has finished its sync cycle, your new `testing` project will appear under the `root` application:

![Step 2](assets/getting_started_2.png)

The "hello-world" application will also be deployed to the cluster:
And the `hello-world` application will also be deployed to the cluster:

![Step 3](assets/getting_started_3.png)

## Uninstall everything when done
The following command will clear your entire GitOps Repository of related files, and your k8s cluster from any resources autopilot created:
## Uninstalling
The following command will clear your GitOps repository of related files, and your Kubernetes cluster from any autopilot related resources (including Argo-CD itself)
```
argocd-autopilot repo uninstall
```

## Advanced Use Cases
For more advanced use-case, which includes deploying to multiple environments, you can go through this [argocd-autopilot deep dive](https://codefresh.io/about-gitops/launching-argo-cd-autopilot-opinionated-way-manage-applications-across-environments-using-gitops-scale/) blog post.
11 changes: 11 additions & 0 deletions docs/Git-Providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Git Providers

Autopilot fully automates the installation process and bootstrapping of Argo CD, it can even create and initialize a git repository if required, but to do so it needs to have access to your git provider.

The following git providers are currently supported:

* Github
* Gitlab
* Bitbucket Server (on-prem only)
* Azure DevOps
* Gitea
159 changes: 159 additions & 0 deletions docs/Modifying-Argo-CD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
One of the benefits you get from using Argo-CD Autopilot is the bootstrap installation of Argo-CD. This means that Argo-CD will manage and reconcile itself based on the desired in your installation repository.

The state of Argo-CD is managed by the `argo-cd` application that is deployed by the `autopilot-bootstrap` application. The application is a kustomize type application and generates its Argo-CD manifests from `bootstrap/argo-cd/kustomization.yaml`.

![Argo-CD application](assets/getting_started_1.png)
<sub>One of the applications you get after the initial bootstrap is the `argo-cd` application</sub>

To modify your Argo-CD installation you would need to use the GitOps approach. This means you cannot modify Argo-CD resources directly in the cluster, instead you should use [kustomize patches](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patches/) to modify the resources generated from `bootstrap/argo-cd/kustomization.yaml`.

Here are a few examples of common Argo-CD modifications:

### Specifying Requests and Limits
The following shows the kustomization file in `bootstrap/argo-cd/kustomization.yaml` with patches which sets the `requests` and `limits` for `argocd-repo-server` and `argocd-application-controller`. Note that some parts of the file were omitted in this example.

You can use the same method to set `requests` and `limits` for any other Argo-CD component.

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argocd
resources:
- github.com/argoproj-labs/argocd-autopilot/manifests/base?ref=v0.4.10

# Added these patches
patches:
- target:
group: apps
version: v1
kind: Deployment
name: argocd-repo-server
patch: |-
- op: add
path: /spec/template/spec/containers/0/resources
value:
requests:
memory: 4Gi
limits:
ephemeral-storage: 4Gi
memory: 4Gi
- target:
group: apps
version: v1
kind: StatefulSet
name: argocd-application-controller
patch: |-
- op: add
path: /spec/template/spec/containers/0/resources
value:
requests:
memory: 4Gi
limits:
memory: 4Gi
# rest omitted for brevity...
```

### Disable Admin Account and Add Another Account
In the following example we use the `configMapGenerator` feature of kustomize to modify the `argocd-cm` configmap to disable the admin account, which comes with Argo-CD by default, and add another account instead.

Note that you would need to [activate](https://argo-cd.readthedocs.io/en/stable/operator-manual/user-management/#manage-users) the `alice` account using the `admin` account *before* disabling the `admin` account.
```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argocd
resources:
- github.com/argoproj-labs/argocd-autopilot/manifests/base?ref=v0.4.10

configMapGenerator:
- behavior: merge
name: argocd-cm
literals:
# some keys omitted for brevity...
- admin.enabled=false
- accounts.alice=apiKey, login
```
### Ingress Configuration
The following example shows how you would configure ingress using AWS Application Load Balancer. You can easily use this example to configure ingress using other ingress controllers and you can refer to the [official Argo-CD documetation](https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress) for additional information.
Create the `argogrpc` service:

```yaml
# /bootstrap/argo-cd/argogrpc.service.yaml
apiVersion: v1
kind: Service
metadata:
annotations:
alb.ingress.kubernetes.io/backend-protocol-version: HTTP2 #This tells AWS to send traffic from the ALB using HTTP2. Can use GRPC as well if you want to leverage GRPC specific features
labels:
app: argogrpc
name: argogrpc
spec:
ports:
- name: "443"
port: 443
protocol: TCP
targetPort: 8080
selector:
app.kubernetes.io/name: argocd-server
sessionAffinity: None
type: NodePort
```

Create the ingress resource:

```yaml
# /bootstrap/argo-cd/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
alb.ingress.kubernetes.io/backend-protocol: HTTPS
alb.ingress.kubernetes.io/conditions.argogrpc: |
[{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "Content-Type", "values":["application/grpc"]}}]
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}]'
alb.ingress.kubernetes.io/target-type: 'ip'
alb.ingress.kubernetes.io/scheme: internet-facing
name: argocd
spec:
rules:
- host: argocd.argoproj.io
http:
paths:
- path: /
backend:
service:
name: argogrpc
port:
number: 443
pathType: Prefix
- path: /
backend:
service:
name: argocd-server
port:
number: 443
pathType: Prefix
tls:
- hosts:
- argocd.argoproj.io
```

Add the new resources to the kustomization file:

```yaml
# /bootstrap/argo-cd/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argocd
resources:
- github.com/argoproj-labs/argocd-autopilot/manifests/base?ref=v0.4.10
# Added new resources:
- ./ingress.yaml
- ./argogrpc.service.yaml
# rest omitted for brevity...
```

If ALB is correctly configured on your cluster, the `argo-cd` application would successfully reconcile after the new ingress resource will be updated with its external address. Then you should be able to reach your Argo-CD through the external address.
29 changes: 29 additions & 0 deletions docs/Recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#### Recovering From an Existing Repository
If, for any reason, something happens to your argo-cd installation, you can recover from an existing repository using the `--recover` flag.

This should re-apply Argo-CD to the cluster, then create the `autopilot-bootstrap` application, which will restore all of the other applications in your repository.



```
export GIT_REPO=https://github.com/owner/installation-repo
export GIT_TOKEN=xxx
argocd-autopilot repo bootstrap --recover
```

#### Apply Argo-CD Manifests From Existing Repository
In some cases where you made [some modifications](./Modifying-Argo-CD.md) to your Argo-CD, you probably want to apply the modified Argo-CD manifests from your repository instead of new ones. You can easily do that with the `--app` flag.

For example:
```
export GIT_REPO=https://github.com/owner/installation-repo
export GIT_TOKEN=xxx
argocd-autopilot repo bootstrap --recover --app "${GIT_REPO}.git/bootstrap/argo-cd"
```

This is using the [app specifier](./App-Specifier.md) flag to tell autopilot that the Argo-CD manifests should be generated from `/bootstrap/argo-cd/kustomization.yaml`.

!!! note
If you used a different path or branch for your autopilot installation your app specifier would look different
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ nav:
- Installation: Installation-Guide.md
- User Guide:
- Getting Started: Getting-Started.md
- Advanced Installation: Advanced-Installation.md
- Modifying Argo-CD: Modifying-Argo-CD.md
- Application Specifier: App-Specifier.md
- Labels: Labels.md
- Installation Recovery: Recovery.md
- Command Reference: commands/argocd-autopilot.md
- Git Providers: Git-Providers.md
- Development: Development.md
- Roadmap: Roadmap.md
- Blogs: Blogs.md
Expand Down

0 comments on commit 9f3b0cc

Please sign in to comment.