|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +from diagrams import Diagram, Cluster |
| 4 | +from diagrams.aws.compute import EKS, EC2 |
| 5 | +from diagrams.aws.network import VPC, PrivateSubnet, PublicSubnet, InternetGateway, NATGateway, Endpoint |
| 6 | +from diagrams.aws.security import IAMRole, IAM |
| 7 | +from diagrams.aws.storage import S3, FSx |
| 8 | +from diagrams.aws.ml import Sagemaker |
| 9 | +from diagrams.k8s.compute import Pod |
| 10 | + |
| 11 | +with Diagram("SageMaker HyperPod EKS Architecture", show=False, direction="TB"): |
| 12 | + |
| 13 | + # Internet Gateway |
| 14 | + igw = InternetGateway("Internet Gateway") |
| 15 | + |
| 16 | + with Cluster("VPC (10.192.0.0/16)"): |
| 17 | + |
| 18 | + with Cluster("Public Subnets"): |
| 19 | + pub_subnet_1 = PublicSubnet("Public Subnet 1\n(10.192.10.0/24)") |
| 20 | + pub_subnet_2 = PublicSubnet("Public Subnet 2\n(10.192.11.0/24)") |
| 21 | + nat_gw = NATGateway("NAT Gateway") |
| 22 | + |
| 23 | + with Cluster("Private Subnets"): |
| 24 | + private_subnet = PrivateSubnet("Private Subnet\n(10.1.0.0/16)") |
| 25 | + |
| 26 | + with Cluster("EKS Private Subnets"): |
| 27 | + eks_subnet_1 = PrivateSubnet("EKS Subnet 1\n(10.192.7.0/28)") |
| 28 | + eks_subnet_2 = PrivateSubnet("EKS Subnet 2\n(10.192.8.0/28)") |
| 29 | + eks_node_subnet = PrivateSubnet("EKS Node Subnet\n(10.192.9.0/24)") |
| 30 | + |
| 31 | + # Security Group |
| 32 | + sg = IAM("Security Group") |
| 33 | + |
| 34 | + # S3 VPC Endpoint |
| 35 | + s3_endpoint = Endpoint("S3 VPC Endpoint") |
| 36 | + |
| 37 | + with Cluster("EKS Cluster"): |
| 38 | + eks = EKS("EKS Cluster\n(Kubernetes 1.31)") |
| 39 | + |
| 40 | + with Cluster("Kubernetes Workloads"): |
| 41 | + helm_pods = Pod("HyperPod\nDependencies\n(Helm)") |
| 42 | + |
| 43 | + with Cluster("SageMaker HyperPod"): |
| 44 | + hyperpod = Sagemaker("HyperPod Cluster") |
| 45 | + |
| 46 | + with Cluster("Instance Groups"): |
| 47 | + instance_group = EC2("ml.trn1.32xlarge\nInstances") |
| 48 | + |
| 49 | + # FSx Lustre |
| 50 | + fsx = FSx("FSx Lustre\nHigh Performance\nStorage") |
| 51 | + |
| 52 | + # External Resources |
| 53 | + with Cluster("External AWS Services"): |
| 54 | + s3_bucket = S3("S3 Bucket\n(Lifecycle Scripts)") |
| 55 | + iam_role = IAMRole("SageMaker\nIAM Role") |
| 56 | + |
| 57 | + # Connections |
| 58 | + igw >> nat_gw |
| 59 | + nat_gw >> private_subnet |
| 60 | + |
| 61 | + # EKS connections |
| 62 | + eks >> helm_pods |
| 63 | + eks >> sg |
| 64 | + |
| 65 | + # HyperPod connections |
| 66 | + hyperpod >> instance_group |
| 67 | + hyperpod >> iam_role |
| 68 | + hyperpod >> fsx |
| 69 | + |
| 70 | + # Storage connections |
| 71 | + s3_endpoint >> s3_bucket |
| 72 | + instance_group >> fsx |
| 73 | + |
| 74 | + # Network flow |
| 75 | + private_subnet >> eks |
| 76 | + eks_subnet_1 >> eks |
| 77 | + eks_subnet_2 >> eks |
| 78 | + eks_node_subnet >> eks |
| 79 | + |
| 80 | +print("Architecture diagram generated as 'sagemaker_hyperpod_eks_architecture.png'") |
0 commit comments