Skip to content

Commit

Permalink
Merge branch 'awslabs:main' into streaming_redpanda
Browse files Browse the repository at this point in the history
  • Loading branch information
ashapiaws authored May 1, 2024
2 parents cd6c19c + 99e5440 commit cd2e7c7
Show file tree
Hide file tree
Showing 67 changed files with 4,207 additions and 9 deletions.
Empty file modified README.md
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions ai-ml/jark-stack/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Docs coming soon...
|------|-------------|------|---------|:--------:|
| <a name="input_eks_cluster_version"></a> [eks\_cluster\_version](#input\_eks\_cluster\_version) | EKS Cluster version | `string` | `"1.29"` | no |
| <a name="input_enable_aws_efa_k8s_device_plugin"></a> [enable\_aws\_efa\_k8s\_device\_plugin](#input\_enable\_aws\_efa\_k8s\_device\_plugin) | Enable AWS EFA K8s Device Plugin | `bool` | `false` | no |
| <a name="input_enable_kubecost"></a> [enable\_kubecost](#input\_enable\_kubecost) | Enable Kubecost addon | `bool` | `false` | no |
| <a name="input_huggingface_token"></a> [huggingface\_token](#input\_huggingface\_token) | Hugging Face Secret Token | `string` | `"DUMMY_TOKEN_REPLACE_ME"` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the VPC and EKS Cluster | `string` | `"jark-stack"` | no |
| <a name="input_region"></a> [region](#input\_region) | region | `string` | `"us-west-2"` | no |
Expand Down
11 changes: 11 additions & 0 deletions ai-ml/jark-stack/terraform/addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ module "data_addons" {
values = [file("${path.module}/helm-values/aws-efa-k8s-device-plugin-values.yaml")]
}

#---------------------------------------------------------------
# Kubecost Add-on
#---------------------------------------------------------------
enable_kubecost = var.enable_kubecost
kubecost_helm_config = {
values = [templatefile("${path.module}/helm-values/kubecost-values.yaml", {})]
version = "2.2.2"
repository_username = data.aws_ecrpublic_authorization_token.token.user_name
repository_password = data.aws_ecrpublic_authorization_token.token.password
}

#---------------------------------------------------------------
# Karpenter Resources Add-on
#---------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions ai-ml/jark-stack/terraform/examples/training/README.md

This file was deleted.

69 changes: 69 additions & 0 deletions ai-ml/jark-stack/terraform/helm-values/kubecost-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

# KubeCost WebUI -> kubectl port-forward --namespace kubecost deployment/kubecost-cost-analyzer 9090

global:
# pricingCsv:
# enabled: false
# location:
# provider: "AWS"
# region: "us-east-1"
# URI: s3://kc-csv-test/pricing_schema.csv # a valid file URI
# csvAccessCredentials: pricing-schema-access-secret

prometheus:
enabled: true # Kubecost depends on Prometheus data, it is not optional. When enabled: false, Prometheus will not be installed and you must configure your own Prometheus to scrape kubecost as well as provide the fqdn below. -- Warning: Before changing this setting, please read to understand the risks https://docs.kubecost.com/install-and-configure/install/custom-prom
fqdn: http://cost-analyzer-prometheus-server.default.svc # example address of a prometheus to connect to. Include protocol (http:// or https://) Ignored if enabled: true

grafana:
enabled: true # If false, Grafana will not be installed
domainName: cost-analyzer-grafana.default.svc # example grafana domain Ignored if enabled: true
scheme: "http" # http or https, for the domain name above.
proxy: true # If true, the kubecost frontend will route to your grafana through its service endpoint

kubecostFrontend:
image: public.ecr.aws/kubecost/frontend
resources:
requests:
cpu: "200m"
memory: "512Mi"

kubecostMetrics:
emitPodAnnotations: true
emitNamespaceAnnotations: true

kubecostModel:
image: public.ecr.aws/kubecost/cost-model
resources:
requests:
cpu: "500m"
memory: "512Mi"

forecasting:
fullImageName: public.ecr.aws/kubecost/kubecost-modeling:v0.1.6

networkCosts:
image:
repository: public.ecr.aws/kubecost/kubecost-network-costs

clusterController:
image:
repository: public.ecr.aws/kubecost/cluster-controller

prometheus:
server:
image:
repository: public.ecr.aws/kubecost/prometheus

configmapReload:
prometheus:
image:
repository: public.ecr.aws/kubecost/prometheus-config-reloader

reporting:
productAnalytics: false

# Define persistence volume for cost-analyzer
persistentVolume:
size: 32Gi
dbSize: 32.0Gi
enabled: true # Note that setting this to false means configurations will be wiped out on pod restart.
6 changes: 6 additions & 0 deletions ai-ml/jark-stack/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ variable "enable_aws_efa_k8s_device_plugin" {
type = bool
default = false
}

variable "enable_kubecost" {
description = "Enable Kubecost addon"
type = bool
default = false
}
2 changes: 1 addition & 1 deletion analytics/terraform/emr-eks-karpenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Checkout the [documentation website](https://awslabs.github.io/data-on-eks/docs/

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_eks_cluster_version"></a> [eks\_cluster\_version](#input\_eks\_cluster\_version) | EKS Cluster version | `string` | `"1.28"` | no |
| <a name="input_eks_cluster_version"></a> [eks\_cluster\_version](#input\_eks\_cluster\_version) | EKS Cluster version | `string` | `"1.29"` | no |
| <a name="input_enable_amazon_prometheus"></a> [enable\_amazon\_prometheus](#input\_enable\_amazon\_prometheus) | Enable AWS Managed Prometheus service | `bool` | `true` | no |
| <a name="input_enable_emr_spark_operator"></a> [enable\_emr\_spark\_operator](#input\_enable\_emr\_spark\_operator) | Enable the Spark Operator to submit jobs with EMR Runtime | `bool` | `false` | no |
| <a name="input_enable_fsx_for_lustre"></a> [enable\_fsx\_for\_lustre](#input\_enable\_fsx\_for\_lustre) | Deploys fsx for lustre addon, storage class and static FSx for Lustre filesystem for EMR | `bool` | `false` | no |
Expand Down
2 changes: 1 addition & 1 deletion analytics/terraform/emr-eks-karpenter/addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module "eks_blueprints_addons" {
}
}
karpenter = {
chart_version = "v0.33.1"
chart_version = "0.36.0"
repository_username = data.aws_ecrpublic_authorization_token.token.user_name
repository_password = data.aws_ecrpublic_authorization_token.token.password
}
Expand Down
2 changes: 1 addition & 1 deletion analytics/terraform/emr-eks-karpenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "region" {
variable "eks_cluster_version" {
description = "EKS Cluster version"
type = string
default = "1.28"
default = "1.29"
}
variable "tags" {
description = "Default tags"
Expand Down
52 changes: 52 additions & 0 deletions analytics/terraform/superset-on-eks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Requirements

For security reasons, ALB is deployed as internal one and it can be changed to internet-facing during the deployment, if needed.
## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.36.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.12.1 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.25.2 |
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.2 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_ebs_csi_driver_irsa"></a> [ebs\_csi\_driver\_irsa](#module\_ebs\_csi\_driver\_irsa) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | ~> 5.20 |
| <a name="module_eks"></a> [eks](#module\_eks) | terraform-aws-modules/eks/aws | ~> 19.15 |
| <a name="module_eks_blueprints_addons"></a> [eks\_blueprints\_addons](#module\_eks\_blueprints\_addons) | aws-ia/eks-blueprints-addons/aws | ~> 1.2 |
| <a name="module_lb_role"></a> [lb\_role](#module\_lb\_role) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | 5.37.1 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |

## Resources

| Name | Type |
|------|------|
| [helm_release.alb_controller](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.superset](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_ingress_class_v1.aws_alb](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress_class_v1) | resource |
| [kubernetes_ingress_v1.superset](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress_v1) | resource |
| [kubernetes_namespace.superset](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
| [kubernetes_service_account.service_account](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/service_account) | resource |
| [null_resource.add_superset_repo](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.helm_update_repos](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_eks_cluster_version"></a> [eks\_cluster\_version](#input\_eks\_cluster\_version) | EKS Cluster version | `string` | `"1.28"` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the VPC and EKS Cluster | `string` | `"superset-on-eks"` | no |
| <a name="input_region"></a> [region](#input\_region) | Region | `string` | `"us-east-1"` | no |
| <a name="input_secondary_cidr_blocks"></a> [secondary\_cidr\_blocks](#input\_secondary\_cidr\_blocks) | Secondary CIDR blocks to be attached to VPC | `list(string)` | <pre>[<br> "100.64.0.0/16"<br>]</pre> | no |
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | VPC CIDR. This should be a valid private (RFC 1918) CIDR range | `string` | `"10.1.0.0/21"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_configure_kubectl"></a> [configure\_kubectl](#output\_configure\_kubectl) | Configure kubectl: make sure you're logged in with the correct AWS profile and run the following command to update your kubeconfig |
| <a name="output_superset_url"></a> [superset\_url](#output\_superset\_url) | Configure kubectl: Once the kubeconfig is configured as above, use the below command to get the Superset URL |
160 changes: 160 additions & 0 deletions analytics/terraform/superset-on-eks/addons.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#---------------------------------------------------------------
# GP3 Encrypted Storage Class
#---------------------------------------------------------------
resource "kubernetes_annotations" "disable_gp2" {
annotations = {
"storageclass.kubernetes.io/is-default-class" : "false"
}
api_version = "storage.k8s.io/v1"
kind = "StorageClass"
metadata {
name = "gp2"
}
force = true

depends_on = [module.eks.eks_cluster_id]
}

resource "kubernetes_storage_class" "default_gp3" {
metadata {
name = "gp3"
annotations = {
"storageclass.kubernetes.io/is-default-class" : "true"
}
}

storage_provisioner = "ebs.csi.aws.com"
reclaim_policy = "Delete"
allow_volume_expansion = true
volume_binding_mode = "WaitForFirstConsumer"
parameters = {
fsType = "ext4"
encrypted = true
type = "gp3"
}

depends_on = [kubernetes_annotations.disable_gp2]
}

#---------------------------------------------------------------
# IRSA for EBS CSI Driver
#---------------------------------------------------------------
module "ebs_csi_driver_irsa" {
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
version = "~> 5.20"
role_name_prefix = format("%s-%s", local.name, "ebs-csi-driver-")
attach_ebs_csi_policy = true
oidc_providers = {
main = {
provider_arn = module.eks.oidc_provider_arn
namespace_service_accounts = ["kube-system:ebs-csi-controller-sa"]
}
}
tags = local.tags
}

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.2"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
cluster_version = module.eks.cluster_version
oidc_provider_arn = module.eks.oidc_provider_arn

#---------------------------------------
# Amazon EKS Managed Add-ons
#---------------------------------------
eks_addons = {
aws-ebs-csi-driver = {
service_account_role_arn = module.ebs_csi_driver_irsa.iam_role_arn
}
coredns = {
preserve = true
}
vpc-cni = {
preserve = true
}
kube-proxy = {
preserve = true
}
}

#---------------------------------------
# AWS Load Balancer Controller Add-on
#---------------------------------------
enable_aws_load_balancer_controller = true
# turn off the mutating webhook for services because we are using
# service.beta.kubernetes.io/aws-load-balancer-type: external
aws_load_balancer_controller = {
set = [{
name = "enableServiceMutatorWebhook"
value = "false"
}]
}

tags = local.tags
}

module "eks_data_addons" {
source = "aws-ia/eks-data-addons/aws"
version = "~> 1.31.5" # ensure to update this to the latest/desired version

oidc_provider_arn = module.eks.oidc_provider_arn

#---------------------------------------
# AWS Apache Superset Add-on
#---------------------------------------
enable_superset = true
superset_helm_config = {
values = [templatefile("${path.module}/helm-values/superset-values.yaml", {})]
}
depends_on = [module.eks_blueprints_addons]

}

#------------------------------------------------------------
# Create AWS Application Load balancer with Ingres
#------------------------------------------------------------
resource "kubernetes_ingress_class_v1" "aws_alb" {
metadata {
name = "aws-alb"
}

spec {
controller = "ingress.k8s.aws/alb"
}

depends_on = [module.eks.cluster_id]
}

resource "kubernetes_ingress_v1" "superset" {
metadata {
name = "superset-ingress3"
namespace = "superset"
annotations = {
"alb.ingress.kubernetes.io/scheme" = "internet-facing"
"alb.ingress.kubernetes.io/target-type" = "ip"
}
}
spec {
ingress_class_name = "aws-alb"
rule {
http {
path {
path = "/*"
backend {
service {
name = "superset"
port {
number = 8088
}
}
}
}
}
}
}

depends_on = [module.eks_blueprints_addons, module.eks_data_addons]
}
Loading

0 comments on commit cd2e7c7

Please sign in to comment.