Skip to content

Commit

Permalink
Added terraform-docs (#434)
Browse files Browse the repository at this point in the history
* Added terraform-docs
* Updated docs
* Added specs for the modules
  • Loading branch information
bravecobra authored Feb 25, 2023
1 parent c4f819e commit 973aecb
Show file tree
Hide file tree
Showing 66 changed files with 3,008 additions and 727 deletions.
50 changes: 50 additions & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
formatter: "" # this is required

version: ""

header-from: main.tf
footer-from: ""

recursive:
enabled: false
path: modules

sections:
hide: []
show: []

hide-all: false # deprecated in v0.13.0, removed in v0.15.0
show-all: true # deprecated in v0.13.0, removed in v0.15.0

content: ""

output:
file: ""
mode: inject
template: |-
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
output-values:
enabled: false
from: ""

sort:
enabled: true
by: name

settings:
anchor: false
color: true
default: true
description: true
escape: true
hide-empty: false
html: true
indent: 3
lockfile: true
read-comments: true
required: true
sensitive: true
type: true
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
"bitnami",
"bravecobra",
"certmanager",
"choco",
"codecentric",
"codeql",
"containo",
"cowboysysop",
"crds",
"datalust",
"datasource",
"devinfra",
"entrypoints",
"fluxcd",
"hckops",
Expand All @@ -43,6 +46,7 @@
"promtail",
"rabbitmq",
"sarif",
"serverlb",
"simcube",
"sqlserver",
"storageclass",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The full docs are available at [Github Pages](https://bravecobra.github.io/k8s-d
#### Build the docs locally

```shell
pip install --user -f requirements.txt
pip install --upgrade --user -r requirements.txt
mkdocs build
mkdocs serve
```
43 changes: 43 additions & 0 deletions add-terraformdocs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
terraform-docs markdown table "./src/terraform" --output-file "../../docs/terraform-specs.md"
terraform-docs markdown table "./src/clusters/k3d" --output-file "../../../docs/k3s.md"
terraform-docs markdown table "./src/clusters/kind" --output-file "../../../docs/kind.md"

# monitoring
terraform-docs markdown table "./src/terraform/modules/monitoring/dashboard" --output-file "../../../../../docs/specs/dashboard.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/goldilocks" --output-file "../../../../../docs/specs/goldilocks.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/ingestion/opentelemetry" --output-file "../../../../../../docs/specs/opentelemetry.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/logging/loki" --output-file "../../../../../../docs/specs/loki.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/logging/seq" --output-file "../../../../../../docs/specs/seq.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/metrics/metrics" --output-file "../../../../../../docs/specs/metrics.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/metrics/prometheus" --output-file "../../../../../../docs/specs/prometheus.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/tracing/jaeger" --output-file "../../../../../../docs/specs/jaeger.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/tracing/tempo" --output-file "../../../../../../docs/specs/tempo.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/vpa" --output-file "../../../../../docs/specs/vpa.md"
# networking
terraform-docs markdown table "./src/terraform/modules/networking/cert-manager" --output-file "../../../../../docs/specs/cert-manager.md"
terraform-docs markdown table "./src/terraform/modules/networking/coredns" --output-file "../../../../../docs/specs/coredns.md"
terraform-docs markdown table "./src/terraform/modules/networking/linkerd" --output-file "../../../../../docs/specs/linkerd.md"
terraform-docs markdown table "./src/terraform/modules/networking/traefik" --output-file "../../../../../docs/specs/traefik.md"
# services
terraform-docs markdown table "./src/terraform/modules/services/caching/redis" --output-file "../../../../../../docs/specs/redis.md"
terraform-docs markdown table "./src/terraform/modules/services/cloud/localstack" --output-file "../../../../../../docs/specs/localstack.md"
terraform-docs markdown table "./src/terraform/modules/services/configuration/etcd" --output-file "../../../../../../docs/specs/etcd.md"
terraform-docs markdown table "./src/terraform/modules/services/configuration/vault" --output-file "../../../../../../docs/specs/vault.md"
terraform-docs markdown table "./src/terraform/modules/services/database/nosql/mongodb" --output-file "../../../../../../../docs/specs/mongodb.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/mariadb" --output-file "../../../../../../../docs/specs/mariadb.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/mysql" --output-file "../../../../../../../docs/specs/mysql.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/oracle-xe" --output-file "../../../../../../../docs/specs/oracle-xe.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/postgres" --output-file "../../../../../../../docs/specs/postgres.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/sqlserver" --output-file "../../../../../../../docs/specs/sqlserver.md"
terraform-docs markdown table "./src/terraform/modules/services/deployment/argocd" --output-file "../../../../../../docs/specs/argocd.md"
terraform-docs markdown table "./src/terraform/modules/services/deployment/flux2" --output-file "../../../../../../docs/specs/flux2.md"
terraform-docs markdown table "./src/terraform/modules/services/messaging/kafka" --output-file "../../../../../../docs/specs/kafka.md"
terraform-docs markdown table "./src/terraform/modules/services/messaging/rabbitmq" --output-file "../../../../../../docs/specs/rabbitmq.md"
terraform-docs markdown table "./src/terraform/modules/services/search/elasticsearch" --output-file "../../../../../../docs/specs/elasticsearch.md"
terraform-docs markdown table "./src/terraform/modules/services/security/auth/identityserver4-admin" --output-file "../../../../../../../docs/specs/identityserver4-admin.md"
terraform-docs markdown table "./src/terraform/modules/services/security/auth/keycloak" --output-file "../../../../../../../docs/specs/keycloak.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/azurite" --output-file "../../../../../../docs/specs/azurite.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/docker" --output-file "../../../../../../docs/specs/docker.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/minio" --output-file "../../../../../../docs/specs/minio.md"
#versions
terraform-docs markdown table "./src/terraform/modules/utils/chartversions" --output-file "../../../../../docs/specs/chartversions.md"
45 changes: 45 additions & 0 deletions add-terraformdocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

terraform-docs markdown table "./src/terraform" --output-file "../../docs/terraform-specs.md"
terraform-docs markdown table "./src/clusters/k3d" --output-file "../../../docs/k3s.md"
terraform-docs markdown table "./src/clusters/kind" --output-file "../../../docs/kind.md"

# monitoring
terraform-docs markdown table "./src/terraform/modules/monitoring/dashboard" --output-file "../../../../../docs/specs/dashboard.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/goldilocks" --output-file "../../../../../docs/specs/goldilocks.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/ingestion/opentelemetry" --output-file "../../../../../../docs/specs/opentelemetry.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/logging/loki" --output-file "../../../../../../docs/specs/loki.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/logging/seq" --output-file "../../../../../../docs/specs/seq.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/metrics/metrics" --output-file "../../../../../../docs/specs/metrics.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/metrics/prometheus" --output-file "../../../../../../docs/specs/prometheus.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/tracing/jaeger" --output-file "../../../../../../docs/specs/jaeger.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/tracing/tempo" --output-file "../../../../../../docs/specs/tempo.md"
terraform-docs markdown table "./src/terraform/modules/monitoring/vpa" --output-file "../../../../../docs/specs/vpa.md"
# networking
terraform-docs markdown table "./src/terraform/modules/networking/cert-manager" --output-file "../../../../../docs/specs/cert-manager.md"
terraform-docs markdown table "./src/terraform/modules/networking/coredns" --output-file "../../../../../docs/specs/coredns.md"
terraform-docs markdown table "./src/terraform/modules/networking/linkerd" --output-file "../../../../../docs/specs/linkerd.md"
terraform-docs markdown table "./src/terraform/modules/networking/traefik" --output-file "../../../../../docs/specs/traefik.md"
# services
terraform-docs markdown table "./src/terraform/modules/services/caching/redis" --output-file "../../../../../../docs/specs/redis.md"
terraform-docs markdown table "./src/terraform/modules/services/cloud/localstack" --output-file "../../../../../../docs/specs/localstack.md"
terraform-docs markdown table "./src/terraform/modules/services/configuration/etcd" --output-file "../../../../../../docs/specs/etcd.md"
terraform-docs markdown table "./src/terraform/modules/services/configuration/vault" --output-file "../../../../../../docs/specs/vault.md"
terraform-docs markdown table "./src/terraform/modules/services/database/nosql/mongodb" --output-file "../../../../../../../docs/specs/mongodb.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/mariadb" --output-file "../../../../../../../docs/specs/mariadb.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/mysql" --output-file "../../../../../../../docs/specs/mysql.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/oracle-xe" --output-file "../../../../../../../docs/specs/oracle-xe.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/postgres" --output-file "../../../../../../../docs/specs/postgres.md"
terraform-docs markdown table "./src/terraform/modules/services/database/rds/sqlserver" --output-file "../../../../../../../docs/specs/sqlserver.md"
terraform-docs markdown table "./src/terraform/modules/services/deployment/argocd" --output-file "../../../../../../docs/specs/argocd.md"
terraform-docs markdown table "./src/terraform/modules/services/deployment/flux2" --output-file "../../../../../../docs/specs/flux2.md"
terraform-docs markdown table "./src/terraform/modules/services/messaging/kafka" --output-file "../../../../../../docs/specs/kafka.md"
terraform-docs markdown table "./src/terraform/modules/services/messaging/rabbitmq" --output-file "../../../../../../docs/specs/rabbitmq.md"
terraform-docs markdown table "./src/terraform/modules/services/search/elasticsearch" --output-file "../../../../../../docs/specs/elasticsearch.md"
terraform-docs markdown table "./src/terraform/modules/services/security/auth/identityserver4-admin" --output-file "../../../../../../../docs/specs/identityserver4-admin.md"
terraform-docs markdown table "./src/terraform/modules/services/security/auth/keycloak" --output-file "../../../../../../../docs/specs/keycloak.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/azurite" --output-file "../../../../../../docs/specs/azurite.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/docker" --output-file "../../../../../../docs/specs/docker.md"
terraform-docs markdown table "./src/terraform/modules/services/storage/minio" --output-file "../../../../../../docs/specs/minio.md"
#versions
terraform-docs markdown table "./src/terraform/modules/utils/chartversions" --output-file "../../../../../docs/specs/chartversions.md"
7 changes: 7 additions & 0 deletions docs/clusters/desktop-cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Docker Desktop K8s

!!!Warning
`Docker Desktop` creates a single-node `k8s` cluster.
Enable `kubernetes` in the settings:

![enable k8s](../images/docker-desktop-kubernetes-settings.png)
143 changes: 143 additions & 0 deletions docs/clusters/k3s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<!-- markdownlint-disable MD033 MD046 -->
# K3S Cluster

## Description

This `terraform` config will create a multi-node `k3s` cluster using `k3d` command-line inside a separate docker network and can add a private docker registry to push docker images.

```mermaid
graph LR;
host
subgraph docker-network: k3d
k3d-devinfra-server-0
k3d-devinfra-agent-0
k3d-devinfra-agent-1
registry-localhost
k3d-devinfra-serverlb
end
host --> k3d-devinfra-serverlb
k3d-devinfra-serverlb-->k3d-devinfra-server-0
k3d-devinfra-serverlb-->k3d-devinfra-agent-0
k3d-devinfra-serverlb-->k3d-devinfra-agent-1
k3d-devinfra-server-0 -.uses.-> registry-localhost
k3d-devinfra-agent-0 -.uses.-> registry-localhost
k3d-devinfra-agent-1 -.uses.-> registry-localhost
```

## Installation

Make sure docker is up and running.

### Create the cluster

!!! Note
When using `WSL2` (Windows Subsystem for Linux), you need to copy the context configuration to your `.kubeconfig` file on the `WSL2` home directory or the other way round, depending on which shell you use to run the `terraform` code.

```powershell
cp /mnt/c/users/$(whoami)/.kube/config ~/.kube/config
```

or

```powershell
cp ~/.kube/config /mnt/c/users/$(whoami)/.kube/config
```

```shell
cd ./src/clusters/k3s
terraform init --upgrade
terraform apply --auto-approve
```

The cluster creation automatically add configuration to your `kubectl` contexts connect to so you can connect to the new cluster

```powershell
kubectl cluster-info --context k3d-devinfra
```

### Destroy the cluster

```shell
terraform destroy --auto-approve
```

## Terraform

<!-- BEGIN_TF_DOCS -->
### Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.0 |
| docker | ~> 3.0.1 |

### Providers

| Name | Version |
|------|---------|
| docker | 3.0.1 |
| local | 2.3.0 |
| null | 3.2.1 |

### Modules

No modules.

### Resources

| Name | Type |
|------|------|
| [docker_network.k3d_network](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/network) | resource |
| [local_file.cluster-config](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource |
| [null_resource.cluster_create](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.cluster_delete](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |

### Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| cluster-name | Name of the cluster being created | `string` | `"devinfra"` | no |
| expose\_azurite | Expose Azurite externally | `bool` | `false` | no |
| expose\_jaeger | Expose Jaeger externally | `bool` | `false` | no |
| expose\_loki | Expose Loki externally | `bool` | `false` | no |
| expose\_nosql\_mongodb | Expose MongoDb externally | `bool` | `false` | no |
| expose\_opentelemetry | Expose OpenTelemetry Collector externally | `bool` | `false` | no |
| expose\_rabbitmq | Expose rabbitmq externally | `bool` | `false` | no |
| expose\_rds\_mariadb | Expose MariaDb externally | `bool` | `false` | no |
| expose\_rds\_mssql | Expose SQL Server externally | `bool` | `false` | no |
| expose\_rds\_mysql | Expose Mysql externally | `bool` | `false` | no |
| expose\_rds\_oracle | Expose Oracle externally | `bool` | `false` | no |
| expose\_rds\_postgres | Expose Postgres externally | `bool` | `false` | no |
| expose\_redis | Expose Redis externally | `bool` | `false` | no |
| expose\_seq | Expose Seq externally | `bool` | `false` | no |
| install\_private\_registry | Whether to start a private registry | `bool` | `true` | no |
| k3d-cluster-domain | The default domain name used in the cluster | `string` | n/a | yes |
| k3d-cluster-ip | The Cluster IP | `string` | `"0.0.0.0"` | no |
| k3d-cluster-name | K3DS cluster prefix | `list(string)` | <pre>[<br> "k3d"<br>]</pre> | no |
| k3d-cluster-port | The port for the k8s API server | `number` | `6445` | no |
| k3d-network-gateway | The network gateway for the cluster | `string` | `"172.19.0.1"` | no |
| k3d-network-subnet | The subnet for the cluster | `string` | `"172.19.0.0/16"` | no |
| k3s-version | K3S version to use for the k3s containers | `string` | `"latest"` | no |
| server-node-count | The amount of server nodes | `number` | `1` | no |
| worker-node-count | The amount of worker nodes | `number` | `0` | no |

### Outputs

| Name | Description |
|------|-------------|
| clusters\_created | The named of the created cluster |
| expose\_azurite | The cluster is listen on Azurite ports (10000-10002) |
| expose\_jaeger | The cluster is listen on Jaeger ports (6831-6832) |
| expose\_loki | The cluster is listen on Loki port (3100) |
| expose\_nosql\_mongodb | The cluster is listen on MongoDB port (27017) |
| expose\_opentelemetry | The cluster is listen on OpenTelemetry Collector ports(4317-4318) |
| expose\_rabbitmq | The cluster is listen on Rabbitmq port (5672) |
| expose\_rds\_mariadb | The cluster is listen on MariaDB port (3307) (trying not to conflict with MySQL) |
| expose\_rds\_mssql | The cluster is listen on SQL Server port (1433) |
| expose\_rds\_mysql | The cluster is listen on MySQL port (3306) |
| expose\_rds\_oracle | The cluster is listen on Oracle port (1521) |
| expose\_rds\_postgres | The cluster is listen on Postgres port (5432) |
| expose\_seq | The cluster is listen on Seq port (5341) |
| k3d\_api\_port | Cluster port |
| k3d\_cluster\_ip | Cluster IP |
<!-- END_TF_DOCS -->
Loading

0 comments on commit 973aecb

Please sign in to comment.