1. Deploy the plex-media-server helm chart on AWS EKS

    TypeScript

    To deploy the Plex Media Server on an AWS EKS cluster using Pulumi, you'll go through a few high-level steps:

    1. Create an EKS cluster using the @pulumi/eks module.
    2. Deploy the Plex Media Server using the @pulumi/kubernetes module and the helm.v3.Chart resource.

    Creating an EKS Cluster

    Firstly, you need to create an Amazon EKS cluster. You can do this using Pulumi's EKS package, which provides a high-level abstraction over AWS infrastructure needed to run an EKS cluster. This abstraction simplifies the process significantly.

    Here's how you can create an EKS cluster with Pulumi's EKS package:

    1. Import the necessary Pulumi packages.
    2. Define the EKS cluster by creating a new instance of Cluster.

    Deploying the Plex Media Server Helm Chart

    After setting up your EKS cluster, you'll use Pulumi's Kubernetes package to deploy the Plex Media Server using Helm Charts. The helm.v3.Chart resource from the @pulumi/kubernetes package allows you to deploy Helm charts in a Kubernetes cluster.

    Complete Program

    Below you'll find a complete TypeScript program that sets up an EKS cluster and deploys the Plex Media Server Helm chart. You need to have AWS access configured for Pulumi and Helm chart details for the Plex Media Server ready to use this code.

    import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; // Create an EKS cluster with default settings. const cluster = new eks.Cluster("plex-media-server-cluster", {}); // Once the cluster is created, it provides a kubeconfig that we can use to configure a k8s provider instance. const k8sProvider = new k8s.Provider("plex-k8s-provider", { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Now deploy the Plex Media Server Helm chart into the cluster using the Helm Chart resource. const plexChart = new k8s.helm.v3.Chart("plex-media-server", { chart: "plex-media-server", // Replace `<REPO>` with the repository that contains the plex-media-server chart. // This might require adding that repo to Helm with `helm repo add` if it's not a standard one. repo: "<REPO>", version: "<CHART_VERSION>", // Specify the version of the chart you'd like to deploy namespace: "default", // The Kubernetes namespace to deploy the chart. Use "default" or create a new one if required. }, { provider: k8sProvider }); // Export the kubeconfig and the EKS cluster's name to access them easily later on. export const kubeconfig = cluster.kubeconfig; export const clusterName = cluster.core.cluster.name;

    In the program above:

    • The eks.Cluster class creates an Amazon EKS cluster. This includes the required compute infrastructure to run the Kubernetes control plane and worker nodes.
    • The k8s.Provider class utilizes the generated kubeconfig from our EKS cluster to interact with it using Pulumi's Kubernetes provider.
    • The k8s.helm.v3.Chart class is used to deploy the Plex Media Server on EKS using its Helm chart.
    • We've exported the kubeconfig and clusterName to make it easy to connect to the cluster after the program has finished running.

    Make sure you replace <REPO> and <CHART_VERSION> with the appropriate Helm repository and chart version for Plex Media Server.

    After writing this code in a TypeScript file (for example, index.ts), you can deploy it using Pulumi CLI commands:

    1. Install Pulumi CLI and set up your AWS credentials.
    2. Navigate to the directory containing your index.ts file and run pulumi up. This will start the deployment process.

    Pulumi will print out the planned changes before prompting you to confirm if you want to proceed with the deployment. Once you confirm, it will provision your EKS cluster and deploy the Plex Media Server Helm chart.