Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zbioe committed Aug 22, 2022
1 parent 5375a25 commit d4f6a59
Showing 1 changed file with 147 additions and 18 deletions.
165 changes: 147 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Consul cluster in local vms server

## Requirements

Have some dependecies required for use modules
Have some dependecies depending what environment are you using.

# LIBVIRTD
### Libvirtd
`libvirtd` needs to works in your environment.
Add follow options to your `configuration.nix`:
``` nix
Expand All @@ -23,7 +23,7 @@ Add follow options to your `configuration.nix`:
}
```

# GCP
### GCP
``` nix
{
environment.systemPackages = [
Expand All @@ -32,41 +32,170 @@ Add follow options to your `configuration.nix`:
}
```

Get auth to GCP with:
Get auth to GCP with:
``` bash
gcloud auth application-default login
```

### Azure
``` nix
{
environment.systemPackages = [
pkgs.azure-cli
];
}
```

Get auth to Azure with:
``` bash
az login
```

## Environment

If you use external VAULT, it's required to set the envs to point to it.
To set it, use:

``` bash
IC_VAULT_ADDR=https://vault:443
IC_VAULT_TOKEN=root-token
```

## Build

* `nix build .#qcow` genarate `qcow2` image to use in `livirt`
By default it will build libvirt

### Libvirtd
To build libvirt Image to be imported use:
``` bash
nix build .#qcow # or `build-qcow`
```

### GCP
To build GCP Image use:
``` bash
nix build .#gce # or `build-gce`
```

### Azure
To build azure Image to be imported use:
``` bash
nix build .#azure # or `build-azure`
```

## Provision
Required to build image before apply.
Required access to `./result`
Add this access with `git add -Nf result`
* `nix run` run `nix run ".#apply"`
* `nix run ".#apply"` run `terraform apply`
* `nix run ".#destroy"` run `terraform destroy`
Required access to `./result`. Add this access with `git add -Nf result`

## Vault
start vault dev server in `http://127.0.0.1:8200`
It will call terraform in the end with the configuration made by terranix
Converting the `config.nix` files in `config.tf.json`

In the end of provision it will output an JSON with the values of each machine created.

### Operations
Defaults to `libvirt`
``` bash
# Apply infra
nix run ".#apply" # or `nix run` or `apply`
# Destroy infra
nix run ".#destroy" # or `nix run` or `destroy`
```

#### Libvirt
Provide infra in Libvirtd environment.
``` bash
# Apply
nix run ".#apply-libvirt" # or `apply-libvirt`
# Destroy
nix run ".#destroy-libvirt" # or `destroy-libvirt`
```

#### GCP
Provide infra in GCP environment.
``` bash
arion up # or local-vault
# Apply
nix run ".#apply-gcp" # or `apply-gcp`
# Destroy
nix run ".#destroy-gcp" # or `destroy-gcp`
```

#### Azure
Provide infra in Azure environment.
``` bash
# Apply
nix run ".#apply-azure" # or `apply-azure`
# Destroy
nix run ".#destroy-azure" # or `destroy-azure`
```

## Deploy
Required access to `output.json` generated by provision.
Add this access with `git add -Nf output.json`
Required vault access `local-vault` start and populate a local docker vault.
* `nix run ".#deploy"` run `colmena apply`
Required vault access. you can pass Environment or use an local vault.

Deploy uses [colmena](https://github.com/zhaofengli/colmena) as backend.
For deploy, you can follow all patterns of provision, but replacing `apply` to `deploy`

It defaults to libvirt
``` bash
nix run ".#deploy" # or `deploy`
```

### Libvirt
For deploy to libvirt explicit use:
``` bash
nix run ".#deploy-libvirt" # or `colmena deploy --on @libvirt` # or `deploy-libvirt`
```

### GCP
For deploy to GCP use:
``` bash
nix run ".#deploy-gcp" # or `colmena deploy --on @gcp` # or `deploy-gcp`
```

### Azure
For deploy to Azure use:
``` bash
nix run ".#deploy-azure" # or `colmena deploy --on @azure` # or `deploy-azure`
```

## Vault
Use vault as pki and secret manager.
To configure it, set Environment with token and addr.
And then use:
``` bash
./scripts/vault-init.sh
```
to configure it.

### Environment
Set environment vars with addr and token. If you are using local-vault, you don't need to set it.
``` bash
IC_VAULT_ADDR=https://vault:443
IC_VAULT_TOKEN=root-token
```

### Local-Vault
Use docker-compose by arion-compose to run a dev local-vault.
For libvirt environment you can use local vault.
Start vault dev server in `http://127.0.0.1:8200`with:
``` bash
local-vault # or arion up
```

## K8s
start local kubernetes with k3d and configure it to do federation
Federation in Kubernetes can be configured using scripts and devShell alias.

If you are using `libvirt` environment, you can use an local-k8s

### Federation
Configure it with federation with
``` bash
local-k8s # start k3d local
./scripts/configure.sh # configure local k8s
./scripts/k8s/configure.sh # configure k8s
```

### Local K8s
Start local kubernetes with k3d for libvirt local tests.
``` bash
local-k8s # start k3d local
```

0 comments on commit d4f6a59

Please sign in to comment.