Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-codefresh committed Apr 26, 2021
1 parent 49a317c commit 59249e3
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 56 deletions.
114 changes: 59 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,90 @@
# argo-installer
# argocd-autopilot
[![codecov](https://codecov.io/gh/codefresh-io/cf-argo/branch/main/graph/badge.svg?token=R64AZI8NUW)](https://codecov.io/gh/codefresh-io/cf-argo)
## Overview:
The installer utilizes the gitops pattern in order to control the install,uninstall and upgrade flows for kustomize based installations.
The installer creates (or modifies) a git repository while leverging the Argo CD apps patttern.
The argocd-autopilot utilizes the gitops pattern in order to control the install,uninstall and upgrade flows for kustomize based installations.
The argocd-autopilot cli modifies a git repository while leverging the Argo CD apps patttern

## Architecture:
### Bootstrap:
The installer clones the template repository, copies the templates into the target repository, and bootstrap Argo CD and sealed-secrets (controlled by bootstrap/kustomization.yaml in template repository) by applying the kustomized output to K8S cluster.
### controlling the installation flow:
The follwing folders and files in the user's repository contorls the installation's content :
* `argocd-apps/{envName}/components` - contains Argo CD apps for `envName`
* `kustomize/entities/overlays/{envName}/kustomization.yaml` - contains the entities that are synced by Argo CD app for `envName`
* `kustomize/components/{appName}/overlays/{envName}` - this folder contains the the overlays to control `appName` app
The argocd-autopilot bootstrap command pushs the apps manifests into a git repository which will be later used to contorl the gitops lifecycle.
Later the argocd-autopilot install Argo CD on kubernetes cluster which monitors the repository for changes. Now one cad add projects and apps in a gitops approach

## Usage:

### Installing a new environment
### Creating a new project
```
~ cf-argo install --help
This command will create a new git repository that manages an Argo Enterprise solution using Argo-CD with gitops.
~ argocd-autopilot project create [PROJECT] [flags]
This command will create a new project which will later can add applications to it
Usage:
cf-argo install [flags]
Flags:
--dry-run when true, the command will have no side effects, and will only output the manifests to stdout
--env-name string name of the Argo Enterprise environment to create (default "production")
--git-token string git token which will be used by argo-cd to create the gitops repository
-h, --help help for install
--kube-context string name of the kubeconfig context to use (default: current context)
--kubeconfig string path to the kubeconfig file [KUBECONFIG] (default: ~/.kube/config)
--repo-name string the name of the gitops repository to be created [REPO_NAME]
--repo-owner string the name of the owner of the gitops repository to be created [REPO_OWNER]
--repo-url string the clone url of an existing gitops repository url [REPO_URL]
Global Flags:
--log-format string set the log format: "text", "json" (defaults to text) (default "text")
--log-level string set the log level, e.g. "debug", "info", "warn", "error" (default "info")
argocd-autopilot project create [PROJECT] [flags]
--auth-token string Authentication token
--aws-cluster-name string AWS Cluster name if set then aws cli eks token command will be used to access cluster
--aws-role-arn string Optional AWS role arn. If set then AWS IAM Authenticator assumes a role to perform cluster operations instead of the default AWS credential provider chain.
--client-crt string Client certificate file
--client-crt-key string Client certificate key file
--config string Path to Argo CD config (default "/home/user/.argocd/config")
--dest-kube-context string The default destination kubernetes context for applications in this project
--dry-run If true, print manifests instead of applying them to the cluster (nothing will be commited to git)
--exec-command string Command to run to provide client credentials to the cluster. You may need to build a custom ArgoCD image to ensure the command is available at runtime.
--exec-command-api-version string Preferred input version of the ExecInfo for the --exec-command executable
--exec-command-args stringArray Arguments to supply to the --exec-command executable
--exec-command-env stringToString Environment vars to set when running the --exec-command executable (default [])
--exec-command-install-hint string Text shown to the user when the --exec-command executable doesn't seem to be present
-t, --git-token string Your git provider api token [GIT_TOKEN]
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
-h, --help help for create
--in-cluster Indicates Argo CD resides inside this cluster and should connect using the internal k8s hostname (kubernetes.default.svc)
--insecure Skip server certificate and domain verification
--installation-path string The path where we of the installation files (defaults to the root of the repository [GIT_INSTALLATION_PATH]
--name string Overwrite the cluster name
--plaintext Disable TLS
--port-forward Connect to a random argocd-server port using port forwarding
--port-forward-namespace string Namespace name which should be used for port forwarding
--repo string Repository URL [GIT_REPO]
--revision string Repository branch, tag or commit hash (defaults to HEAD)
--server string Argo CD server address
--server-crt string Server certificate file
--service-account string System namespace service account to use for kubernetes resource management. If not set then default "argocd-manager" SA will be created
--shard int Cluster shard number; inferred from hostname if not set (default -1)
--system-namespace string Use different system namespace (default "kube-system")
--upsert Override an existing cluster with the same name even if the spec differs
```
### Creating a new application

* Use `cf-argo install --repo-owner <owner> --repo-name <name> ...` when creating a new Gitops repository
* Use `cf-argo install --repo-url <url> ...` when installing a new environment into an existing Gitops repository

### Uninstalling an existing environment

```
~ cf-argo uninstall --help
This command will clear all Argo-CD managed resources relating to a specific installation, from a specific cluster
~ argocd-autopilot application create [APP_NAME] [flags]
This command will create a new application under a project in the git reposiotry

Usage:
cf-argo uninstall [flags]
Flags:
--dry-run when true, the command will have no side effects, and will only output the manifests to stdout
--env-name string name of the Argo Enterprise environment to create (default "production")
--git-token string git token which will be used by argo-cd to create the gitops repository
-h, --help help for uninstall
--kube-context string name of the kubeconfig context to use (default: current context)
--kubeconfig string path to the kubeconfig file [KUBECONFIG] (default: ~/.kube/config) (default "/Users/noamgal/.kube/config")
--repo-url string the gitops repository url. If it does not exist we will try to create it for you [REPO_URL]
Global Flags:
--log-format string set the log format: "text", "json" (defaults to text) (default "text")
--log-level string set the log level, e.g. "debug", "info", "warn", "error" (default "info")
```
argocd-autopilot application create [APP_NAME] [flags]

--app string The application specifier (e.g. argocd@v1.0.2)
--dest-namespace string K8s target namespace (overrides the namespace specified in the kustomization.yaml)
--dest-server string K8s cluster URL (e.g. https://kubernetes.default.svc) (default "https://kubernetes.default.svc")
-t, --git-token string Your git provider api token [GIT_TOKEN]
-h, --help help for create
--installation-mode string One of: normal|flat. If flat, will commit the application manifests (after running kustomize build), otherwise will commit the kustomization.yaml (default "normal")
--installation-path string The path where we of the installation files (defaults to the root of the repository [GIT_INSTALLATION_PATH]
-p, --project string Project name
--repo string Repository URL [GIT_REPO]
--revision string Repository branch, tag or commit hash (defaults to HEAD)

Will remove all managed applications from the environment. If there are no other applications remaining in the root app-of-apps, will also remove it, and uninstall the argo-cd server itself.

## Development

### Building from Source:
To build a binary from the source code, make sure:
* you have `go >=1.15` installed.
* you have `go >=1.16` installed.
* and that the `GOPATH` environment variable is set.


Then run:
* `make` to build the binary to `./dist/`


or
* `make install` to make it available as `cf-argo` in the `PATH`
### Linting:
We are using https://github.com/golangci/golangci-lint as our linter, you can integrate golangci-lint with the following IDEs:
* vscode: make sure `GOPATH` is setup correctly and run `make lint` this will download `golangci-lint` if it was not already installed on your machine. Then add the following to your `settings.json`:
Expand Down
19 changes: 19 additions & 0 deletions docs/user-guide/commands/project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## project

Manage projects

```
project [flags]
```

### Options

```
-h, --help help for project
```

### SEE ALSO

* [project create](project_create.md) - Create a new project

###### Auto generated by spf13/cobra on 26-Apr-2021
75 changes: 75 additions & 0 deletions docs/user-guide/commands/project_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## project create

Create a new project

```
project create [PROJECT] [flags]
```

### Examples

```
# To run this command you need to create a personal access token for your git provider,
# and have a bootstrapped GitOps repository, and provide them using:
export GIT_TOKEN=<token>
export GIT_REPO=<repo_url>
# or with the flags:
--token <token> --repo <repo_url>
# Create a new project
project create <new_project_name>
# Create a new project in a specific path inside the GitOps repo
project create <new_project_name> --installation-path path/to/bootstrap/root
```

### Options

```
--auth-token string Authentication token
--aws-cluster-name string AWS Cluster name if set then aws cli eks token command will be used to access cluster
--aws-role-arn string Optional AWS role arn. If set then AWS IAM Authenticator assumes a role to perform cluster operations instead of the default AWS credential provider chain.
--client-crt string Client certificate file
--client-crt-key string Client certificate key file
--config string Path to Argo CD config (default "/home/user/.argocd/config")
--dest-kube-context string The default destination kubernetes context for applications in this project
--dry-run If true, print manifests instead of applying them to the cluster (nothing will be commited to git)
--exec-command string Command to run to provide client credentials to the cluster. You may need to build a custom ArgoCD image to ensure the command is available at runtime.
--exec-command-api-version string Preferred input version of the ExecInfo for the --exec-command executable
--exec-command-args stringArray Arguments to supply to the --exec-command executable
--exec-command-env stringToString Environment vars to set when running the --exec-command executable (default [])
--exec-command-install-hint string Text shown to the user when the --exec-command executable doesn't seem to be present
-t, --git-token string Your git provider api token [GIT_TOKEN]
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
-h, --help help for create
--in-cluster Indicates Argo CD resides inside this cluster and should connect using the internal k8s hostname (kubernetes.default.svc)
--insecure Skip server certificate and domain verification
--installation-path string The path where we of the installation files (defaults to the root of the repository [GIT_INSTALLATION_PATH]
--name string Overwrite the cluster name
--plaintext Disable TLS
--port-forward Connect to a random argocd-server port using port forwarding
--port-forward-namespace string Namespace name which should be used for port forwarding
--repo string Repository URL [GIT_REPO]
--revision string Repository branch, tag or commit hash (defaults to HEAD)
--server string Argo CD server address
--server-crt string Server certificate file
--service-account string System namespace service account to use for kubernetes resource management. If not set then default "argocd-manager" SA will be created
--shard int Cluster shard number; inferred from hostname if not set (default -1)
--system-namespace string Use different system namespace (default "kube-system")
--upsert Override an existing cluster with the same name even if the spec differs
```

### SEE ALSO

* [project](project.md) - Manage projects

###### Auto generated by spf13/cobra on 26-Apr-2021
2 changes: 1 addition & 1 deletion docs/user-guide/commands/repo_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repo create [flags]
-t, --git-token string Your git provider api token [GIT_TOKEN]
-h, --help help for create
--host string The git provider address (for on-premise git providers)
-r, --name string The name of the repository
-n, --name string The name of the repository
-o, --owner string The name of the owner or organiaion
-p, --provider string The git provider, one of: github (default "github")
--public If true, will create the repository as public (default is false)
Expand Down
5 changes: 5 additions & 0 deletions hack/cmd-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ func main() {
if err != nil {
log.Fatal(err)
}

err = doc.GenMarkdownTree(commands.NewProjectCommand(), "./docs/user-guide/commands")
if err != nil {
log.Fatal(err)
}
}

0 comments on commit 59249e3

Please sign in to comment.