Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌪️ APC Airflow #6448

Merged
merged 4 commits into from
Jun 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module "eks" {
#checkov:skip=CKV_TF_2:Module registry does not support tags for versions

source = "terraform-aws-modules/eks/aws"
version = "20.12.0"
version = "20.13.1"

cluster_name = local.eks_cluster_name
cluster_version = local.environment_configuration.eks_cluster_version
Expand Down Expand Up @@ -98,10 +98,40 @@ module "eks" {
eks_managed_node_groups = {
general = {
min_size = 1
max_size = 5
max_size = 10
desired_size = 3
instance_types = ["t3.xlarge"]
}
airflow-high-memory = {
min_size = 0
max_size = 1
desired_size = 0
instance_types = ["r6i.8xlarge"]
labels = {
high-memory = "true"
}
taints = [
{
key = "high-memory"
value = "true"
effect = "NO_SCHEDULE"
}
]
block_device_mappings = {
xvdb = {
device_name = "/dev/xvdb"
ebs = {
volume_size = 200
volume_type = "gp3"
iops = 3000
throughput = 250
encrypted = true
kms_key_id = module.ebs_kms.key_arn
delete_on_termination = true
}
}
}
}
}

access_entries = {
Expand All @@ -116,6 +146,11 @@ module "eks" {
}
}
}
data-engineering-airflow = {
principal_arn = local.environment_configuration.data_engineering_airflow_execution_role_arn
username = "data-engineering-airflow"
kubernetes_groups = ["airflow"]
}
}

tags = local.tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ locals {
coredns = "v1.11.1-eksbuild.9"
kube_proxy = "v1.30.0-eksbuild.3"
aws_ebs_csi_driver = "v1.31.0-eksbuild.1"
aws_efs_csi_driver = "v2.0.2-eksbuild.1"
aws_efs_csi_driver = "v2.0.3-eksbuild.1"
aws_guardduty_agent = "v1.6.1-eksbuild.1"
eks_pod_identity_agent = "v1.2.0-eksbuild.1"
vpc_cni = "v1.18.1-eksbuild.3"
}

/* Data Engineering Airflow */
data_engineering_airflow_execution_role_arn = "arn:aws:iam::593291632749:role/airflow-dev-execution-role"

/* Observability Platform */
observability_platform = "development"

Expand Down Expand Up @@ -80,7 +83,7 @@ locals {
coredns = "v1.11.1-eksbuild.9"
kube_proxy = "v1.30.0-eksbuild.3"
aws_ebs_csi_driver = "v1.31.0-eksbuild.1"
aws_efs_csi_driver = "v2.0.2-eksbuild.1"
aws_efs_csi_driver = "v2.0.3-eksbuild.1"
aws_guardduty_agent = "v1.6.1-eksbuild.1"
eks_pod_identity_agent = "v1.2.0-eksbuild.1"
vpc_cni = "v1.18.1-eksbuild.3"
Expand All @@ -89,6 +92,9 @@ locals {
/* Observability Platform */
observability_platform = "development"

/* Data Engineering Airflow */
data_engineering_airflow_execution_role_arn = "arn:aws:iam::593291632749:role/airflow-dev-execution-role"

/* QuickSight */
quicksight_notification_email = "[email protected]"
}
Expand All @@ -115,12 +121,15 @@ locals {
coredns = "v1.11.1-eksbuild.9"
kube_proxy = "v1.30.0-eksbuild.3"
aws_ebs_csi_driver = "v1.31.0-eksbuild.1"
aws_efs_csi_driver = "v2.0.2-eksbuild.1"
aws_efs_csi_driver = "v2.0.3-eksbuild.1"
aws_guardduty_agent = "v1.6.1-eksbuild.1"
eks_pod_identity_agent = "v1.2.0-eksbuild.1"
vpc_cni = "v1.18.1-eksbuild.3"
}

/* Data Engineering Airflow */
data_engineering_airflow_execution_role_arn = "arn:aws:iam::593291632749:role/airflow-prod-execution-role"

/* Observability Platform */
observability_platform = "production"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ resource "kubernetes_namespace" "actions_runners" {
metadata {
name = "actions-runners"
labels = {
"pod-security.kubernetes.io/enforce" = "baseline"
"pod-security.kubernetes.io/enforce-version" = "v${local.environment_configuration.eks_cluster_version}"
"pod-security.kubernetes.io/enforce" = "baseline"
"compute.analytical-platform.service.justice.gov.uk/workload" = "actions-runners"
}
}
}

resource "kubernetes_namespace" "airflow" {
metadata {
name = "airflow"
labels = {
"pod-security.kubernetes.io/enforce" = "restricted"
"compute.analytical-platform.service.justice.gov.uk/workload" = "airflow"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "kubernetes_role_binding" "airflow_execution" {
metadata {
name = "airflow-execution"
namespace = kubernetes_namespace.airflow.metadata[0].name
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "Role"
name = kubernetes_role.airflow_execution.metadata[0].name
}
subject {
api_group = "rbac.authorization.k8s.io"
kind = "Group"
name = "airflow"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Derived from https://docs.aws.amazon.com/mwaa/latest/userguide/mwaa-eks-example.html#eksctl-role
resource "kubernetes_role" "airflow_execution" {
metadata {
name = "airflow-execution"
namespace = kubernetes_namespace.airflow.metadata[0].name
}
rule {
api_groups = [
"",
"apps",
"batch",
"extensions",
]
resources = [
"jobs",
"pods",
"pods/attach",
"pods/exec",
"pods/log",
"pods/portforward",
"secrets",
"services"
]
verbs = [
"create",
"delete",
"describe",
"get",
"list",
"patch",
"update"
]
}
}