Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 95 additions & 8 deletions deployment-examples/aws-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,42 @@ terraform apply --auto-approve

### 3. Accessing the CogStack Platform

Once the deployment is complete and all services are running, you can access the CogStack platform and its components using the following URLs:
Once the deployment is complete and all services are running, you can access the CogStack platform and its components.

We will use kubernetes port-forwarding to make the services accessible locally.

Run this command:

```bash
terraform output -raw cogstack_notes | bash
```

The console will now print all the URLs you can visit to access your CogStack deployment.

<!-- termynal -->
```bash
terraform output service_urls
$ terraform output -raw cogstack_notes | bash
Forwarding from 127.0.0.1:5001 -> 5000
Forwarding from [::1]:5001 -> 5000
Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000
Visit http://127.0.0.1:5000 to use MedCAT Service
Visit http://127.0.0.1:5001 to use AnonCAT
Visit http://127.0.0.1:8080 to use MedCAT Trainer
Visit https://127.0.0.1:9200 to use OpenSearch
Visit http://127.0.0.1:5601 to use OpenSearch Dashboards
Visit http://127.0.0.1:8000 to use jupyterhub
Visit http://127.0.0.1:8000/user/admin/notebooks/medcat-service-tutorial.ipynb to get started with a tutorial
```

### 4. Continue with the CogStack Tutorials

You've now got a fully working deployment of CogStack Community Edition!

Now you can look at the product tour and interactively follow along with this: https://docs.cogstack.org/en/latest/cogstack-ce/product-tour/ .

You've already port-forwarded the services, so you should be able to just open all the URLs and try out the applications.


### Optional - Destroy

Expand Down Expand Up @@ -88,14 +118,71 @@ export KUBECONFIG=${AWS_KUBECONFIG}

Note - alternatively you could use the AWS CLI to set your kubeconfig using `aws eks update-kubeconfig --name $(terraform output -raw cluster_name)`.

You can then interact with kubernetes via the CLI
You can then interact with kubernetes via the CLI for example:

```bash
# Run Medcat service
helm install my-medcat oci://registry-1.docker.io/cogstacksystems/medcat-service-helm --wait --timeout 10m0s
helm install medcat-service oci://registry-1.docker.io/cogstacksystems/medcat-service-helm --wait --timeout 10m0s
```

## Optional - Public Access

You can setup public access over the internet to your deployed services.

One way to do this is to use an AWS ALB, along with defining the ingress routes of the helm chart.

See this terraform code for an example

```hcl
resource "kubernetes_ingress_class" "application_load_balancer" {
# An Application Load Balancer is required in order to create public URLs.
# The load balancer controller creates instances of the ALB when it sees ingress objects with the right annotations.
metadata {
name = "alb"
labels = {
"app.kubernetes.io/name" = "LoadBalancerController"
}
}
spec {
controller = "eks.amazonaws.com/alb"
}
}

locals {
services = {
medcat_service = {
path_prefix = "medcat-service"
}
}
}
module "cogstack_helm_services" {
depends_on = [kubernetes_ingress_class.application_load_balancer]
source = "github.com/CogStack/cogstack-platform-toolkit//deployment/terraform/modules/cogstack-helm-services?ref=terraform-modules-v0.1.0"
medcat_service_values = <<EOT
ingress:
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/healthcheck-path: /api/health/live
className: alb
http:
- paths:
- path: /${local.services.medcat_service.path_prefix}
pathType: Prefix
EOT
}

locals {
medcat_ingress_address = module.cogstack_helm_services.service_urls.medcat_service.ip_address
}
output "service_urls" {
value = {
medcat_service = {
example_curl = "curl http://${local.medcat_ingress_address}/${local.services.medcat_service.path_prefix}/api/info"
example_ui = "http://${local.medcat_ingress_address}/${local.services.medcat_service.path_prefix}/docs"
}
}
description = "Public URls to call services on"
}

# Create the ingress
kubectl apply -f resources/ingress-medcat-service.yaml
# Find public url
kubectl get ingress
```
55 changes: 18 additions & 37 deletions deployment-examples/aws-kubernetes/kubernetes-deployment/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
resource "helm_release" "cogstack-ce" {
name = "cogstack"
chart = "oci://registry-1.docker.io/cogstacksystems/cogstack-ce-helm"
version = "0.6.0"
timeout = 600
atomic = true
render_subchart_notes = false
values = [ <<EOT
opensearch:
replicas: 1
EOT
]
}

provider "helm" {
kubernetes = {
Expand All @@ -9,42 +22,10 @@ provider "kubernetes" {
config_path = var.kubeconfig_file
}

resource "kubernetes_ingress_class" "application_load_balancer" {
# An Application Load Balancer is required in order to create public URLs.
# The load balancer controller creates instances of the ALB when it sees ingress objects with the right annotations.
metadata {
name = "alb"
labels = {
"app.kubernetes.io/name" = "LoadBalancerController"
}
}
spec {
controller = "eks.amazonaws.com/alb"
}
}


locals {
services = {
medcat_service = {
path_prefix = "medcat-service"
}
}
}
module "cogstack_helm_services" {
depends_on = [kubernetes_ingress_class.application_load_balancer]
source = "github.com/CogStack/cogstack-platform-toolkit//deployment/terraform/modules/cogstack-helm-services?ref=terraform-modules-v0.1.0"
medcat_service_values = <<EOT
ingress:
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/healthcheck-path: /api/health/live
className: alb
http:
- paths:
- path: /${local.services.medcat_service.path_prefix}
pathType: Prefix
EOT
variable "kubeconfig_file" {
description = "Path to the generated KUBECONFIG file used to connect to kubernetes"
}

output "cogstack_notes" {
value = helm_release.cogstack-ce.metadata.notes
}
15 changes: 0 additions & 15 deletions deployment-examples/aws-kubernetes/kubernetes-deployment/output.tf

This file was deleted.

This file was deleted.

Loading