Skip to content

Commit b4f9ce3

Browse files
feat: Create Deployment documentation and examples in Terraform (#13)
* ops: Create Examples and modules for deploying medcat to AWS, Azure and Openstack * docs: Create documentation for the deployment examples
1 parent 9ffc3ec commit b4f9ce3

File tree

113 files changed

+4240
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+4240
-6
lines changed

.devcontainer/devcontainer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
66
"image": "mcr.microsoft.com/devcontainers/base:jammy",
77
"features": {
8-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
9-
"ghcr.io/devcontainers/features/python:1": {}
8+
"ghcr.io/devcontainers/features/python:1": {},
9+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
10+
"ghcr.io/devcontainers/features/terraform:1": {},
11+
"ghcr.io/devcontainers-extra/features/ansible:2": {},
12+
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
13+
"ghcr.io/devcontainers/features/aws-cli:1": {},
14+
"ghcr.io/devcontainers/features/azure-cli:1": {}
1015
},
1116

1217
// Features to add to the dev container. More info: https://containers.dev/features.

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,46 @@
22
observability/examples/simple/observability-simple
33
observability/examples/full/cogstack-observability
44
_build
5+
**/.build/
6+
7+
8+
### Terraform Git Ignore
9+
# https://github.com/github/gitignore/blob/main/Terraform.gitignore
10+
11+
# Local .terraform directories
12+
**/.terraform/
13+
14+
# .tfstate files
15+
**/*.tfstate
16+
**/*.tfstate.*
17+
18+
# Crash log files
19+
**/crash.log
20+
**/crash.*.log
21+
22+
# Exclude all .tfvars files, which are likely to contain sensitive data
23+
**/*.tfvars
24+
**/*.tfvars.json
25+
26+
# Ignore override files
27+
**/override.tf
28+
**/override.tf.json
29+
**/*_override.tf
30+
**/*_override.tf.json
31+
32+
# Ignore transient lock info files created by terraform apply
33+
**/.terraform.tfstate.lock.info
34+
35+
# Include override files you do wish to add to version control using negated pattern
36+
# !example_override.tf
37+
38+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
39+
# example: *tfplan*
40+
41+
# Ignore CLI configuration files
42+
**/.terraformrc
43+
**/terraform.rc
44+
545

646
# Python ignores
747
# Byte-compiled / optimized / DLL files

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files.exclude": {
3+
"**/.terraform/": true,
4+
"**/.terraform.lock.hcl": true,
5+
"**/terraform.tfstate": true,
6+
"**/terraform.tfstate.backup": true,
7+
"**/terraform.tfstate.*.backup": true,
8+
"**/.ansible/": true
9+
}
10+
}

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
# Cogstack Platform Toolkit
1+
# Cogstack Platform
22

33
This repository contains tools and services used to support CogStack deployments
44

5-
See the latest documentation on [Readthedocs](https://cogstack-platform-toolkit.readthedocs.io/en/latest/observability/_index.html)
5+
See the latest documentation on [Readthedocs](https://docs.cogstack.org/en/latest/)
6+
7+
## Project contents
8+
- Source for the official cogstack documentation. This git repo stores the top level documetation that hosts on https://docs.cogstack.org
9+
- CogStack deployment instructions and examples
10+
- CogStack platform tools eg Observability.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export AWS_ACCESS_KEY_ID=
2+
export AWS_SECRET_ACCESS_KEY=
3+
export AWS_REGION=eu-west-1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
.env
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# AWS EKS Deployment
2+
3+
This is an example deployment of CogStack in AWS. It will create publically accessible services, so is not suitable for production deployment.
4+
5+
The recommended deployment in AWS is based on using Kubernetes through AWS EKS.
6+
7+
This example will create a AWS EKS cluster, setup any necessary config, deploy CogStack to the cluster, and test that it is available.
8+
9+
## Usage
10+
Deployment through terraform is carried out through two terraform commands, to handle the sequencing issues between making a k8s cluster and using it in AWS.
11+
12+
### Requirements
13+
- Terraform - [Install Terraform](https://developer.hashicorp.com/terraform/install)
14+
- AWS Credentials for an account that can create and destroy resources.
15+
16+
17+
### Steps
18+
19+
### 1. Add Required Secrets for your env
20+
This readme uses environment variables for access:
21+
22+
1. See the `.env.example` file for the required details.
23+
2. Create a file `.env` with those fields set for your account.
24+
3. Execute `source .env` to set those environment variables
25+
26+
If desired, see the official documentation for other ways to provide AWS credentials https://registry.terraform.io/providers/hashicorp/aws/latest/docs#authentication-and-configuration
27+
28+
### 2. Run Terraform
29+
Terraform is run on two modules for AWS, so we will run one terraform apply in one folder, then another terraform apply in a second folder.
30+
31+
Initial provisioning takes around 15 minutes.
32+
33+
```bash
34+
# Set AWS credentials
35+
source .env
36+
37+
# Create AWS EKS infra
38+
cd eks-cluster
39+
terraform init
40+
terraform apply --auto-approve
41+
42+
AWS_KUBECONFIG=$(terraform output -raw kubeconfig_file)
43+
44+
# Deploy services to kubernetes
45+
cd ../kubernetes-deployment
46+
export TF_VAR_kubeconfig_file=$AWS_KUBECONFIG
47+
terraform init
48+
terraform apply --auto-approve
49+
```
50+
51+
### 3. Accessing the CogStack Platform
52+
53+
Once the deployment is complete and all services are running, you can access the CogStack platform and its components using the following URLs:
54+
55+
```bash
56+
terraform output service_urls
57+
```
58+
59+
60+
### Optional - Destroy
61+
62+
You can destroy the infra to save costs when it wont be used for a long time.
63+
64+
Do note that there is an initial cost every time the EKS infrastructure is created, looks to be around $0.50 at time of writing.
65+
66+
```bash
67+
cd ../kubernetes-deployment
68+
terraform destroy
69+
70+
cd ../eks-cluster
71+
terraform destroy
72+
```
73+
74+
75+
## Optionally use the K8s cluster as normal with the CLI
76+
After setting up the cluster, it is possible to interact directly with it using the kubectl CLI
77+
78+
The requirement is to get the KUBECONFIG file created by the terraform apply.
79+
80+
```bash
81+
# Get KUBECONFIG
82+
cd eks-cluster
83+
AWS_KUBECONFIG=$(terraform output -raw kubeconfig_file)
84+
85+
# SET KUBECONFIG
86+
export KUBECONFIG=${AWS_KUBECONFIG}
87+
```
88+
89+
Note - alternatively you could use the AWS CLI to set your kubeconfig using `aws eks update-kubeconfig --name $(terraform output -raw cluster_name)`.
90+
91+
You can then interact with kubernetes via the CLI
92+
93+
```bash
94+
# Run Medcat service
95+
helm install my-medcat oci://registry-1.docker.io/cogstacksystems/medcat-service-helm --wait --timeout 10m0s
96+
97+
# Create the ingress
98+
kubectl apply -f resources/ingress-medcat-service.yaml
99+
# Find public url
100+
kubectl get ingress
101+
```

deployment/terraform/examples/aws-kubernetes/eks-cluster/.terraform.lock.hcl

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)