1. Deploy the label-studio helm chart on AWS EKS

    TypeScript

    To deploy the Label Studio helm chart on AWS EKS using Pulumi, you will first need to create an EKS cluster, and then deploy the helm chart to that cluster. We will leverage Pulumi's AWS EKS and Kubernetes packages to accomplish this.

    To begin, I’ll run you through the steps we’re going to follow in our Pulumi program:

    1. Create an EKS Cluster: Using the eks.Cluster resource, we'll configure the necessary parameters such as the EKS role, VPC, subnets, and the version of EKS we want to deploy.
    2. Deploy the Helm Chart: With the cluster in place, we'll use the kubernetes.helm.v3.Chart resource to deploy Label Studio from its helm chart repository.

    Without further ado, let’s start off with the Pulumi TypeScript program:

    import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; // Step 1: Create an AWS EKS Cluster const role = new aws.iam.Role("eksRole", { assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: "eks.amazonaws.com", }), }); const rolePolicyAttachment = new aws.iam.RolePolicyAttachment("eks-access", { role: role, policyArn: "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", // This policy provides the necessary permissions for EKS. }); const vpc = new aws.ec2.Vpc("eksVpc", { cidrBlock: "10.100.0.0/16", // Define the CIDR block for the VPC. Adjust according to your networking requirements. enableDnsHostnames: true, }); const subnet = new aws.ec2.Subnet("eksSubnet", { vpcId: vpc.id, cidrBlock: "10.100.1.0/24", // Define the CIDR block for the subnet. Adjust according to your networking requirements. availabilityZone: "us-west-2a", // Adjust the availability zone to the one that suits your geographical location. }); const cluster = new eks.Cluster("eksCluster", { roleArn: role.arn, vpcId: vpc.id, publicSubnetIds: [subnet.id], instanceType: "t2.medium", // Choose an instance type for your worker nodes. }); // Step 2: Install Label Studio helm chart using the Kubernetes provider const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeconfig, }); const labelStudioChart = new k8s.helm.v3.Chart("labelStudioChart", { chart: "label-studio", version: "1.0.0", // Specify the version of the Chart you want to deploy. fetchOpts: { repo: "http://helm.label-studio.com/" // This is a made-up Helm repo URL; replace with the actual URL of the Label Studio Helm repository. }, }, { provider: k8sProvider }); // Export the cluster's kubeconfig and the Label Studio service endpoint export const kubeconfig = cluster.kubeconfig; export const labelStudioServiceEndpoint = labelStudioChart.getResourceProperty("v1/Service", "label-studio", "status") .apply(status => status.loadBalancer.ingress[0].hostname || status.loadBalancer.ingress[0].ip);

    In this program:

    • We defined an IAM role that EKS will use to create and manage resources on your behalf.
    • We created a VPC and subnet which are mandatory to deploy an EKS cluster.
    • We then created the EKS cluster with the eks.Cluster resource using the IAM role and networking resources we created before.
    • Using a Provider tied to our new EKS cluster, we deployed the Label Studio helm chart.
    • Finally, we’re exporting the kubeconfig file needed to access the cluster with kubectl and the Label Studio service endpoint.

    To get this program running, you need Pulumi and AWS CLI configured with appropriate access to your AWS account.

    To apply this Pulumi program:

    1. Save the above TypeScript code to a file, say index.ts.
    2. Run pulumi up in the same directory. Follow the CLI prompts to perform the deployment.

    Remember to replace the version and repo with the correct version and repository of the Label Studio Helm chart. You can obtain these details from the maintainers of Label Studio Helm chart documentation or a public Helm chart repository that hosts it.

    Note that due to the Kubernetes load balancing, it may take a few minutes for the labelStudioServiceEndpoint to be available after the initial deployment is completed.

    Please also be aware that some Helm charts require custom configuration passed via the values property of the Chart resource. You should refer to Label Studio's Helm chart documentation for the required configuration values.